Fix conflict between TypeHintSniff and Slevomat null position sniffs#427
Merged
dereuromark merged 2 commits into6.xfrom Mar 14, 2026
Merged
Fix conflict between TypeHintSniff and Slevomat null position sniffs#427dereuromark merged 2 commits into6.xfrom
dereuromark merged 2 commits into6.xfrom
Conversation
… sniffs Remove `NullTypeHintOnLastPosition` sniff and `nullPosition` property from `DNFTypeHintFormat` to avoid conflict with CakePHP's `TypeHintSniff` which expects `void` to be last in union types (e.g., `int|null|void`). The Slevomat sniffs enforced `null` as last position, causing an unresolvable conflict where PHPCBF would fail to fix files containing both `null` and `void` in union types. Fixes #426
Member
|
Would usage like |
Member
Author
|
Yes, CakePHP's own The existing test files confirm this behavior:
The removed Slevomat sniffs were redundant (and conflicting when |
ADmad
approved these changes
Mar 14, 2026
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.
Summary
NullTypeHintOnLastPositionsniff from rulesetnullPosition="last"property fromDNFTypeHintFormatsniffThis fixes the conflict where CakePHP's
TypeHintSniffexpectsvoidto be last in union types (e.g.,int|null|void), but Slevomat sniffs enforcednullas last position (expectingint|void|null).The conflict caused PHPCBF to fail when trying to fix files containing both
nullandvoidin union types, as both sniffs would fight each other.This follows the same approach as php-collective/code-sniffer which also doesn't use these Slevomat sniffs.
Fixes #426