Skip to content

Blink: port 12 more PHP_CodeSniffer sniffs - #404

Merged
TomasVotruba merged 4 commits into
mainfrom
blink-phpcs-sniffs-4
Nov 19, 2026
Merged

TomasVotruba merged 4 commits into
mainfrom
blink-phpcs-sniffs-4

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fourth wave of PHP_CodeSniffer ports. Every sniff passes PHP_CodeSniffer's own test files byte-exact against ECS output (TestPhpcsUpstreamFixtures), and extra edge cases were run through bin/ecs vs bin/ecs --blink with identical output.

New sniffs

  • Generic.PHP.RequireStrictTypes, Generic.Strings.UnnecessaryHeredoc - deliberate no-ops: their only fixes are addFixableWarning, which ECS drops
  • Generic.Files.LineEndings (configurable eolChar), Squiz.Strings.DoubleQuoteUsage
  • PSR12.Functions.ReturnTypeDeclaration (Go type ReturnTypeDeclarationSniff), PSR12.Operators.OperatorSpacing, Squiz.WhiteSpace.ObjectOperatorSpacing, Generic.WhiteSpace.SpreadOperatorSpacingAfter
  • Squiz.Commenting.PostStatementComment, Squiz.Commenting.ClosingDeclarationComment, Squiz.Commenting.DocCommentAlignment
  • PSR12.Classes.ClassInstantiation

Shared helpers

  • phpcs_operator.go: PHPCS operator classification, union/intersection/DNF type detection and File::isReference (simplified) - ready for Squiz.WhiteSpace.OperatorSpacing
  • isPhpcsAnnotationComment: PHPCS tokenizes phpcs:* comments specially even with annotations off, comment sniffs skip them

Not ported, still listed

  • Squiz.WhiteSpace.ScopeClosingBrace - needs PHPCS's full scope map (case/default sharing closers, alternative syntax), better done once as shared infrastructure for ScopeIndent and ControlSignature too
  • Squiz.WhiteSpace.OperatorSpacing - spacing rules not ported yet

Notes

  • ClosingDeclarationComment replaces the rest of the line after } like ECS does (} foo(); -> }//end x()), so TestOperatorLinebreakKeepsNullFirstParenAssignment (runs all rules) now expects the //end comment

PHP_CodeSniffer coverage: 54 -> 66 of 114, phpcs-not-ported.txt 60 -> 48.

@TomasVotruba
TomasVotruba merged commit eecf233 into main Nov 19, 2026
12 checks passed
@TomasVotruba
TomasVotruba deleted the blink-phpcs-sniffs-4 branch November 19, 2026 21:16
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