Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit e71c589

Browse files
committed
Provide a fix for issue #70
- Added a failing test case, per #70. - Discovered that the structure addressed can be either an array (existing assumption) or a string. - Updated the assignment to check for array before assigning, and use the string value if present instead.
1 parent ca15548 commit e71c589

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/Scanner/TokenArrayScanner.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,9 @@ protected function scan()
583583
&& $infos[$infoIndex]['type'] === 'class'
584584
|| ($tokenType === T_FUNCTION && $infos[$infoIndex]['type'] === 'function'))
585585
) {
586-
$infos[$infoIndex]['shortName'] = $tokens[$tokenIndex + 2][1];
586+
$infos[$infoIndex]['shortName'] = is_array($tokens[$tokenIndex + 2])
587+
? $tokens[$tokenIndex + 2][1]
588+
: $tokens[$tokenIndex + 2];
587589
$infos[$infoIndex]['name'] = (($namespace !== null)
588590
? $namespace . '\\'
589591
: '') . $infos[$infoIndex]['shortName'];

test/Reflection/FileReflectionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,16 @@ public function testFileCanReflectFileWithUses()
175175
];
176176
$this->assertSame($expected, $reflectionFile->getUses());
177177
}
178+
179+
/**
180+
* @group 70
181+
* @group 43
182+
*/
183+
public function testFileReflectionShouldNotRaiseNoticesWhenReflectingClosures()
184+
{
185+
require_once __DIR__ . '/TestAsset/issue-70.php';
186+
$r = new FileReflection(__DIR__ . '/TestAsset/issue-70.php');
187+
$this->assertContains('spl_autoload_register', $r->getContents());
188+
$this->assertContains('function ()', $r->getContents());
189+
}
178190
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* @link http://github.com/zendframework/zend-code for the canonical source repository
4+
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license http://framework.zend.com/license/new-bsd New BSD License
6+
*/
7+
8+
spl_autoload_register(function () {
9+
});

0 commit comments

Comments
 (0)