-
Notifications
You must be signed in to change notification settings - Fork 48
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
Exclude PHPUnit asserts etc. from DynamicCallOnStaticMethodsRule? #36
Comments
|
If you don’t agree with this rule and want to call PHPUnit methods as
instance methods, simply put a regexp to ignoreErrors config key.
On Fri, 7 Sep 2018 at 18:18, Martin Hujer ***@***.***> wrote:
From
https://phpunit.readthedocs.io/en/7.3/assertions.html#static-vs-non-static-usage-of-assertion-methods
A common question, especially from developers new to PHPUnit, is whether
using $this->assertTrue() or self::assertTrue(), for instance, is “the
right way” to invoke an assertion. The short answer is: there is no right
way. And there is no wrong way, either. It is a matter of personal
preference.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#36 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuHd9t-7obaqRe4rHVxxuZMv-y0W8ks5uYpxQgaJpZM4WfGvE>
.
--
Ondřej Mirtes
|
@ondrejmirtes Could you gently say explicitly how to simply put a regexp to ignoreErrors config key? |
@eugcar In your phpstan.neon configuration file, add the following:
This will ignore the error for all relevant PHPUnit classes. |
It's in the README. |
@BluePsyduck @ondrejmirtes Thanks for your support. It works :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When using PHPUnit, assertions and some other methods are normally called dynamically (e.g.
$this->assertSame()
or$this->once()
), although they are declared as static methods. This of course triggers theDynamicCallOnStaticMethodsRule
for all these calls.According to the author of PHPUnit, it is encouraged to use
$this->
instead ofself::
.Keeping that in mind the question is: Should the PHPUnit classes (e.g.
PHPUnit\Framework\Assert
andPHPUnit\Framework\TestCase
) be excluded from theDynamicCallOnStaticMethodsRule
? (Maybe through a parameter to enable/disable this?)The text was updated successfully, but these errors were encountered: