magento-coding-standard icon indicating copy to clipboard operation
magento-coding-standard copied to clipboard

Fix Class Property DocBlock sniff for union/intersection types

Open CRC-Mismatch opened this issue 1 year ago • 1 comments

Since PHP_CodeSniffer 3.7.0, there's a separate token T_TYPE_INTERSECTION for the & type-intersection specifier, instead of using the same T_BITWISE_AND token for both type intersections and the bitwise operator. Due to this, the Magento2.Commenting.ClassPropertyPHPDocFormatting sniff fails to detect the DocBlock for intersection-typed properties in projects that use newer versions.

image

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.

CRC-Mismatch avatar Jul 31 '24 12:07 CRC-Mismatch

@ihor-sviziev any chance of merging this? The problem literally prevents some developers from using the supported PHP versions' typing system to its full extent, forcing us to fall back to PhpDocs and redundant conditionals if we need to pass CI tests...

CRC-Mismatch avatar Sep 18 '24 20:09 CRC-Mismatch

Nevermind, let's forgo supported versions and leave the developers to their own devices...

CRC-Mismatch avatar Feb 28 '25 21:02 CRC-Mismatch

@sidolov @engcom-Hotel any chanse we can merge it?

ihor-sviziev avatar Mar 01 '25 15:03 ihor-sviziev

@ihor-sviziev @sidolov if there's any chance to merge for a new release, I'd be glad to hear from you if there's anything that should be changed, reopen the PR and work on it again, since it was opened over 8 months ago and by now there could be some conflicts...

CRC-Mismatch avatar Mar 03 '25 18:03 CRC-Mismatch