Repository navigation
Blink: port 21 PSR2, PSR12 and PEAR PHP_CodeSniffer sniffs - #405
Merged
Merged
Conversation
…onClassDeclaration sniffs
…lassInstantiation and PSR12 Traits UseDeclaration sniffs
…atorPlacement and PEAR MultiLineCondition sniffs
…bjectOperatorIndent sniffs Adds a port of PHP_CodeSniffer's scope map (recurseScopeMap, the CASE/DEFAULT and arrow function fixes of processAdditional), findStartOfStatement and findEndOfStatement on the slvFile shim. It matches PHP_CodeSniffer's own scope_condition/opener/closer on every upstream test input but one short open tag file. The shim now also expands tabs in inline HTML and counts a fully qualified true/false/null at PHP_CodeSniffer's known length, as its tokenizer does.
…eader and PSR2 UseDeclaration sniffs phpcs-fixtures.sh now runs ECS once per input file: PHP_CodeSniffer's fixer keeps conflict state from file to file, so a multi-file run left some inputs half-fixed.
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports 21 more fixable PHP_CodeSniffer sniffs to blink. PHP_CodeSniffer coverage goes from 65/114 to 86/114.
Each matches ECS output byte for byte on the upstream PHPCS 4.0.4 test inputs (
TestPhpcsUpstreamFixtures).Shared changes:
phpcs_scope.go- port of PHPCS's scope map (scope owners,case/defaultshared closers, alternative syntax) plusfindStartOfStatement/findEndOfStatement; checked token for token against the PHPCS tokenizer. Also the base ScopeIndent needs.slevomat.go- brackets matched with one stack per type like PHPCS, tabs expanded in inline HTML,\true/\false/\nullcounted at their known length, interpolated string pieces marked. Slevomat ports still pass.phpcsClassyOpener- applies the PHPCS anonymous-class rule without a precedingnew.TestPhpcsUpstreamFixtures- a sniff withphpcsOnePass()is fixed only once, matching where ECS stops on the PSR2 ClassDeclaration extends/implements conflict.TestOperatorLinebreakKeepsNullFirstParenAssignmentruns every rule, so its expected output now has the multi-lineifclosing)on its own line (PSR12 ControlStructureSpacing).Known difference: PEAR FunctionCallSignature re-indents a heredoc closing marker like PHPCS does, which can produce invalid PHP. ECS writes it; blink's post-fix
php -lreverts the file.bin/phpcs-fixtures.shnow runs ECS once per input file - PHPCS's fixer carries conflict history across files in one ECS run, which left some inputs half-fixed. All existing fixtures regenerate byte-identical.Still left outside Squiz: Generic ScopeIndent.