Skip to content

feat: add PHP_CodeSniffer 4.x support#724

Open
MickaelN wants to merge 1 commit into
nunomaduro:masterfrom
MickaelN:feat/phpcs-4-support
Open

feat: add PHP_CodeSniffer 4.x support#724
MickaelN wants to merge 1 commit into
nunomaduro:masterfrom
MickaelN:feat/phpcs-4-support

Conversation

@MickaelN
Copy link
Copy Markdown

Summary

Upgrades squizlabs/php_codesniffer from ^3.13.5 to ^4.0 and slevomat/coding-standard from ^8.22.1 to ^8.23.

Closes #723

Changes

Core:

  • File.php: typed addMessage() signature, fixableCount replaced by fixableErrorCount/fixableWarningCount
  • SniffDecorator.php: typed process() parameter
  • ForbiddenSetterSniff.php: typed process() parameter, dotted error code to comply with PHPCS 4 naming validation, getDeclarationName empty string check

Removed sniffs (dropped in PHPCS 4):

  • Zend\Debug\CodeAnalyzerSniff — removed without replacement (redundant with SyntaxCheck which uses parallel-lint)
  • Generic\Functions\CallTimePassByReferenceSniff — removed without replacement (call-time pass-by-reference is a syntax error since PHP 5.4, irrelevant for PHP 8.3+)

Moved sniff:

  • Squiz\WhiteSpace\LanguageConstructSpacingSniffGeneric\WhiteSpace\LanguageConstructSpacingSniff

Tests:

  • TestCase::prepareFixtureWithSniff(): manual sniff registration to bypass PHPCS 4 namespace convention validation in populateTokenListeners() for custom sniffs outside the Standard\Sniffs\Category namespace

Verification

  • 100 tests pass (0 failures, 0 errors)
  • Self-analysis produces scores
  • Tested on a large Symfony project (~1900 files): scores are consistent with PHPCS 3 baseline (Code, Complexity and Architecture identical, Style within 1.2 pts)

Upgrade squizlabs/php_codesniffer from ^3.13.5 to ^4.0 and
slevomat/coding-standard from ^8.22.1 to ^8.23.

Changes:
- File.php: typed addMessage() signature, fixableCount replaced by
  fixableErrorCount/fixableWarningCount
- SniffDecorator.php: typed process() parameter
- ForbiddenSetterSniff.php: typed process() parameter, dotted error
  code to comply with PHPCS 4 naming validation, getDeclarationName
  empty string check
- Metrics: removed CodeAnalyzerSniff (dropped from Zend in PHPCS 4,
  redundant with SyntaxCheck), removed CallTimePassByReferenceSniff
  (dropped, irrelevant since PHP 5.4), moved LanguageConstructSpacingSniff
  from Squiz to Generic namespace
- TestCase: manual sniff registration to bypass PHPCS 4 namespace
  convention validation for custom sniffs

Closes nunomaduro#723
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow "squizlabs/php_codesniffer": "^4"

2 participants