Skip to content

Blink: port the fixable slevomat TypeHints sniffs - #417

Merged
TomasVotruba merged 2 commits into
mainfrom
blink-slevomat-typehints
Nov 20, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
blink-slevomat-typehints

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Ports all 15 fixable slevomat TypeHints sniffs to blink, following #414. Slevomat coverage goes from 77 to 92 of 132.

Sniff Config
TypeHints\ClassConstantTypeHint enableNativeTypeHint, fixableNativeTypeHint
TypeHints\DNFTypeHintFormat enable, enableForDocComments, nullPosition, shortNullable, withSpacesAroundOperators, withSpacesInsideParentheses
TypeHints\DeclareStrictTypes declareOnFirstLine, linesCountAfterDeclare, linesCountBeforeDeclare, spacesCountAroundEqualsSign
TypeHints\DisallowArrayTypeHintSyntax traversableTypeHints
TypeHints\LongTypeHints -
TypeHints\NullTypeHintOnLastPosition -
TypeHints\NullableTypeForNullDefaultValue -
TypeHints\ParameterTypeHint enable*TypeHint, traversableTypeHints
TypeHints\ParameterTypeHintSpacing -
TypeHints\PropertyTypeHint enable*TypeHint, traversableTypeHints
TypeHints\RequireTrailingCommaInArrayShape -
TypeHints\ReturnTypeHint enable*TypeHint, traversableTypeHints
TypeHints\ReturnTypeHintSpacing spacesCountBeforeColon
TypeHints\UnionTypeHintFormat enable, nullPosition, shortNullable, withSpaces
TypeHints\UselessConstantTypeHint -

Code is split in three files:

  • slevomat_typehints_native.go - sniffs working on native type tokens (spacing, formats, declare, constants).
  • slevomat_typehints_phpdoc.go - sniffs rewriting phpdoc types.
  • slevomat_typehints_declared.go - Parameter/Property/ReturnTypeHint, incl. useless annotation and @phpcsSuppress removal.

slevomat_phpdoc.go drops two unused helpers and gets a tagged switch for lint.

Tests

  • 152 new golden cases from the upstream fixtures, generated by ECS, checked byte-exact with a stability check.

Parity with ECS

Diffs were rechecked by a single-file ECS run.

  • NullTypeHintOnLastPosition, LongTypeHints, ReturnTypeHintsWithAnnotations, DisallowArrayTypeHintSyntax (incl. traversableTypeHints): 0 diffs on Laravel src, clean and on 1,744 mutated files.
  • Parameter/Property/ReturnTypeHint: 0 diffs on Laravel src, on 226 Laravel files with types stripped, and on edge-case files under 11 configs.
  • Excluded are 65 files where upstream itself writes invalid PHP (10 Parameter, 1 Property, 54 Return), e.g. void added to a function with return; or to a generator. blink's lint guard leaves those unchanged, as in the other ports.

@TomasVotruba
TomasVotruba merged commit d8db998 into main Nov 20, 2026
12 checks passed
@TomasVotruba
TomasVotruba deleted the blink-slevomat-typehints branch November 20, 2026 16:40
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