Repository navigation
Blink: port the fixable slevomat PHP sniffs - #402
Merged
Merged
Conversation
Ports DisallowDirectMagicInvokeCall, ForbiddenClasses, ReferenceSpacing,
RequireExplicitAssertion, RequireNowdoc, ShortList, TypeCast,
UselessParentheses and UselessSemicolon, verified on golden outputs generated
by ECS from the upstream test fixtures.
The shim's braceOwner no longer reaches past a closed block, an object
operator or an assignment, so $this->{$x} is not taken for a scope, and it
gains PHP_CodeSniffer's scope_condition for trait use blocks.
TomasVotruba
force-pushed
the
blink-slevomat-php
branch
from
November 19, 2026 21:18
d27640a to
a8f8cc5
Compare
TomasVotruba
enabled auto-merge (squash)
November 19, 2026 21:18
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 the 9 fixable sniffs of slevomat's PHP category to blink, following #400 (Attributes).
forbiddenClasses,forbiddenExtends,forbiddenInterfaces,forbiddenTraitsspacesCountAfterReferenceenableIntegerRanges,enableAdvancedStringTypesignoreComplexTernaryConditions,enableCheckAroundNewTests
.fixed.php.forbiddenClasses.configured,uselessParenthesesCheckAroundNewErrors.enabled/disabled).Shim
braceOwnerno longer reaches past a closed block,->,::,=or a variable. Before, the{of$this->{$x}was taken for the scope of an earlierif. Arrays, Functions, Operators and Attributes were re-checked against ECS with this change, with no difference.scopeConditionadds PHP_CodeSniffer'sscope_conditionfor trait use blocks (use T { ... }), used by UselessSemicolon and ForbiddenClasses.$this,int<a, b>, flat unions and intersections, parentheses); anything else is skipped, as upstream does when it cannot build an assertion.Parity with ECS
Every sniff (non-default configs too) was run by ECS and by blink on Laravel
src, clean and with mutations targeting it (->__invoke(,& $x,list(...), long cast names, doubled;;,};, heredocs from nowdocs, added parentheses,@varannotations of many shapes, forbidden classes, traits and interfaces). Output is byte-identical everywhere, except files where upstream produces invalid PHP, which blink's lint guard reverts: RequireNowdoc (1), UselessParentheses withenableCheckAroundNew(2,new ($expr)->x), RequireExplicitAssertion (1, an\assertin a class body). Without the lint guard blink's output equals ECS there too.ECS aborts a file when RequireExplicitAssertion meets an annotated constructor parameter with a default value (upstream
TypeError); blink leaves such a file unchanged the same way.