diff --git a/src/SymbolFinder.php b/src/SymbolFinder.php index 0e68172..f49677c 100644 --- a/src/SymbolFinder.php +++ b/src/SymbolFinder.php @@ -73,6 +73,8 @@ class SymbolFinder extends NodeVisitorAbstract } } else { $this->nameStack[] = $containerName; + // We are not interested in unnamed nodes, return + return; } $class = get_class($node); diff --git a/tests/PhpDocumentTest.php b/tests/PhpDocumentTest.php new file mode 100644 index 0000000..465748a --- /dev/null +++ b/tests/PhpDocumentTest.php @@ -0,0 +1,70 @@ +project = new Project(new LanguageClient(new MockProtocolStream())); + } + + public function testParsesVariableVariables() + { + $document = $this->project->getDocument('whatever'); + + $document->updateContent("getSymbols(); + + $this->assertEquals([ + [ + 'name' => 'a', + 'kind' => SymbolKind::VARIABLE, + 'location' => [ + 'uri' => 'whatever', + 'range' => [ + 'start' => [ + 'line' => 1, + 'character' => 0 + ], + 'end' => [ + 'line' => 1, + 'character' => 3 + ] + ] + ], + 'containerName' => null + ], + [ + 'name' => 'bar', + 'kind' => SymbolKind::VARIABLE, + 'location' => [ + 'uri' => 'whatever', + 'range' => [ + 'start' => [ + 'line' => 2, + 'character' => 0 + ], + 'end' => [ + 'line' => 2, + 'character' => 4 + ] + ] + ], + 'containerName' => null + ] + ], json_decode(json_encode($symbols), true)); + } +}