Skip to content

Blink: port the fixable slevomat Exceptions, Numbers, Variables and Whitespaces sniffs - #414

Merged
TomasVotruba merged 1 commit into
mainfrom
blink-slevomat-small
Nov 20, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
blink-slevomat-small

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Ports the fixable sniffs of four small slevomat categories to blink, following #410 (Namespaces).

Sniff Config
Exceptions\CatchExceptionsOrder caseSensitive
Exceptions\ReferenceThrowableOnly -
Exceptions\RequireNonCapturingCatch enable
Numbers\DisallowNumericLiteralSeparator -
Variables\UselessVariable -
Whitespaces\DuplicateSpaces ignoreSpacesBeforeAssignment, ignoreSpacesInAnnotation, ignoreSpacesInComment, ignoreSpacesInParameters, ignoreSpacesInMatch

Tests

  • 29 new golden cases from the upstream fixtures, generated by ECS, checked byte-exact with a stability check.
  • ReferenceThrowableOnly's exceptionReferences* fixtures have goldens although upstream has no .fixed.php: upstream only asserts the reported errors, ECS fixes them.

Parity with ECS

Every sniff (all DuplicateSpaces configs, CatchExceptionsOrder caseSensitive) was run by ECS and by blink on Laravel src, clean and with mutations targeting it: shuffled multi-catches, unused / later-used / closure-captured / interpolated catch variables, \Exception in parameters, unions and returns, @phpcsSuppress, numeric separators in every literal form, $x = ...; return $x; templates, doubled spaces and mid-line tabs in code, comments, docblocks, strings and heredocs.

Output is byte-identical everywhere except files where upstream produces invalid PHP, which blink's lint guard reverts:

  • ReferenceThrowableOnly writes duplicate unions like \Throwable|\Throwable (8 mutated files).
  • UselessVariable turns $x = &$y; return $x; into return &$y; (one mutation template).

Without the lint guard blink's output equals ECS on those files too.

…hitespaces sniffs

Ports CatchExceptionsOrder, ReferenceThrowableOnly, RequireNonCapturingCatch,
DisallowNumericLiteralSeparator, UselessVariable and DuplicateSpaces, verified
on golden outputs generated by ECS from the upstream test fixtures.
@TomasVotruba
TomasVotruba merged commit 669411d into main Nov 20, 2026
12 checks passed
@TomasVotruba
TomasVotruba deleted the blink-slevomat-small branch November 20, 2026 10:17
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