This Question is Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
5 Replies Last post: Feb 6, 2013 4:02 PM by Jan Roald Haugland  
Adrian Grund Newbie 79 posts since
Jul 10, 2011
Currently Being Moderated

Mar 20, 2012 11:02 PM

@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.

Andriy Bazanov Master 4,177 posts since
May 28, 2010
Currently Being Moderated
Mar 20, 2012 11:11 PM in response to: Adrian Grund
Re: @noinspection for one line

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

Andriy Bazanov Master 4,177 posts since
May 28, 2010
Currently Being Moderated
Mar 21, 2012 12:41 AM in response to: Adrian Grund
Re: @noinspection for one line

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.

Jan Roald Haugland Newbie 6 posts since
Nov 28, 2011
Currently Being Moderated
Feb 6, 2013 4:02 PM in response to: Adrian Grund
Re: @noinspection for one line

Write it in two lines :-)

            echo "<div class='$classRegisterBackground' ";

            /** @noinspection PhpUndefinedVariableInspection */

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

More Like This

  • Retrieving data ...