File tree 2 files changed +17
-5
lines changed
2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -165,20 +165,28 @@ impl<'a> PhpParser<'a> {
165
165
. count ( ) > 0 ;
166
166
167
167
if !is_alias {
168
+ // Get the `qualified_name` node kind, which are
169
+ // usages like: `use Foo\Bar;`. We might also run
170
+ // into `use Foo;` which has the node kind `name`,
171
+ // which we ignore.
168
172
let fqn_node = child_node
169
173
. children ( & mut child_node. walk ( ) )
170
174
. filter ( |node| node. kind ( ) == "qualified_name" )
171
- . next ( )
172
- . unwrap ( ) ;
175
+ . next ( ) ;
176
+
177
+ if !fqn_node. is_some ( ) {
178
+ continue ;
179
+ }
173
180
174
181
let fqn_name = fqn_node
175
- . children ( & mut fqn_node. walk ( ) )
182
+ . unwrap ( )
183
+ . children ( & mut fqn_node. unwrap ( ) . walk ( ) )
176
184
. filter ( |node| node. kind ( ) == "name" )
177
185
. next ( )
178
186
. and_then ( |node| Some ( self . get_node_text ( & node) ) ) ;
179
187
180
188
if fqn_name. unwrap ( ) == property_type {
181
- let mut fqn_text = self . get_node_text ( & fqn_node) ;
189
+ let mut fqn_text = self . get_node_text ( & fqn_node. unwrap ( ) ) ;
182
190
183
191
// Make sure FQN always starts with a backslash.
184
192
if !fqn_text. starts_with ( '\\' ) {
Original file line number Diff line number Diff line change 8
8
9
9
Given php (function where the type should result in its FQN):
10
10
<?php
11
+ use Closure;
12
+ use Exception;
11
13
use Symfony\Component\HttpFoundation\Response;
12
14
13
15
function myFunction(Response $p1): Response {}
14
16
15
17
Do (trigger doge):
16
- :4 \<CR>
18
+ :6 \<CR>
17
19
\<C-d>
18
20
19
21
Expect php (generated comment containing the FQN):
20
22
<?php
23
+ use Closure;
24
+ use Exception;
21
25
use Symfony\Component\HttpFoundation\Response;
22
26
23
27
/**
You can’t perform that action at this time.
0 commit comments