44
55use PHPStan \PhpDocParser \Ast \NodeAttributes ;
66use PHPStan \PhpDocParser \Parser \ParserException ;
7+ use function sprintf ;
8+ use function trigger_error ;
9+ use const E_USER_WARNING ;
710
11+ /**
12+ * @property ParserException $exception
13+ */
814class InvalidTagValueNode implements PhpDocTagValueNode
915{
1016
@@ -13,15 +19,30 @@ class InvalidTagValueNode implements PhpDocTagValueNode
1319 /** @var string (may be empty) */
1420 public $ value ;
1521
16- /** @var ParserException */
17- public $ exception ;
22+ /** @var mixed[] */
23+ private $ exceptionArgs ;
1824
1925 public function __construct (string $ value , ParserException $ exception )
2026 {
2127 $ this ->value = $ value ;
22- $ this ->exception = $ exception ;
28+ $ this ->exceptionArgs = [
29+ $ exception ->getCurrentTokenValue (),
30+ $ exception ->getCurrentTokenType (),
31+ $ exception ->getCurrentOffset (),
32+ $ exception ->getExpectedTokenType (),
33+ $ exception ->getExpectedTokenValue (),
34+ ];
2335 }
2436
37+ public function __get (string $ name )
38+ {
39+ if ($ name !== 'exception ' ) {
40+ trigger_error (sprintf ('Undefined property: %s::$%s ' , self ::class, $ name ), E_USER_WARNING );
41+ return null ;
42+ }
43+
44+ return new ParserException (...$ this ->exceptionArgs );
45+ }
2546
2647 public function __toString (): string
2748 {
0 commit comments