-
Notifications
You must be signed in to change notification settings - Fork 154
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
[New Rule] Static methods SHOULD NOT be used #24
Comments
Hi i will work on this at next weekend |
This rule should not include tests which use PHPUnit because all |
@joni-jones I believe this is not relevant because the proposed sniff is looking for declaration of the static tests, not usage. Additionally, in the recent versions of PHPUnit all this methods are not invoked statically. |
This issue contains the explanation sebastianbergmann/phpunit#1914 and you can see Sebastian's answer and the community reaction. |
#24: [New Rule] Static methods SHOULD NOT be used
Implemented in #24 |
The PHPUnit maintainer is simply wrong on this issue. I have thoroughly analyzed PHPUnit's code, and unless we are going to declare willfully disregarding the static method calls are OK, then such an important code quality tool as PHPUnit should have code written for it using Or, PHPUnit needs to have a third class that does something like // Expose static assert methods for people who need them.
class Assert
{
public static function assertEquals($expected, $actual, $memo='')
{
return (new AssertLogic())->assertEquals($expected, $actual, $memo);
}
} Then extend |
…-coding-standard-224 [Imported] AC-958: create unit test for Magento2\Annotation checks
Rule
The use of
static
methods is discouraged.Reason
Source: Magento Technical Guidelines.
Plugins cannot be used with static methods, because static methods cannot be intercepted.
As a result, It hurts extensibility.
Implementation
T_STATIC
token.T_FUNCTION
is found right to it raise a warning.The text was updated successfully, but these errors were encountered: