Skip to content

Commit

Permalink
fix(VariableComment): Allow intersection types in @var comment (#3392…
Browse files Browse the repository at this point in the history
…423)
  • Loading branch information
klausi authored Oct 15, 2023
1 parent c3f8e28 commit ba6e623
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
T_NULLABLE,
T_READONLY,
T_TYPE_UNION,
T_TYPE_INTERSECTION,
T_FALSE,
T_NULL,
];
Expand Down
12 changes: 12 additions & 0 deletions tests/Drupal/Commenting/VariableCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
12 changes: 12 additions & 0 deletions tests/Drupal/Commenting/VariableCommentUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

0 comments on commit ba6e623

Please sign in to comment.