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

Commit

Permalink
Merge branch 'hotfix/70' into develop
Browse files Browse the repository at this point in the history
Forward port #72
  • Loading branch information
weierophinney committed Jun 27, 2016
2 parents 9debbfb + d297115 commit d2ffdb0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ All notable changes to this project will be documented in this file, in reverse
how class names under the same namespace are generated when generating
typehints, extends, and implements values; they now strip the
common namespace from the class name.
- [#72](https://github.com/zendframework/zend-code/pull/72) fixes an issue
within the `TokenArrayScanner` when scanning closures.

## 3.0.2 - 2016-04-20

Expand Down
4 changes: 3 additions & 1 deletion src/Scanner/TokenArrayScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
12 changes: 12 additions & 0 deletions test/Reflection/FileReflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
9 changes: 9 additions & 0 deletions test/Reflection/TestAsset/issue-70.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* @link http://github.com/zendframework/zend-code for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

spl_autoload_register(function () {
});

0 comments on commit d2ffdb0

Please sign in to comment.