slevomat / coding-standard

Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs
MIT License
1.39k stars 171 forks source link

Issues when 7.2.1 is used with squizlabs/PHP_CodeSniffer 3.7 #1381

Closed janedbal closed 2 years ago

janedbal commented 2 years ago

Hi, I assume there will be some official support in upcoming days/weeks, I just want to point out issues I found when analysing our codebase with slevomat/cs 7.2.1 and squizlabs/PHP_CodeSniffer 3.7.0:

  1. function named empty causing internal server error in FunctionHelper
  2. enum case named True (or False) is identified as constant by SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFallbackGlobalName
  3. enum case named Isset causing internal server error An error occurred during processing; checking has been aborted. The error message was: Undefined array key "parenthesis_closer" in RequireNullCoalesceOperatorSniff.php:69
kukulich commented 2 years ago

Function empty looks like invalid PHP: https://3v4l.org/sQXtT

janedbal commented 2 years ago

I oversimplified the case. It was a class method, which is allowed: https://3v4l.org/er5bV

kukulich commented 2 years ago
  1. There's no array access in FunctionHelper on line 92, so it looks like outdated Slevomat CS. I've checked branches 7.2 and master. Please try master.
  2. I'm not able to reproduce it in master now. Please try master.
  3. It's bug of PHPCS itself. The enum case name is tokenized as T_ISSET and that's wrong.
kukulich commented 2 years ago

empty and isset are probably fixed in PHPCS itself: https://github.com/squizlabs/PHP_CodeSniffer/pull/3610

jrfnl commented 2 years ago

Yes, the fix is included in the PHPCS 3.7.1 release. Upgrading to that should solve the problem.

janedbal commented 2 years ago

Seems like

"slevomat/coding-standard": "dev-master",
"squizlabs/php_codesniffer": "3.7.1",

works fine. Thank you!

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.