Skip to content

Commit

Permalink
Fix using brackets inside function arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Oct 5, 2016
1 parent 5f59f0c commit 028a618
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/RR/Shunt/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,17 @@ public function dump($str = false)

protected function fargs($fn)
{
$argc = 0;
$argc = $parenthesis = 0;
$this->handle($this->scanner->next()); // '('

if ($this->scanner->peek()) { // more tokens?
while ($t = $this->scanner->next()) {
$this->handle($t);

if ($t->type === Token::T_PCLOSE)
// nested parenthesis inside function calls
if ($t->type === Token::T_POPEN)
$parenthesis++;
elseif ($t->type === Token::T_PCLOSE && $parenthesis-- === 0)
break;

$argc = max($argc, 1); // at least 1 arg if bracket not closed immediately
Expand Down

0 comments on commit 028a618

Please sign in to comment.