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

Commit a1c8eab

Browse files
committed
Merge branch 'hotfix/61' into develop
Forward port #61
2 parents 3ab1cc0 + ec10781 commit a1c8eab

File tree

5 files changed

+27
-2
lines changed

5 files changed

+27
-2
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ All notable changes to this project will be documented in this file, in reverse
3737

3838
### Fixed
3939

40-
- Nothing.
40+
- [#61](https://github.com/zendframework/zend-code/pull/61) fixes an issue with
41+
how parameter typehints were generated; previously, fully-qualified class
42+
names were not being generated with the leading backslash, causing them to
43+
attempt to resolve as if they were relative to the current namespace.
4144

4245
## 3.0.2 - 2016-04-20
4346

src/Scanner/MethodScanner.php

+7
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,13 @@ protected function scan()
522522
goto SCANNER_CONTINUE_SIGNATURE;
523523
// goto (no break needed);
524524

525+
case T_NS_SEPARATOR:
526+
if (!isset($infos[$infoIndex])) {
527+
$MACRO_INFO_START();
528+
}
529+
goto SCANNER_CONTINUE_SIGNATURE;
530+
// goto (no break needed);
531+
525532
case T_VARIABLE:
526533
case T_STRING:
527534
if ($tokenType === T_STRING && $parentCount === 0) {

test/Scanner/ClassScannerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function testClassScannerCanReturnLineNumbers()
160160
$file = new FileScanner(__DIR__ . '/../TestAsset/BarClass.php');
161161
$class = $file->getClass('ZendTest\Code\TestAsset\BarClass');
162162
$this->assertEquals(10, $class->getLineStart());
163-
$this->assertEquals(37, $class->getLineEnd());
163+
$this->assertEquals(42, $class->getLineEnd());
164164
}
165165

166166
public function testClassScannerCanScanAnnotations()

test/Scanner/MethodScannerTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public function testMethodScannerReturnsParameterScanner()
4848
$this->assertEquals('t', $parameter->getName());
4949
}
5050

51+
public function testMethodScannerParsesClassNames()
52+
{
53+
$file = new FileScanner(__DIR__ . '/../TestAsset/BarClass.php');
54+
$class = $file->getClass('ZendTest\Code\TestAsset\BarClass');
55+
$method = $class->getMethod('five');
56+
$this->assertEquals(['a'], $method->getParameters());
57+
$parameter = $method->getParameter('a');
58+
$this->assertEquals('ZendTest\Code\TestAsset\AbstractClass', $parameter->getClass());
59+
}
60+
5161
public function testMethodScannerReturnsPropertyWithNoDefault()
5262
{
5363
$file = new FileScanner(__DIR__ . '/../TestAsset/BazClass.php');

test/TestAsset/BarClass.php

+5
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ protected function four($one, $two = array(array(array('default'))))
3434
{
3535
// four
3636
}
37+
38+
private function five(\ZendTest\Code\TestAsset\AbstractClass $a)
39+
{
40+
// five
41+
}
3742
}

0 commit comments

Comments
 (0)