Search code examples
phpphpstormphpdoc

PhpStorm false positive inspections on CSS applied to dynamic content


With respect to the ever-powerful code inspections in PhpStorm, I am facing the following issue;

At some point in my project I am generating some html content from PHP (login forms in particular) and pass them over to one of my smarty templates at runtime.

In some of my templates I include simple css styling like this:

.login_fields {  // Warning here as unused css!
    color: red;
}

However since the forms are dynamically generated from the server, PhpStorm won't find the html and will instead generate a warning for the css as being unused which it isn't really.

The server generated forms look like this:

<form ...>
    <div class="login_fields">...</div>
...
</form>

Apart from suppressing the warnings, is there any way "to let PhpStorm know" that an html form is coming from the server so that it can see that the css applied to the templates is valid?

Any ideas? Thank you in advance.


Solution

  • PHPStorm can't analyze generated code and doesn't work correctly this way. The point of PhpStorm's engine is to analyze real files so that it can properly work. Analyzing dynamic code is difficult and dangerous because lots of interpretations are possible and that's the main reason it will generate errors.