how to ignore "void method return value used" inspection in test
I am writing unit test and I do want to validate that when a method should return void it does in fact return nothing (null).
It's quit easy to do with phpunit with the assertNull but I get a inspection warning about using the return value.
I don't want to disable the inspection completely since I would want the warning in the application context, but I would want to have a specific behaviour inside a test class (PHPUnit TestCase).
Is there any way to do that ?
Please sign in to leave a comment.
Hi there,
Inspections can be configured differently based on scopes: it can be enabled globally but disabled for specific scope (e.g. files from "tests" folder etc).
https://www.jetbrains.com/help/phpstorm/code-inspection.html
Just to be clear I don't wan to disable all inspection for tests directory, I want to disable this specific inspection for tests (ideally specificaly TestCase since I can have fixtures in tests directories).
I don't thing it will be possible that way since inspections will be applied to a full scope.
You cannot disable this for TestCase and child classes only.
I mean: you can disable ANY inspection for some scope (which can be specific files and/or folders -- just create your own custom scope) or you can suppress warnings manually -- be it per line or per whole file. Check "Suppressing Inspections" in help.
Once again: it's done on per-inspection basis not all-inspections-at-once.