Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
Issue #31: function::getArguments: fixed function name mistakenly use…
Browse files Browse the repository at this point in the history
…d as typehint for first typehint-less argument
  • Loading branch information
Stefaan Lippens committed Oct 21, 2013
1 parent 5220af2 commit 5a54d90
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion PHP/Token.php
Expand Up @@ -376,10 +376,15 @@ public function getArguments()
}

$this->arguments = array();
$i = $this->id + 2;
$tokens = $this->tokenStream->tokens();
$typeHint = NULL;

// Search for first token inside brackets
$i = $this->id + 2;
while (!$tokens[$i-1] instanceof PHP_Token_OPEN_BRACKET) {
$i++;
}

while (!$tokens[$i] instanceof PHP_Token_CLOSE_BRACKET) {
if ($tokens[$i] instanceof PHP_Token_STRING) {
$typeHint = (string)$tokens[$i];
Expand Down
2 changes: 2 additions & 0 deletions Tests/Token/FunctionTest.php
Expand Up @@ -99,6 +99,8 @@ public function testGetArguments()
);

$this->assertEquals(array(), $this->functions[4]->getArguments());

$this->assertEquals(array('$x' => null, '$y' => null), $this->functions[5]->getArguments());
}

/**
Expand Down
4 changes: 4 additions & 0 deletions Tests/_files/source.php
Expand Up @@ -29,4 +29,8 @@ public function barfoo(Barfoo $barfoo)
public function baz()
{
}

public function blaz($x, $y)
{
}
}

0 comments on commit 5a54d90

Please sign in to comment.