Skip to content

Blink: port 15 Squiz PHP_CodeSniffer sniffs - #406

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

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

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fifth wave of PHP_CodeSniffer ports, Squiz only (the PSR2/PSR12/PEAR ones landed in #405). 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

  • WhiteSpace: ScopeKeywordSpacing, MemberVarSpacing, FunctionSpacing, OperatorSpacing, FunctionClosingBraceSpace
  • Classes: SelfMemberReference
  • ControlStructures: ForEachLoopDeclaration, ForLoopDeclaration, InlineIfDeclaration
  • Commenting: FileComment, InlineComment, LongConditionClosingComment, VariableComment
  • PHP / Strings: LowercasePHPFunctions, ConcatenationSpacing

Notes

  • LowercasePHPFunctions uses a committed list of PHP's built-in functions (php_builtin_functions.txt, from PHP 8.4 with bundled extensions; regenerate with bin/php-builtin-functions.sh). Upstream reads the running PHP, so functions from extra extensions can differ
  • OperatorSpacing copies PHP_CodeSniffer's rule that stops a pass when a fix would undo the previous one - an & right after a // comment never settles otherwise
  • FileComment fills a missing copyright year from the clock; the fixtures embed the generation year, so tests pin the clock (file_comment_clock_test.go)
  • Three slvFile helpers clashed by name with Blink: port 21 PSR2, PSR12 and PEAR PHP_CodeSniffer sniffs #405's and do different things, so this side renamed them (isScopeOrMethodModifier, isAnonClassKeyword, docBlockOpener)
  • TestOperatorLinebreakKeepsNullFirstParenAssignment runs every rule, so its expected output gains the blank lines FunctionSpacing and FunctionClosingBraceSpace add; the null-first assertion is unchanged

Not ported, still listed

PHP_CodeSniffer coverage: 86 -> 101 of 114, phpcs-not-ported.txt 28 -> 13.

Port ScopeKeywordSpacing, SelfMemberReference, MemberVarSpacing and
FunctionSpacing, held byte-exact to ECS on the upstream test files.

phpcs-fixtures.sh now runs ECS once per input: PHP_CodeSniffer's Fixer
keeps its conflict history across the files of one run, which changed
the ECS output of FunctionSpacingUnitTest.6.inc depending on its siblings.
…Declaration sniffs

The shared PHP_CodeSniffer operator context no longer reads a closure's
return type colon inside a ternary as the ternary's else.
FileComment, InlineComment, LongConditionClosingComment and VariableComment, with upstream fixtures matching ECS byte for byte.
FunctionClosingBraceSpace, LowercasePHPFunctions, ConcatenationSpacing and
InlineIfDeclaration, byte-exact against ECS on the upstream fixtures.
@TomasVotruba
TomasVotruba merged commit 21f1478 into main Nov 19, 2026
12 checks passed
@TomasVotruba
TomasVotruba deleted the blink-phpcs-sniffs-5 branch November 19, 2026 22:48
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