@@ -45,11 +45,16 @@ public function __invoke(Stream $stream): ElementReference
4545 $ body = \rtrim ($ matches [0 ]);
4646 $ isFullyQualified = $ body [0 ] === '\\' ;
4747
48+ // @phpstan-ignore match.unhandled
4849 $ result = match ($ matches ['MARK ' ]) {
50+ // @phpstan-ignore-next-line : All ok
4951 'T_FUNCTION ' => new FunctionElementReference ($ isFullyQualified
52+ // @phpstan-ignore-next-line : All ok
5053 ? new FullQualifiedName (\substr ($ body , 0 , -2 ))
54+ // @phpstan-ignore-next-line : All ok
5155 : new Name (\substr ($ body , 0 , -2 )),
5256 ),
57+ // @phpstan-ignore-next-line : All ok
5358 'T_IDENTIFIER ' => new TypeElementReference (
5459 type: new NamedTypeNode ($ isFullyQualified
5560 ? new FullQualifiedName ($ body )
@@ -61,20 +66,29 @@ public function __invoke(Stream $stream): ElementReference
6166 ),
6267 'T_CLASS_CONSTANT ' => new ClassConstantElementReference (
6368 class: $ isFullyQualified
69+ // @phpstan-ignore-next-line : All ok
6470 ? new FullQualifiedName ($ matches ['T_CLASS ' ])
71+ // @phpstan-ignore-next-line : All ok
6572 : new Name ($ matches ['T_CLASS ' ]),
73+ // @phpstan-ignore-next-line : All ok
6674 constant: \substr ($ body , \strlen ($ matches ['T_CLASS ' ]) + 2 ),
6775 ),
6876 'T_CLASS_METHOD ' => new ClassMethodElementReference (
6977 class: $ isFullyQualified
78+ // @phpstan-ignore-next-line : All ok
7079 ? new FullQualifiedName ($ matches ['T_CLASS ' ])
80+ // @phpstan-ignore-next-line : All ok
7181 : new Name ($ matches ['T_CLASS ' ]),
82+ // @phpstan-ignore-next-line : All ok
7283 method: \substr ($ body , \strlen ($ matches ['T_CLASS ' ]) + 2 , -2 ),
7384 ),
7485 'T_CLASS_PROPERTY ' => new ClassPropertyElementReference (
7586 class: $ isFullyQualified
87+ // @phpstan-ignore-next-line : All ok
7688 ? new FullQualifiedName ($ matches ['T_CLASS ' ])
89+ // @phpstan-ignore-next-line : All ok
7790 : new Name ($ matches ['T_CLASS ' ]),
91+ // @phpstan-ignore-next-line : All ok
7892 property: \substr ($ body , \strlen ($ matches ['T_CLASS ' ]) + 3 ),
7993 ),
8094 };
@@ -89,64 +103,4 @@ class: $isFullyQualified
89103 $ stream ->tag ,
90104 ));
91105 }
92-
93- private function getReference (string $ context , Stream $ stream ): ElementReference
94- {
95- $ class = new Name ($ context );
96-
97- if (\str_starts_with ($ stream ->value , ':: ' )) {
98- $ stream ->shift (2 , false );
99-
100- if (\str_starts_with ($ stream ->value , '$ ' )) {
101- $ stream ->shift (1 , false );
102-
103- $ variable = $ this ->fetchIdentifier ($ stream ->value );
104-
105- if ($ variable !== null ) {
106- return new ClassPropertyElementReference (
107- class: $ class ,
108- property: $ variable ,
109- );
110- }
111-
112- throw $ stream ->toException (\sprintf (
113- 'Tag @%s contains invalid property name after class reference ' ,
114- $ stream ->tag ,
115- ));
116- }
117-
118- $ identifier = $ this ->fetchIdentifier ($ stream ->value );
119-
120- if ($ identifier !== null ) {
121- $ stream ->shift (\strlen ($ identifier ), false );
122-
123- if (\str_starts_with ($ stream ->value , '() ' )) {
124- return new ClassMethodElementReference (
125- class: $ class ,
126- method: $ identifier ,
127- );
128- }
129-
130- return new ClassConstantElementReference (
131- class: $ class ,
132- constant: $ identifier ,
133- );
134- }
135-
136- throw $ stream ->toException (\sprintf (
137- 'Tag @%s contains invalid method or constant name after class reference ' ,
138- $ stream ->tag ,
139- ));
140- }
141-
142- if (\str_starts_with ($ stream ->value , '() ' )) {
143- $ stream ->shift (2 , false );
144-
145- return new FunctionElementReference ($ class );
146- }
147-
148- return new TypeElementReference (
149- type: new NamedTypeNode ($ class ),
150- );
151- }
152106}
0 commit comments