From 05fb3cfb862be4207287a95ba33f805a46a78488 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Thu, 22 Sep 2016 23:35:06 +0200 Subject: [PATCH] Fixed local variable detection and containerName generation in SymbolFinder. --- src/SymbolFinder.php | 6 +++--- tests/Server/TextDocumentTest.php | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/SymbolFinder.php b/src/SymbolFinder.php index 58fc695..e185d3e 100644 --- a/src/SymbolFinder.php +++ b/src/SymbolFinder.php @@ -68,7 +68,7 @@ class SymbolFinder extends NodeVisitorAbstract array_push($this->nameStack, (string)$node->name); } else { - if ($node instanceof Stmt\ClassMethod) { + if ($node instanceof Node\Stmt\ClassMethod) { array_push($this->nameStack, $containerName . '::' . (string)$node->name); } else { @@ -86,7 +86,7 @@ class SymbolFinder extends NodeVisitorAbstract } // if we enter a method or function, increase the function counter - if ($node instanceof Stmt\Function_ || $node instanceof Stmt\ClassMethod) { + if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) { $this->functionCount++; } @@ -117,7 +117,7 @@ class SymbolFinder extends NodeVisitorAbstract array_pop($this->nameStack); // if we leave a method or function, decrease the function counter - if ($node instanceof Function_ || $node instanceof ClassMethod) { + if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) { $this->functionCount--; } } diff --git a/tests/Server/TextDocumentTest.php b/tests/Server/TextDocumentTest.php index f227fe8..0be1e27 100644 --- a/tests/Server/TextDocumentTest.php +++ b/tests/Server/TextDocumentTest.php @@ -60,7 +60,7 @@ class TextDocumentTest extends TestCase ] ] ], - 'containerName' => null + 'containerName' => 'TestNamespace' ], [ 'name' => 'testProperty', @@ -78,7 +78,7 @@ class TextDocumentTest extends TestCase ] ] ], - 'containerName' => 'TestClass' + 'containerName' => 'TestNamespace\\TestClass' ], [ 'name' => 'testMethod', @@ -96,7 +96,7 @@ class TextDocumentTest extends TestCase ] ] ], - 'containerName' => 'TestClass' + 'containerName' => 'TestNamespace\\TestClass' ], [ 'name' => 'TestTrait', @@ -114,7 +114,7 @@ class TextDocumentTest extends TestCase ] ] ], - 'containerName' => null + 'containerName' => 'TestNamespace' ], [ 'name' => 'TestInterface', @@ -132,7 +132,7 @@ class TextDocumentTest extends TestCase ] ] ], - 'containerName' => null + 'containerName' => 'TestNamespace' ] ], json_decode(json_encode($result), true)); }