Skip to content

Commit a9f371e

Browse files
committed
Test errors in @var above class constants
1 parent b932769 commit a9f371e

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

src/Rules/PhpDoc/InvalidPhpDocTagValueRule.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function processNode(Node $node, Scope $scope): array
4040
&& !$node instanceof Node\Stmt\Property
4141
&& !$node instanceof Node\Expr\Assign
4242
&& !$node instanceof Node\Expr\AssignRef
43+
&& !$node instanceof Node\Stmt\ClassConst
4344
) {
4445
return [];
4546
}

tests/PHPStan/Rules/PhpDoc/InvalidPhpDocTagValueRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public function testRule(): void
8686
'PHPDoc tag @throws has invalid value ((\Exception): Unexpected token "*/", expected \')\' at offset 24',
8787
72,
8888
],
89+
[
90+
'PHPDoc tag @var has invalid value ((Foo|Bar): Unexpected token "*/", expected \')\' at offset 18',
91+
81,
92+
],
8993
]);
9094
}
9195

tests/PHPStan/Rules/PhpDoc/InvalidPhpDocVarTagTypeRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ public function testRule(): void
9797
67,
9898
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
9999
],
100+
[
101+
'PHPDoc tag @var contains unresolvable type.',
102+
90,
103+
],
100104
]);
101105
}
102106

tests/PHPStan/Rules/PhpDoc/data/invalid-phpdoc.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ public function doFoo()
7373
}
7474

7575
}
76+
77+
class ClassConstant
78+
{
79+
80+
/** @var (Foo|Bar */
81+
const FOO = 1;
82+
83+
}

tests/PHPStan/Rules/PhpDoc/data/invalid-var-tag-type.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ class Bar
8383
private $foo;
8484

8585
}
86+
87+
class Baz
88+
{
89+
90+
/** @var self&\stdClass */
91+
const FOO = 1;
92+
93+
}

0 commit comments

Comments
 (0)