Fix Class Property DocBlock sniff for union/intersection types #483
+29
−12
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.
Since PHP_CodeSniffer 3.7.0, there's a separate token
T_TYPE_INTERSECTION
for the&
type-intersection specifier, instead of using the sameT_BITWISE_AND
token for both type intersections and the bitwise operator. Due to this, theMagento2.Commenting.ClassPropertyPHPDocFormatting
sniff fails to detect the DocBlock for intersection-typed properties in projects that use newer versions.Also, since PHP 8.2 added support for DNF types, two new tokens were added to PHP_CodeSniffer in 3.10.0 for the parentheses.
This PR proposes pinning the minimum PHP_CodeSniffer version to
^3.10.0
in order to fully support the newer DNF types, while also fixing the sniff's allowed tokens to correctly detect DocBlocks for intersection-typed properties.