Skip to content

Commit

Permalink
bug in arguments aextractor
Browse files Browse the repository at this point in the history
  • Loading branch information
Halleck45 committed Sep 1, 2014
1 parent 148a464 commit d917dee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Hal/Component/OOP/Extractor/MethodExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ public function extract(&$n, TokenCollection $tokens)
if(sizeof($elems, COUNT_NORMAL) == 1) {
list($name, $type) = array_pad($elems, 2, null);
} else {
list($type, $name) = array_pad($elems, 2, null);

if('$' == $elems[0][0]) {
$name = $elems[0];
$type = null;
$isRequired = false;
} else {
list($type, $name) = array_pad($elems, 2, null);
}
}

$argument = new ReflectedArgument($name, $type, $isRequired);
Expand Down
2 changes: 2 additions & 0 deletions tests/Hal/Component/OOP/MethodExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public function provideCodeForNew() {
array(array(), '<?php public function foo() { return 1; }')
, array(array('A'), '<?php public function bar() { new A(); }')
, array(array('A'), '<?php public function bar() { new A(1,2,3); }')
, array(array(), '<?php public function bar($d = false) { }')
, array(array(), '<?php public function bar($d = false) { }')
);
}
}

0 comments on commit d917dee

Please sign in to comment.