You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
use PHP 5.5’s ::class keyword when referring to the fully qualified class name outside of that class
Since I'm not sure if that is on purpose or by accident, I didn't open a PR, but I think it makes no sense to only use the ::class constant for full class names and use strings for the rest.
Since the::class always is mapped to a fully qualified class name by the PHP preprocessor, there should be no need to use it only for fully qualified class names. It should be used every time a class name is referenced as a string.
Examples:
Non imported class name:
// Resolves to "\Magento\Path\To\Class"$this->get(\Magento\Path\To\Class::class);
Imported class name:
useFoo\Bar;
// ... other code// Resolves to "\Foo\Bar"$this->get(Bar::class);
Namespace relative class name:
namespaceBaz;
// ... other code// Resolves to "\Baz\Qux"$this->get(Qux::class);
Import relative class name
useMagento\Framework\Data;
// ... other code// Resolves to "\Magento\Framework\Data\Helper"$this->get(Data\Helper::class);
The text was updated successfully, but these errors were encountered:
Well... it's related, but I opened this issue so the wording in the documentation can be clarified. So the implementation you linked is basically the core team following the recommendation documented here.
The page http://devdocs.magento.com/guides/v2.0/coding-standards/code-standard-php.html states
Since I'm not sure if that is on purpose or by accident, I didn't open a PR, but I think it makes no sense to only use the
::class
constant for full class names and use strings for the rest.Since the
::class
always is mapped to a fully qualified class name by the PHP preprocessor, there should be no need to use it only for fully qualified class names. It should be used every time a class name is referenced as a string.Examples:
Non imported class name:
Imported class name:
Namespace relative class name:
Import relative class name
The text was updated successfully, but these errors were encountered: