/** * Internal generator method * * Used by unit tests to debug generated PHP code. * * @param string $expression * @return string * @throws ParserException */ protected function generateEvaluatorCode($expression) { $parser = new EntityPrivilegeExpressionParser($expression); /** @var boolean|array $result */ $result = $parser->match_Expression(); if ($result === false) { throw new ParserException(sprintf('Expression "%s" could not be parsed.', $expression), 1416933186); } elseif ($parser->pos !== strlen($expression)) { throw new ParserException(sprintf('Expression "%s" could not be parsed. Error starting at character %d: "%s".', $expression, $parser->pos, substr($expression, $parser->pos)), 1416933203); } elseif (!array_key_exists('code', $result)) { throw new ParserException(sprintf('Parser error, no code in result %s ', json_encode($result)), 1416933192); } return $result['code']; }