Skip to content

Commit 60c95d8

Browse files
committed
Squiz/VariableComment: allow for various other missing types
There were some more allowed types missing from the list of tokens to skip over to find a docblock. Fixed now. Includes unit tests.
1 parent 7ffcbb5 commit 60c95d8

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php

+3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ public function processMemberVar(File $phpcsFile, $stackPtr)
3939
T_WHITESPACE => T_WHITESPACE,
4040
T_STRING => T_STRING,
4141
T_NS_SEPARATOR => T_NS_SEPARATOR,
42+
T_NAMESPACE => T_NAMESPACE,
4243
T_NULLABLE => T_NULLABLE,
4344
T_TYPE_UNION => T_TYPE_UNION,
4445
T_TYPE_INTERSECTION => T_TYPE_INTERSECTION,
4546
T_NULL => T_NULL,
4647
T_TRUE => T_TRUE,
4748
T_FALSE => T_FALSE,
49+
T_SELF => T_SELF,
50+
T_PARENT => T_PARENT,
4851
];
4952

5053
for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) {

src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc

+18
Original file line numberDiff line numberDiff line change
@@ -436,3 +436,21 @@ class StandaloneNullTrueFalseTypes
436436
*/
437437
private false $variableName = false;
438438
}
439+
440+
class MoreMissingButSupportedTypes
441+
{
442+
/**
443+
* @var parent
444+
*/
445+
public parent $variableName;
446+
447+
/**
448+
* @var self
449+
*/
450+
protected self $variableName;
451+
452+
/**
453+
* @var SomeClass
454+
*/
455+
private namespace\SomeClass $variableName;
456+
}

src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed

+18
Original file line numberDiff line numberDiff line change
@@ -436,3 +436,21 @@ class StandaloneNullTrueFalseTypes
436436
*/
437437
private false $variableName = false;
438438
}
439+
440+
class MoreMissingButSupportedTypes
441+
{
442+
/**
443+
* @var parent
444+
*/
445+
public parent $variableName;
446+
447+
/**
448+
* @var self
449+
*/
450+
protected self $variableName;
451+
452+
/**
453+
* @var SomeClass
454+
*/
455+
private namespace\SomeClass $variableName;
456+
}

0 commit comments

Comments
 (0)