@noinspection for one line

Hello,
is it possible to use @noinspection for just one line of code or for a special area in code?
E.g. I would like to suppress error for the following: "Cannot resolve file path '$pathMiddle'.

echo "<div class='$classRegisterBackground' style='background: url($pathMiddle) repeat-x;'>";

Just to switch off all inspection is no option, because I really need inspection.
On the other hand it is very hard for debugging to see always the same "warnings", so switching of error inspection for e.g. one line of code would be nice.

Thank you, Adrian.

5 comments

For Injected Language fragment (that's what you have) -- no.

0

Thank you for your fast answer.
I have seen there are a lot of @noinspection options, e.g. to suppress includes inspection etc.
Would it be difficult to implement a @noinspection just to suppress one line of code?
The thing is, that you have a lot of errors or warnings then.
Do you know a workaround?

Thanks a lot, Adrian.

0

Well -- this is CSS inspection, and suppression is not implemented for that at all. You can only submit Feature Request about this (Ability to suppress CSS inspections -- for statement/rule).

---

Because this is Injected Language (HTML in this particular case) -- why don't you try un-injecting it, so the string will be treated as ordinary php string and not HTML -- no HTML (well, CSS in this particular case) inspections will be applied to it.

It's far from ideal (as it will disable auto-injecting HTML language project-wide (no idea why it does that), but at least something to try.

What you can do (in current versions of PhpStorm) is to create multiple Inspection profiles (one for PHP, another for all other languages etc) and switch between them when needed -- not ideal as well.

0

Hi,
yes, I see. I think I will try that with different injection profiles. Thanks a lot!
Sincerely, Adrian.

0

Write it in two lines :-)

            echo "<div class='$classRegisterBackground' ";
            /** @noinspection PhpUndefinedVariableInspection */
            echo "style='background: url($pathMiddle) repeat-x;'>";

0

Please sign in to leave a comment.