私はポイントを逃しているかもしれませんが、なぜ特定のクラスに「使用」ステートメントがあるのか、時にはないのか疑問に思っています。
例:app\code\Magento\Email\Model\Template.php、ファイルの先頭にあります:
namespace Magento\Email\Model;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;次に、__constructメソッドには次のパラメーターがあります。
public function __construct(
    \Magento\Framework\Model\Context $context,
    \Magento\Framework\View\DesignInterface $design,
    \Magento\Framework\Registry $registry,
    \Magento\Store\Model\App\Emulation $appEmulation,
    StoreManagerInterface $storeManager,
    \Magento\Framework\View\Asset\Repository $assetRepo,
    \Magento\Framework\Filesystem $filesystem,
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    \Magento\Email\Model\Template\Config $emailConfig,
    \Magento\Email\Model\TemplateFactory $templateFactory,
    \Magento\Framework\Filter\FilterManager $filterManager,
    \Magento\Framework\UrlInterface $urlModel,
    \Magento\Email\Model\Template\FilterFactory $filterFactory,
    array $data = []
)したがってuse Magento\Store\Model\StoreManagerInterface;、クラスの先頭で呼び出したときStoreManagerInterface $storeManagerに、コンストラクターパラメーターで実行できることが明確にわかります。
私の質問は:
- なぜ1つのクラスだけでこれを行うのですか?
- useコンストラクターのすべてのクラスにステートメントを追加して、完全なクラスパスを入力する必要がないのはなぜですか?
- または、逆に、useステートメントを削除してStoreManagerInterfaceクラスへのフルパスを入力してみませんか?
use私が正しく指摘した特定のクラスに追加したポイントはありませんか?