Skip to content

Commit cbb5548

Browse files
authored
Merge pull request #211 from PHPCSStandards/feature/squiz-variablecomment-allow-for-more-missing-types
PHP 8.2 | Squiz/VariableComment: allow for stand-alone null/true/false types and more
2 parents dc0ac49 + b04f0a6 commit cbb5548

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -39,9 +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,
46+
T_NULL => T_NULL,
47+
T_TRUE => T_TRUE,
48+
T_FALSE => T_FALSE,
49+
T_SELF => T_SELF,
50+
T_PARENT => T_PARENT,
4551
];
4652

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

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

+36
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,39 @@ class IntersectionTypes
418418
*/
419419
private \Iterator&\Countable $variableName;
420420
}
421+
422+
class StandaloneNullTrueFalseTypes
423+
{
424+
/**
425+
* @var null
426+
*/
427+
public null $variableName = null;
428+
429+
/**
430+
* @var true
431+
*/
432+
protected true $variableName = true;
433+
434+
/**
435+
* @var false
436+
*/
437+
private false $variableName = false;
438+
}
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

+36
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,39 @@ class IntersectionTypes
418418
*/
419419
private \Iterator&\Countable $variableName;
420420
}
421+
422+
class StandaloneNullTrueFalseTypes
423+
{
424+
/**
425+
* @var null
426+
*/
427+
public null $variableName = null;
428+
429+
/**
430+
* @var true
431+
*/
432+
protected true $variableName = true;
433+
434+
/**
435+
* @var false
436+
*/
437+
private false $variableName = false;
438+
}
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)