diff --git a/src/Scanner/TokenArrayScanner.php b/src/Scanner/TokenArrayScanner.php index c0d20fca..ea1037a1 100644 --- a/src/Scanner/TokenArrayScanner.php +++ b/src/Scanner/TokenArrayScanner.php @@ -583,7 +583,9 @@ protected function scan() && $infos[$infoIndex]['type'] === 'class' || ($tokenType === T_FUNCTION && $infos[$infoIndex]['type'] === 'function')) ) { - $infos[$infoIndex]['shortName'] = $tokens[$tokenIndex + 2][1]; + $infos[$infoIndex]['shortName'] = is_array($tokens[$tokenIndex + 2]) + ? $tokens[$tokenIndex + 2][1] + : $tokens[$tokenIndex + 2]; $infos[$infoIndex]['name'] = (($namespace !== null) ? $namespace . '\\' : '') . $infos[$infoIndex]['shortName']; diff --git a/test/Reflection/FileReflectionTest.php b/test/Reflection/FileReflectionTest.php index b96acdbd..1ce2d990 100644 --- a/test/Reflection/FileReflectionTest.php +++ b/test/Reflection/FileReflectionTest.php @@ -175,4 +175,16 @@ public function testFileCanReflectFileWithUses() ]; $this->assertSame($expected, $reflectionFile->getUses()); } + + /** + * @group 70 + * @group 43 + */ + public function testFileReflectionShouldNotRaiseNoticesWhenReflectingClosures() + { + require_once __DIR__ . '/TestAsset/issue-70.php'; + $r = new FileReflection(__DIR__ . '/TestAsset/issue-70.php'); + $this->assertContains('spl_autoload_register', $r->getContents()); + $this->assertContains('function ()', $r->getContents()); + } } diff --git a/test/Reflection/TestAsset/issue-70.php b/test/Reflection/TestAsset/issue-70.php new file mode 100644 index 00000000..d9c3aa81 --- /dev/null +++ b/test/Reflection/TestAsset/issue-70.php @@ -0,0 +1,9 @@ +