In view templates, I'm seeing a lot of warnings to do with undefined fields on objects and undefined variables. I want to disable them.
Asked
Active
Viewed 922 times
2
-
What kind of "view files"? PHP based? If so -- have you tried providing correct type hint for them instead? It's better as it will allow them in code completion etc. – LazyOne Oct 07 '15 at 11:28
-
Yep PHP based. That works for the undefined fields and I can handle the undefined variables one at a time with the noinspection annotation. – chim Oct 07 '15 at 12:50
-
1But you can define variables as well ... Just have one (big) block at the top of the file where you define all variables/provide type hints -- syntax is the same. Does it work for you? Or is there any other reason you want to actually use inspection suppression mechanism? – LazyOne Oct 07 '15 at 13:06
-
Aah, misunderstood you earlier have got it now :) Thanks – chim Oct 07 '15 at 16:55
-
http://stackoverflow.com/questions/1816641/jetbrains-webide-php-variable-type-hinting – chim Oct 07 '15 at 16:56
1 Answers
3
You can provide type hints via standard PHPDoc comments -- just place such block at the top of the file and declare all variables used so they will be recognized and offered in code completion (yes, you can provide type hint for $this
this way as well):
<?php
/** @var \My\ViewRendererClass $this */
/** @var string $abcd */
...
?>
<div class="container">
...
In case if you actually need to disable certain inspection in whole file (or bunch of files) -- do this at Scope/Inspection level:
- Create new Scope (
Settings/Preferences | Appearance & Behaviour | Scopes
) and include all such files - In
Settings/Preferences | Editor | Inspections
find desired inspection and add new rule for that scope, e.g. disable for that scope but enabled in all other places.

LazyOne
- 158,824
- 45
- 388
- 391