Repository navigation
Blink: port the fixable slevomat Namespaces sniffs - #410
Merged
Merged
Conversation
Ports AlphabeticallySortedUses, FullyQualifiedClassNameInAnnotation, FullyQualifiedExceptions, FullyQualifiedGlobalConstants, FullyQualifiedGlobalFunctions, NamespaceDeclaration, NamespaceSpacing, ReferenceUsedNamesOnly, UnusedUses, UseDoesNotStartWithBackslash, UseFromSameNamespace, UseSpacing and UselessAlias, with ports of ReferencedNameHelper and the phpdoc-parser annotation layer they share. The shim gives up on a file whose fixes never settle after 100 loops and keeps it unchanged, like ECS, and true/false/null followed by ( or :: are names, like in PHP_CodeSniffer's tokenizer.
TomasVotruba
force-pushed
the
blink-slevomat-namespaces
branch
from
November 19, 2026 23:36
cacf580 to
6088e55
Compare
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 13 fixable sniffs of slevomat's Namespaces category to blink, following #402 (PHP).
psr12Compatible,caseSensitiveignoredAnnotationNamesspecialExceptionNames,ignoredNamesinclude,excludeinclude,exclude,includeSpecialFunctionslinesCountBeforeNamespace,linesCountAfterNamespacesearchAnnotations,ignoredAnnotationNames,ignoredAnnotationslinesCountBeforeFirstUse,linesCountBetweenUseTypes,linesCountAfterLastUseShared layers
slevomat_referenced_names.go- port of ReferencedNameHelper (class, function and constant references, in code, strings and attributes).slevomat_phpdoc.go- port of phpstan/phpdoc-parser 2.4.1 (lexer, tag, type and const-expr parsers, format-preserving printer for node swaps) plus AnnotationHelper. Checked against the real parser on 25k docblocks from Laravel, slevomat's tests and generated input: same tags, nodes, spans and printed output.defined()/function_exists()upstream) uses embedded lists for the bundled extensions, so a name from an optional extension like curl counts as undefined in blink.Tests
p1/p2variants..fixed.phpdiffers from ECS: 3 tests restrict the sniff to some error codes (ECS always runs all of it), and ECS fixes only one annotation per docblock per pass (each fix rewrites the whole docblock from the parse taken at the start of the pass) and stops when a pass makes no change, where phpcbf keeps going."unstable": true, which skips the stability check. Blink's second run equals ECS's second run on each.Shim
slvRungives up after 100 loops (ECS'sMAX_FIXER_LOOPS) and keeps the file unchanged, like ECS. It used to stop at 50 and keep the last output.true/false/nullfollowed by(or::are names, and\true/\false/\null/\exit/\dieare not, as in PHP_CodeSniffer's tokenizer. Arrays, Functions, Operators, Attributes and PHP were re-checked against ECS with both changes, with no difference.Parity with ECS
Every sniff was run by ECS and by blink on Laravel
src, clean and with mutations targeting it (shuffled, aliased, group, function and const uses, blank lines around namespaces and uses, fully qualified names in code and docblocks, colliding names, partial uses, files without namespace, annotations of every tag shape), with default and non-default configs. Output is byte-identical everywhere. The only exception isReferenceUsedNamesOnlywith fallback global functions/constants disallowed, where ECS also imports functions from the extensions loaded on the machine running it.