Loading syntax/exceptions.php +2 −8 Original line number Diff line number Diff line Loading @@ -54,22 +54,16 @@ class InvalidExpressionException extends Exception { class NotEnoughArgumentsException extends Exception { private $_elementDefinition = null; private $_firstTokenInstance = null; public function __construct($elementDefinition, $firstTokenInstance, $code = 0, Exception $previous = null) { public function __construct($elementDefinition, $code = 0, Exception $previous = null) { $this->_elementDefinition = $elementDefinition; $this->_firstTokenInstance = $firstTokenInstance; $message = 'Not enough arguments for operator ' . $elementDefinition->name() . ' encountered at position ' . $firstTokenInstance->position() . ', around "' . substr($firstTokenInstance->text(), max(0, $firstTokenInstance->position() - 3), $firstTokenInstance->length() + 3) . '".'; $message = 'Not enough arguments for operator ' . $elementDefinition->name() . '.'; if ($elementDefinition->arity() > 0) { $message .= ' Expected ' . $elementDefinition->arity() . ' arguments.'; } parent::__construct($message, $code, $previous); } public function getFirstTokenInstance() { return $this->_firstTokenInstance; } public function getElementDefinition() { return $this->_elementDefinition; } public function __toString() { Loading syntax/parser.php +5 −5 Original line number Diff line number Diff line Loading @@ -385,7 +385,7 @@ class ElementDefinition { $elmArgs = self::_extractAlternateChain($args, $firstTokPosition + 1, $chainLength); $elmInst = new ElementInstance($definition, $elmArgs); if ($firstTokPosition + $chainLength * 2 > count($args)) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition]); throw new NotEnoughArgumentsException($definition); } array_splice($args, $firstTokPosition, $chainLength * 2, array($elmInst)); return $firstTokPosition; Loading @@ -398,9 +398,9 @@ class ElementDefinition { $elmArgs = self::_extractAlternateChain($args, $firstTokPosition - 1, $chainLength); $elmInst = new ElementInstance($definition, $elmArgs); if ($firstTokPosition == 0) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition]); throw new NotEnoughArgumentsException($definition); } elseif ($firstTokPosition + $chainLength * 2 - 1 > count($args)) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition - 1]); throw new NotEnoughArgumentsException($definition); } array_splice($args, $firstTokPosition - 1, $chainLength * 2, array($elmInst)); return $firstTokPosition - 1; Loading @@ -413,9 +413,9 @@ class ElementDefinition { $elmArgs = self::_extractAlternateChain($args, $firstTokPosition - 1, $chainLength + 1); $elmInst = new ElementInstance($definition, $elmArgs); if ($firstTokPosition == 0) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition]); throw new NotEnoughArgumentsException($definition); } elseif ($firstTokPosition + $chainLength * 2 > count($args)) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition - 1]); throw new NotEnoughArgumentsException($definition); } array_splice($args, $firstTokPosition - 1, $chainLength * 2 + 1, array($elmInst)); return $firstTokPosition - 1; Loading Loading
syntax/exceptions.php +2 −8 Original line number Diff line number Diff line Loading @@ -54,22 +54,16 @@ class InvalidExpressionException extends Exception { class NotEnoughArgumentsException extends Exception { private $_elementDefinition = null; private $_firstTokenInstance = null; public function __construct($elementDefinition, $firstTokenInstance, $code = 0, Exception $previous = null) { public function __construct($elementDefinition, $code = 0, Exception $previous = null) { $this->_elementDefinition = $elementDefinition; $this->_firstTokenInstance = $firstTokenInstance; $message = 'Not enough arguments for operator ' . $elementDefinition->name() . ' encountered at position ' . $firstTokenInstance->position() . ', around "' . substr($firstTokenInstance->text(), max(0, $firstTokenInstance->position() - 3), $firstTokenInstance->length() + 3) . '".'; $message = 'Not enough arguments for operator ' . $elementDefinition->name() . '.'; if ($elementDefinition->arity() > 0) { $message .= ' Expected ' . $elementDefinition->arity() . ' arguments.'; } parent::__construct($message, $code, $previous); } public function getFirstTokenInstance() { return $this->_firstTokenInstance; } public function getElementDefinition() { return $this->_elementDefinition; } public function __toString() { Loading
syntax/parser.php +5 −5 Original line number Diff line number Diff line Loading @@ -385,7 +385,7 @@ class ElementDefinition { $elmArgs = self::_extractAlternateChain($args, $firstTokPosition + 1, $chainLength); $elmInst = new ElementInstance($definition, $elmArgs); if ($firstTokPosition + $chainLength * 2 > count($args)) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition]); throw new NotEnoughArgumentsException($definition); } array_splice($args, $firstTokPosition, $chainLength * 2, array($elmInst)); return $firstTokPosition; Loading @@ -398,9 +398,9 @@ class ElementDefinition { $elmArgs = self::_extractAlternateChain($args, $firstTokPosition - 1, $chainLength); $elmInst = new ElementInstance($definition, $elmArgs); if ($firstTokPosition == 0) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition]); throw new NotEnoughArgumentsException($definition); } elseif ($firstTokPosition + $chainLength * 2 - 1 > count($args)) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition - 1]); throw new NotEnoughArgumentsException($definition); } array_splice($args, $firstTokPosition - 1, $chainLength * 2, array($elmInst)); return $firstTokPosition - 1; Loading @@ -413,9 +413,9 @@ class ElementDefinition { $elmArgs = self::_extractAlternateChain($args, $firstTokPosition - 1, $chainLength + 1); $elmInst = new ElementInstance($definition, $elmArgs); if ($firstTokPosition == 0) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition]); throw new NotEnoughArgumentsException($definition); } elseif ($firstTokPosition + $chainLength * 2 > count($args)) { throw new NotEnoughArgumentsException($definition, $args[$firstTokPosition - 1]); throw new NotEnoughArgumentsException($definition); } array_splice($args, $firstTokPosition - 1, $chainLength * 2 + 1, array($elmInst)); return $firstTokPosition - 1; Loading