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

Commit d1f11ad

Browse files
committed
Merge branch 'hotfix/70'
Close #72 Fixes #70 Fixes #43
2 parents da70699 + d297115 commit d1f11ad

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ All notable changes to this project will be documented in this file, in reverse
2727
how class names under the same namespace are generated when generating
2828
typehints, extends, and implements values; they now strip the
2929
common namespace from the class name.
30+
- [#72](https://github.com/zendframework/zend-code/pull/72) fixes an issue
31+
within the `TokenArrayScanner` when scanning closures.
3032

3133
## 3.0.2 - 2016-04-20
3234

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)