diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index d2d53e2c3b..f7599c779b 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -30,16 +30,18 @@ public function processMemberVar(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); $ignore = [ - T_PUBLIC => T_PUBLIC, - T_PRIVATE => T_PRIVATE, - T_PROTECTED => T_PROTECTED, - T_VAR => T_VAR, - T_STATIC => T_STATIC, - T_READONLY => T_READONLY, - T_WHITESPACE => T_WHITESPACE, - T_STRING => T_STRING, - T_NS_SEPARATOR => T_NS_SEPARATOR, - T_NULLABLE => T_NULLABLE, + T_PUBLIC => T_PUBLIC, + T_PRIVATE => T_PRIVATE, + T_PROTECTED => T_PROTECTED, + T_VAR => T_VAR, + T_STATIC => T_STATIC, + T_READONLY => T_READONLY, + T_WHITESPACE => T_WHITESPACE, + T_STRING => T_STRING, + T_NS_SEPARATOR => T_NS_SEPARATOR, + T_NULLABLE => T_NULLABLE, + T_TYPE_UNION => T_TYPE_UNION, + T_TYPE_INTERSECTION => T_TYPE_INTERSECTION, ]; for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) { diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc index 36efc443bf..928022498a 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc @@ -402,3 +402,19 @@ class ReadOnlyProps private readonly string $variable; } + +class UnionTypes +{ + /** + * @var array|boolean + */ + private array|bool $variableName = array(); +} + +class IntersectionTypes +{ + /** + * @var \Iterator|\Countable + */ + private \Iterator&\Countable $variableName; +} diff --git a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed index 5c652f5402..2666c7c553 100644 --- a/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed +++ b/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed @@ -402,3 +402,19 @@ class ReadOnlyProps private readonly string $variable; } + +class UnionTypes +{ + /** + * @var array|boolean + */ + private array|bool $variableName = array(); +} + +class IntersectionTypes +{ + /** + * @var \Iterator|\Countable + */ + private \Iterator&\Countable $variableName; +}