-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not use class names as string literals #36
Comments
This issue is related not only to unit tests but to code in general. It is already implemented in EQP coding standard, as well as in Magento 2 core static checks. |
Hi @lenaorobei, cool thank you maybe we can discuss this at the community Meeting. |
It should definitely become a rule not to use class names as string literals. What we need is a decision how to best integrate this rule into extdn-phpcs. I would rather not rely on a Magento code base being available and |
A discussed idea was to look for arguments of certain methods like “ObjectManager::create()” but there are many possibilities where a class name can be used as string. We will try to implement the rule with a regular expression instead, using a low warning level, and try out if any false positives occur. The MEQP rule can be included as an addition – if there is no Magento installation, it will just find nothing. |
Rule
Warning for String-Representation in $this->createMock for Unit Test.
Reason
if you use String Representation typos can happen also it not nice for IDEs Usage Analyse
Implementation
Bad Example:
Recommendation Example:
The text was updated successfully, but these errors were encountered: