Moxio / php-codesniffer-sniffs

Custom sniffs for PHP_CodeSniffer
MIT License
17 stars 10 forks source link

DisallowImplicitLooseComparisonSniff does not work for short-array syntax #2

Closed ondrejmirtes closed 6 years ago

ondrejmirtes commented 6 years ago

Hi, the DisallowImplicitLooseComparisonSniff does not detect this case:

if (in_array($str, ['a', 'b', 'c'])) {

}

Because something goes wrong when counting the nested parentheses inside AbstractFunctionCallSniff. I'm not able to fix this, mainly because these sniffs do not have any tests and I'm afraid I'd break something :(

aboks commented 6 years ago

This issue is now fixed in version 1.1.1. I also added some tests in the process.

Thanks for reporting this issue!