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

Commit bf62fbb

Browse files
committed
Merge pull request #61 from djmattyg007/fix_methodscanner_handling_of_fqcns
Fix handling of FQCNs in method parameters
2 parents 634a1a1 + 658b63f commit bf62fbb

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

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)