Open Matt-PMCT opened 1 year ago
Also, if I disable the plugin, the error goes away. I also could find no way to suppress or stop this.
After a bit of tinkering, I believe that what may be happening is that this plug-in is mistakenly classifying the variable as CSS. Then PHPpstorm says if this is CSS, then it must be proper CSS. I suspect this because if you change the string to be a proper CSS attribute with a colon and semi-colon, then PHPstorm is now happy:
but this is not CSS; it is a selector and should not have an error.
Just came to report same issue. It does marks invalid both HTML selectors $crawler->filter('h1')
and ID selectors: $crawler->filter('#payment')
. (HTML class selectors are OK $crawler->filter('.payment')
).
I guess that it is because of this workaround when the parameter of filter
method is wrapped so it becomes a snippet of CSS. I understand that Phpstorm probably does not have a CSS selector language available, but maybe a small adjustment to the prefix/suffix would help. When I tried adding {}
to my selector, e.g. $crawler->filter('h1 {}')
it made the error go away, because it is now valid CSS snippet.
btw. my sidebar in controller test looks like this these days (all are selector issues):
When I have the Symfony Plugin enabled I am getting errors for valid $crawler->filter() calls in my unit tests.
For example, this code, which is virtually identical to the Symfony Documentation (https://symfony.com/doc/current/components/dom_crawler.html#node-traversing):
$crawler->filter('h3')
or$crawler->filter('body')
Results in the IDE display an error stating " ':' expected " as seen in this picture:If I disable the Symfony Plugin, PHPStorm generates no errors, so I believe the source of it is this plugin. The code and test runs properly, so this error appears to have something to do with this plugin. The Crawler call is from this portion of Crawler.php: