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

Commit

Permalink
Fixed MethodScanner that on latest prm value fails
Browse files Browse the repository at this point in the history
Unit test for this case added anyway
  • Loading branch information
olekhy committed Sep 16, 2013
1 parent 3bd643a commit 86fead2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions library/Zend/Code/Scanner/MethodScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ protected function scan()
goto SCANNER_CONTINUE_SIGNATURE;
case ')':
$parentCount--;
if($parentCount > 0) {
goto SCANNER_CONTINUE_SIGNATURE;
}
if ($parentCount === 0) {
if ($infos) {
$MACRO_INFO_ADVANCE();
Expand Down
2 changes: 1 addition & 1 deletion tests/ZendTest/Code/Scanner/ClassScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testClassScannerCanReturnLineNumbers()
$file = new FileScanner(__DIR__ . '/../TestAsset/BarClass.php');
$class = $file->getClass('ZendTest\Code\TestAsset\BarClass');
$this->assertEquals(10, $class->getLineStart());
$this->assertEquals(33, $class->getLineEnd());
$this->assertEquals(37, $class->getLineEnd());
}

public function testClassScannerCanScanAnnotations()
Expand Down
9 changes: 9 additions & 0 deletions tests/ZendTest/Code/Scanner/MethodScannerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,13 @@ public function testMethodScannerReturnsBodyMethods()
$this->assertEquals($expected, $method->getBody());
}

public function testMethodScannerMethodSignatureLatestOptionalParamHasParentheses()
{
$file = new FileScanner(__DIR__ . '/../TestAsset/BarClass.php');
$class = $file->getClass('ZendTest\Code\TestAsset\BarClass');
$method = $class->getMethod('four');
$paramTwo = $method->getParameter(1);
$optionalValue = $paramTwo->getDefaultValue();
$this->assertEquals('array(array(array(\'default\')))', trim($optionalValue));
}
}
4 changes: 4 additions & 0 deletions tests/ZendTest/Code/TestAsset/BarClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ protected function three(\ArrayObject $o, &$t = 2, FooBarBaz\BazBarFoo $bbf = se
$y = 'this string';
}

protected function four($one, $two = array(array(array('default'))))
{
// four
}
}

0 comments on commit 86fead2

Please # to comment.