File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 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> {
165165 . count ( ) > 0 ;
166166
167167 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.
168172 let fqn_node = child_node
169173 . children ( & mut child_node. walk ( ) )
170174 . filter ( |node| node. kind ( ) == "qualified_name" )
171- . next ( )
172- . unwrap ( ) ;
175+ . next ( ) ;
176+
177+ if !fqn_node. is_some ( ) {
178+ continue ;
179+ }
173180
174181 let fqn_name = fqn_node
175- . children ( & mut fqn_node. walk ( ) )
182+ . unwrap ( )
183+ . children ( & mut fqn_node. unwrap ( ) . walk ( ) )
176184 . filter ( |node| node. kind ( ) == "name" )
177185 . next ( )
178186 . and_then ( |node| Some ( self . get_node_text ( & node) ) ) ;
179187
180188 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 ( ) ) ;
182190
183191 // Make sure FQN always starts with a backslash.
184192 if !fqn_text. starts_with ( '\\' ) {
Original file line number Diff line number Diff line change 88
99Given php (function where the type should result in its FQN):
1010 <?php
11+ use Closure;
12+ use Exception;
1113 use Symfony\Component\HttpFoundation\Response;
1214
1315 function myFunction(Response $p1): Response {}
1416
1517Do (trigger doge):
16- :4 \<CR>
18+ :6 \<CR>
1719 \<C-d>
1820
1921Expect php (generated comment containing the FQN):
2022 <?php
23+ use Closure;
24+ use Exception;
2125 use Symfony\Component\HttpFoundation\Response;
2226
2327 /**
You can’t perform that action at this time.
0 commit comments