Skip to content

Blink: port all 89 report-only PHP_CodeSniffer sniffs - #411

Merged
TomasVotruba merged 12 commits into
mainfrom
blink-phpcs-report-sniffs
Nov 20, 2026
Merged

TomasVotruba merged 12 commits into
mainfrom
blink-phpcs-report-sniffs

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Blink now covers every PHP_CodeSniffer sniff, not only the fixable ones: 203 of 203.

Measurement

  • The universe lists every PHPCS sniff (cmd/list-universe/phpcs_sniffs.txt, regenerated by bin/phpcs-sniffs.sh, was phpcs-fixable-sniffs.sh), so a missing report-only sniff fails CI like a missing fixer
  • bin/phpcs-fixtures.sh also stores the errors ECS reports on each upstream test file as <input>.errors (line<TAB>source<TAB>message)
  • New TestPhpcsUpstreamErrors: every blink rule implementing ErrorReporter must report exactly those rows - same line, code and message

Ported (89)

  • Generic: CodeAnalysis (10), Files/Commenting/Classes/ControlStructures/Strings (14), PHP (10), Metrics, NamingConventions, VersionControl
  • PEAR: comments, naming, ControlSignature, MultiLineAssignment, ValidDefaultValue, ScopeIndent
  • PSR1/PSR2/PSR12: ClassDeclaration, CamelCapsMethodName, SideEffects, FunctionCallSignature, ClosingBrace, CompoundNamespaceDepth, ConstantVisibility
  • Squiz: Operators, PHP Disallow*/CommentedOutCode/NonExecutableCode, Scope, naming, comments, Classes, Files, Functions, Objects
  • Zend: ValidVariableName

Shared ports of the PHPCS base classes: abstract_scope.go (AbstractScopeSniff), abstract_variable.go (AbstractVariableSniff), abstract_pattern.go (AbstractPatternSniff).

Behaviour notes

  • ECS drops warnings except for the sniffs in SniffFileProcessor::ESCALATE_WARNINGS_SNIFF, so warning-only sniffs (e.g. DuplicateClassName, JumbledIncrementer, NonExecutableCode, SideEffects, ConstantVisibility, GlobalFunction) report nothing in blink either
  • Sniffs inheriting fixes reuse the existing fixers: PEAR ScopeIndent (Generic ScopeIndent with SwitchNotIndented), PSR2 FunctionCallSignature (PEAR port with PSR2's multi-line test), Deprecated/DiscouragedFunctions (ForbiddenFunctions)
  • Generic Syntax runs php -l from PATH like the sniff; without php it reports nothing and its fixtures are skipped (Windows CI)
  • ExecutableFile depends on file permissions (the umask of the checkout), so it has its own test instead of the upstream fixture
  • DeprecatedFunctions uses a committed list from PHP 8.4 (php_deprecated_functions.txt, via bin/php-builtin-functions.sh); upstream reads the running PHP
  • CommentedOutCode re-tokenizes comment text with blink's lexer plus PHPCS's retokenization rules - matched all 174 errors on two vendor corpora, rare constructs may still differ
  • Each sniff was also checked with bin/ecs vs bin/ecs --blink on extra edge-case files; identical errors
  • Known gap outside the sniffs: blink's file finder only picks *.php, so Squiz FileExtension's .inc error shows in ECS but not with --blink

@TomasVotruba
TomasVotruba merged commit 650848a into main Nov 20, 2026
12 checks passed
@TomasVotruba
TomasVotruba deleted the blink-phpcs-report-sniffs branch November 20, 2026 09:28
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.

1 participant