From 028a618276899adf8d313da1bd558edc18b03348 Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 5 Oct 2016 21:00:35 +0200 Subject: [PATCH] Fix using brackets inside function arguments --- src/RR/Shunt/Parser.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/RR/Shunt/Parser.php b/src/RR/Shunt/Parser.php index 5727e74..0b438be 100644 --- a/src/RR/Shunt/Parser.php +++ b/src/RR/Shunt/Parser.php @@ -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