Open rodrigoprimo opened 4 months ago
I have removed the Status: triage
label as Juliette already confirmed this to be a valid issue in https://github.com/squizlabs/PHP_CodeSniffer/issues/2830#issuecomment-2075880864. I also added the Standard: Generic
label.
Describe the bug
The Generic.ControlStructures.DisallowYodaConditions sniff has a method called
isArrayStatic()
that determines what the sniff considers to be static arrays. When static arrays are found on the side of a condition, the sniff triggers an error. I would expect the examples below to be considered static arrays and to trigger an error, but they are not.Code sample
To reproduce
Steps to reproduce the behavior:
test.php
with the code sample above.phpcs --standard=Generic --sniffs=Generic.ControlStructures.DisallowYodaConditions tests.php
Expected behavior
I would expect the sniff to generate a
Generic.ControlStructures.DisallowYodaConditions.Found
error for each line in the code sample above. Similar to what happens, for example, with['some string'] === $value
.Versions (please complete the following information)
Please confirm
master
branch of PHP_CodeSniffer.