Skip to content

Blink: port 8 misc PHP-CS-Fixer fixers (Strict, Alias, Basic, Attribute, Namespace) - #286

Merged
TomasVotruba merged 2 commits into
mainfrom
blink-port-misc
Nov 4, 2026
Merged

TomasVotruba merged 2 commits into
mainfrom
blink-port-misc

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Ports a batch of the "misc" PHP-CS-Fixer fixers to blink, each reimplemented faithfully from upstream with parity tests mirroring the upstream fixer test cases. Registered in the registry/All() only (no config/set/ changes). README rule counts and priorities updated; cmd/check-sources confirms every new SourceURL() resolves.

Landed (8)

Fixer Notes
Strict/StrictComparisonFixer == -> ===, != and <> -> !== (risky)
Strict/StrictParamFixer fills $strict for in_array, array_search, array_keys, base64_decode, mb_detect_encoding; global calls only; stops when an earlier required arg is missing
Alias/MbStrFunctionsFixer base mb_* mappings with per-function arg-count gating; renames global calls and use function imports. Version-gated additions (mb_str_pad, mb_trim, ...) intentionally omitted - see below
Alias/RandomApiMigrationFixer v3 defaults (rand->mt_rand, srand->mt_srand, getrandmax->mt_getrandmax); configurable replacements, incl. random_int zero-arg 0, getrandmax() insertion
Basic/OctalNotationFixer 0755 -> 0o755
Basic/NumericLiteralSeparatorFixer digit grouping (bin/hex/octal/decimal/float/exponent); configurable strategy + override_existing
NamespaceNotation/NoBlankLinesBeforeNamespaceFixer the deprecated proxy for blank_lines_before_namespace with min 0 / max 1 line breaks
AttributeNotation/AttributeEmptyParenthesesFixer removes/adds empty () on attributes; configurable use_parentheses

Note on MbStrFunctionsFixer: only the always-present base map is ported. The PHP-version-gated additions (str_pad on 8.3+, trim/ltrim/rtrim on 8.4+, each behind a runtime function_exists reflection check) are omitted so behaviour is deterministic and matches the version-independent upstream test cases; this is conservative for a risky fixer that is not part of any prepared set.

Skipped (with reasons)

  • AttributeNotation/OrderedAttributesFixer - requires reordering attribute token ranges plus full FQN resolution for the sort order; high divergence risk against blink's token model.
  • ClassUsage/DateTimeImmutableFixer - broad semantic rewrite (class references, method and function name mappings); not portable with parity confidence.
  • Import/GroupImportFixer - multi-statement import grouping/sorting; complex, high risk.
  • Comment/CommentToPhpdocFixer - structural comment analysis with ignored_tags; complex.
  • Comment/HeaderCommentFixer - only meaningful once configured (header text, comment_type, location, separate); default is a no-op and faithful configured behaviour is not portable with confidence.
  • Squiz WhiteSpace/SuperfluousWhitespaceSniff - relies on PHP_CodeSniffer's per-line whitespace tokenization and hasCondition(T_FUNCTION/T_CLOSURE) scope tracking for the "multiple empty lines in a function" check; faithful parity not confident.
  • Spacing/MethodChainingNewlineFixer (Symplify) - deprecated; depends on several ChainMethodCallAnalyzer heuristics and BlockFinder, so faithful parity is high-risk.
  • Spacing/StandaloneLineConstructorParamFixer (Symplify) - the pre-split umbrella fixer; its behaviour is already covered by blink's StandaloneLinePlainConstructorParam, StandaloneLineRequiredParam and StandaloneLineSymfonyAttributeParam.

Gates

go build, go vet, go test -race, gofmt -s, go fix, gopls modernize, golangci-lint v2, check-sources, and rule-counts.sh --check all pass locally.

@TomasVotruba
TomasVotruba force-pushed the blink-port-misc branch 2 times, most recently from 391a365 to a48bb7f Compare November 4, 2026 17:20
…te, Namespace)

Adds faithful Go ports with parity tests mirroring upstream cases:

- Strict/StrictComparisonFixer (== -> ===, != and <> -> !==)
- Strict/StrictParamFixer ($strict arg for in_array, array_search, array_keys, base64_decode, mb_detect_encoding)
- Alias/MbStrFunctionsFixer (base mb_* mappings; global calls and use-function imports)
- Alias/RandomApiMigrationFixer (v3 defaults; configurable, random_int insertion)
- Basic/OctalNotationFixer (0755 -> 0o755)
- Basic/NumericLiteralSeparatorFixer (digit grouping; configurable)
- NamespaceNotation/NoBlankLinesBeforeNamespaceFixer
- AttributeNotation/AttributeEmptyParenthesesFixer (configurable)

Registered in registry/All() only, with priorities and README rule counts updated.
@TomasVotruba

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

@TomasVotruba
TomasVotruba merged commit def72b9 into main Nov 4, 2026
20 of 21 checks passed
@TomasVotruba
TomasVotruba deleted the blink-port-misc branch November 4, 2026 17:40
Copilot stopped work on behalf of TomasVotruba due to an error November 4, 2026 17:54
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