Skip to content

Commit

Permalink
Squiz/VariableComment: allow for various other missing types
Browse files Browse the repository at this point in the history
There were some more allowed types missing from the list of tokens to skip over to find a docblock.

Fixed now.

Includes unit tests.
  • Loading branch information
jrfnl committed Jan 10, 2024
1 parent 7725dec commit b04f0a6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
T_WHITESPACE => T_WHITESPACE,
T_STRING => T_STRING,
T_NS_SEPARATOR => T_NS_SEPARATOR,
T_NAMESPACE => T_NAMESPACE,
T_NULLABLE => T_NULLABLE,
T_TYPE_UNION => T_TYPE_UNION,
T_TYPE_INTERSECTION => T_TYPE_INTERSECTION,
T_NULL => T_NULL,
T_TRUE => T_TRUE,
T_FALSE => T_FALSE,
T_SELF => T_SELF,
T_PARENT => T_PARENT,
];

for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) {
Expand Down
18 changes: 18 additions & 0 deletions src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,21 @@ class StandaloneNullTrueFalseTypes
*/
private false $variableName = false;
}

class MoreMissingButSupportedTypes
{
/**
* @var parent
*/
public parent $variableName;

/**
* @var self
*/
protected self $variableName;

/**
* @var SomeClass
*/
private namespace\SomeClass $variableName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,21 @@ class StandaloneNullTrueFalseTypes
*/
private false $variableName = false;
}

class MoreMissingButSupportedTypes
{
/**
* @var parent
*/
public parent $variableName;

/**
* @var self
*/
protected self $variableName;

/**
* @var SomeClass
*/
private namespace\SomeClass $variableName;
}

0 comments on commit b04f0a6

Please sign in to comment.