PHPUnit has all assertions defined as static functions, but you are supposed to call them with object context1.
Apart from if this is a good practice or not, if you want to follow this practice you will get warnings in PhpStorm:
static method called as dynamic
I like this inspection and do not want to turn it off for all files. I do want to turn it off for phpunit tests, but adding a noinspection
comment to all my tests is annoying and repetitive.
How can I ignore this in tests, but have this inspection in my normal code?
I'm using PhpStorm 2016.3
1: see Sebastian's comment on this github issue.
A regular user of PHPUnit should use $this-> instead of self::
Also, all the examples in the manual use this method.
To ignore the "static method called as dynamic" errors in your tests, you can define a scope, and then change the inspections for that scope.
The setting-names etc are for PhpStorm 2016.3.
You can use the default Test
scope, by setting your tests directory as "test sources root". You can also create your own scope (see below)
Now make your inspection work only for this scope
If you have created a specific scope for your project with exclusions, you could also select only that scope here.
You might need to restart phpstorm or re-run inspections.
It looks like so: