Skip to content

Commit

Permalink
Merge pull request #211 from PHPCSStandards/feature/squiz-variablecom…
Browse files Browse the repository at this point in the history
…ment-allow-for-more-missing-types

PHP 8.2 | Squiz/VariableComment: allow for stand-alone null/true/false types and more
  • Loading branch information
jrfnl authored Jan 10, 2024
2 parents dc0ac49 + b04f0a6 commit cbb5548
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +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
36 changes: 36 additions & 0 deletions src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,39 @@ class IntersectionTypes
*/
private \Iterator&\Countable $variableName;
}

class StandaloneNullTrueFalseTypes
{
/**
* @var null
*/
public null $variableName = null;

/**
* @var true
*/
protected true $variableName = true;

/**
* @var false
*/
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 @@ -418,3 +418,39 @@ class IntersectionTypes
*/
private \Iterator&\Countable $variableName;
}

class StandaloneNullTrueFalseTypes
{
/**
* @var null
*/
public null $variableName = null;

/**
* @var true
*/
protected true $variableName = true;

/**
* @var false
*/
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 cbb5548

Please sign in to comment.