allow null in union types of VariableCommentSniff
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/code-style Pipeline was successful

This commit is contained in:
Ferdinand Kuhl 2023-02-10 17:50:54 +01:00
parent f2fde71ef7
commit 42a7968cee
3 changed files with 4 additions and 2 deletions

View file

@ -15,6 +15,7 @@ class VariableCommentSniff extends \PHP_CodeSniffer\Standards\Squiz\Sniffs\Comme
\T_PRIVATE => \T_PRIVATE, \T_PRIVATE => \T_PRIVATE,
\T_PROTECTED => \T_PROTECTED, \T_PROTECTED => \T_PROTECTED,
\T_VAR => \T_VAR, \T_VAR => \T_VAR,
\T_NULL => \T_NULL,
\T_STATIC => \T_STATIC, \T_STATIC => \T_STATIC,
\T_TYPE_UNION => \T_TYPE_UNION, \T_TYPE_UNION => \T_TYPE_UNION,
\T_WHITESPACE => \T_WHITESPACE, \T_WHITESPACE => \T_WHITESPACE,

View file

@ -9,6 +9,7 @@ class VariableCommentSniffTest extends TestCase
public function testErrors(): void public function testErrors(): void
{ {
$report = self::checkFile(__DIR__ . '/data/comments.php'); $report = self::checkFile(__DIR__ . '/data/comments.php');
var_dump($report->getErrors());
self::assertCount(1, $report->getWarnings()[20][6]); self::assertCount(1, $report->getWarnings()[20][6]);
self::assertCount(2, $report->getErrors()); self::assertCount(2, $report->getErrors());
} }

View file

@ -40,7 +40,7 @@ class E extends A {
class F extends A { class F extends A {
/** /**
* @var A|E * @var A|E|null|bool
*/ */
protected A|E $myVar; protected A|E|null|bool $myVar;
} }