0

Checking the Magento core I see two patterns a class with the slash in the beginning and a class without it.

Magento 2 Core preference type

What would be the difference?

1 Answer 1

1

As far as I can tell, there is none. I used to write the fully qualified class name with the leading slash and now I do it without the leading slash. Plugins, preferences, virtual types, arguments and anything else I have worked on have had no noticeable difference.

Looking at the phpClassName simpleType in vendor/magento/framework/ObjectManager/etc/config.xsd the pattern match for the start of the string is: \\? (Match 0 or 1 of the \ character) so it would seem that that the expected input does not care.

The only difference there potentially could be is a negligible performance difference, however the effort to investigate, benchmark and identify the faster option would be better spent working on the code in your own modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.