diff --git a/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php b/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php index 8b5a04dc1619c76b90a821dde868b15dc0700c1e..1b6a3fcf7b42f961543c9be65484a62e2120ab1f 100644 --- a/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php +++ b/coder_sniffer/Drupal/Sniffs/Commenting/VariableCommentSniff.php @@ -50,6 +50,7 @@ class VariableCommentSniff extends AbstractVariableSniff T_NULLABLE, T_READONLY, T_TYPE_UNION, + T_TYPE_INTERSECTION, T_FALSE, T_NULL, ]; diff --git a/tests/Drupal/Commenting/VariableCommentUnitTest.inc b/tests/Drupal/Commenting/VariableCommentUnitTest.inc index 5e6358f60b7cad18a5c7253aaf4ce8f585ef650d..bfb78f30d7ba08f7c9feb4cc0fc5b27a77039f21 100644 --- a/tests/Drupal/Commenting/VariableCommentUnitTest.inc +++ b/tests/Drupal/Commenting/VariableCommentUnitTest.inc @@ -84,4 +84,16 @@ class Test { */ protected string $constant; + /** + * Intersection type support, it is allowed to repeat it in the var type. + * + * @var \Drupal\user\UserStorageInterface&\PHPUnit\Framework\MockObject\MockObject + */ + protected UserStorageInterface&MockObject $userStorageMock; + + /** + * It is also allowed to leave the var comment out since there is a type. + */ + protected UserStorageInterface&MockObject $userStorageMock2; + } diff --git a/tests/Drupal/Commenting/VariableCommentUnitTest.inc.fixed b/tests/Drupal/Commenting/VariableCommentUnitTest.inc.fixed index a8876df13a49f657d52f36aa16a76beef5db2c60..25ed52c592f603836341df6874751983a16c5065 100644 --- a/tests/Drupal/Commenting/VariableCommentUnitTest.inc.fixed +++ b/tests/Drupal/Commenting/VariableCommentUnitTest.inc.fixed @@ -88,4 +88,16 @@ class Test { */ protected string $constant; + /** + * Intersection type support, it is allowed to repeat it in the var type. + * + * @var \Drupal\user\UserStorageInterface&\PHPUnit\Framework\MockObject\MockObject + */ + protected UserStorageInterface&MockObject $userStorageMock; + + /** + * It is also allowed to leave the var comment out since there is a type. + */ + protected UserStorageInterface&MockObject $userStorageMock2; + }