Skip to content

Commit

Permalink
Test errors in @var above class constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Aug 17, 2021
1 parent b932769 commit a9f371e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Rules/PhpDoc/InvalidPhpDocTagValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function processNode(Node $node, Scope $scope): array
&& !$node instanceof Node\Stmt\Property
&& !$node instanceof Node\Expr\Assign
&& !$node instanceof Node\Expr\AssignRef
&& !$node instanceof Node\Stmt\ClassConst
) {
return [];
}
Expand Down
4 changes: 4 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/InvalidPhpDocTagValueRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public function testRule(): void
'PHPDoc tag @throws has invalid value ((\Exception): Unexpected token "*/", expected \')\' at offset 24',
72,
],
[
'PHPDoc tag @var has invalid value ((Foo|Bar): Unexpected token "*/", expected \')\' at offset 18',
81,
],
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public function testRule(): void
67,
'Learn more at https://phpstan.org/user-guide/discovering-symbols',
],
[
'PHPDoc tag @var contains unresolvable type.',
90,
],
]);
}

Expand Down
8 changes: 8 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/data/invalid-phpdoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ public function doFoo()
}

}

class ClassConstant
{

/** @var (Foo|Bar */
const FOO = 1;

}
8 changes: 8 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/data/invalid-var-tag-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,11 @@ class Bar
private $foo;

}

class Baz
{

/** @var self&\stdClass */
const FOO = 1;

}

0 comments on commit a9f371e

Please sign in to comment.