42            $this->unaryOperators = 
$env->getUnaryOperators();
 
   43            $this->binaryOperators = 
$env->getBinaryOperators();
 
   45            @trigger_error(
'Passing the operators as constructor arguments to '.__METHOD__.
' is deprecated since version 1.27. Pass the environment instead.', E_USER_DEPRECATED);
 
   47            $this->env = 
$parser->getEnvironment();
 
   48            $this->unaryOperators = func_get_arg(1);
 
   49            $this->binaryOperators = func_get_arg(2);
 
   56        $token = $this->parser->getCurrentToken();
 
   57        while ($this->
isBinary($token) && $this->binaryOperators[$token->getValue()][
'precedence'] >= $precedence) {
 
   58            $op = $this->binaryOperators[$token->getValue()];
 
   59            $this->parser->getStream()->next();
 
   61            if (
'is not' === $token->getValue()) {
 
   63            } elseif (
'is' === $token->getValue()) {
 
   65            } elseif (isset($op[
'callable'])) {
 
   66                $expr = call_user_func($op[
'callable'], $this->parser, $expr);
 
   68                $expr1 = $this->
parseExpression(self::OPERATOR_LEFT === $op[
'associativity'] ? $op[
'precedence'] + 1 : $op[
'precedence']);
 
   69                $class = $op[
'class'];
 
   70                $expr = 
new $class($expr, $expr1, $token->getLine());
 
   73            $token = $this->parser->getCurrentToken();
 
   76        if (0 === $precedence) {
 
   85        $token = $this->parser->getCurrentToken();
 
   88            $operator = $this->unaryOperators[$token->getValue()];
 
   89            $this->parser->getStream()->next();
 
   91            $class = $operator[
'class'];
 
   95            $this->parser->getStream()->next();
 
  138        $token = $this->parser->getCurrentToken();
 
  139        switch ($token->getType()) {
 
  141                $this->parser->getStream()->next();
 
  142                switch ($token->getValue()) {
 
  161                        if (
'(' === $this->parser->getCurrentToken()->getValue()) {
 
  170                $this->parser->getStream()->next();
 
  180                if (preg_match(
Twig_Lexer::REGEX_NAME, $token->getValue(), $matches) && $matches[0] == $token->getValue()) {
 
  182                    $this->parser->getStream()->next();
 
  185                } elseif (isset($this->unaryOperators[$token->getValue()])) {
 
  186                    $class = $this->unaryOperators[$token->getValue()][
'class'];
 
  188                    $ref = 
new ReflectionClass($class);
 
  189                    $negClass = 
'Twig_Node_Expression_Unary_Neg';
 
  190                    $posClass = 
'Twig_Node_Expression_Unary_Pos';
 
  191                    if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
 
  192                        throw new Twig_Error_Syntax(
sprintf(
'Unexpected unary operator "%s".', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
 
  195                    $this->parser->getStream()->next();
 
  198                    $node = 
new $class($expr, $token->getLine());
 
  208                } elseif ($token->test(
Twig_Token::OPERATOR_TYPE, 
'=') && (
'==' === $this->parser->getStream()->look(-1)->getValue() || 
'!=' === $this->parser->getStream()->look(-1)->getValue())) {
 
  209                    throw new Twig_Error_Syntax(
sprintf(
'Unexpected operator of value "%s". Did you try to use "===" or "!==" for strict comparison? Use "is same as(value)" instead.', $token->getValue()), $token->getLine(), $this->parser->getStream()->getSourceContext());
 
  220        $stream = $this->parser->getStream();
 
  224        $nextCanBeString = 
true;
 
  228                $nextCanBeString = 
false;
 
  232                $nextCanBeString = 
true;
 
  238        $expr = array_shift($nodes);
 
  239        foreach ($nodes as $node) {
 
  248        $stream = $this->parser->getStream();
 
  273        $stream = $this->parser->getStream();
 
  308            $node->addElement($value, 
$key);
 
  318            $token = $this->parser->getCurrentToken();
 
  320                if (
'.' == $token->getValue() || 
'[' == $token->getValue()) {
 
  322                } elseif (
'|' == $token->getValue()) {
 
  340                if (!count($this->parser->getBlockStack())) {
 
  341                    throw new Twig_Error_Syntax(
'Calling "parent" outside a block is forbidden.', $line, $this->parser->getStream()->getSourceContext());
 
  344                if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
 
  345                    throw new Twig_Error_Syntax(
'Calling "parent" on a template that does not extend nor "use" another template is forbidden.', $line, $this->parser->getStream()->getSourceContext());
 
  351                if (count($args) < 1) {
 
  352                    throw new Twig_Error_Syntax(
'The "block" function takes one argument (the block name).', $line, $this->parser->getStream()->getSourceContext());
 
  358                if (count($args) < 2) {
 
  359                    throw new Twig_Error_Syntax(
'The "attribute" function takes at least two arguments (the variable and the attributes).', $line, $this->parser->getStream()->getSourceContext());
 
  364                if (
null !== $alias = $this->parser->getImportedSymbol(
'function', 
$name)) {
 
  367                        $arguments->addElement(
$n);
 
  371                    $node->setAttribute(
'safe', 
true);
 
  379                return new $class(
$name, $args, $line);
 
  385        $stream = $this->parser->getStream();
 
  387        $lineno = $token->getLine();
 
  390        if (
'.' == $token->getValue()) {
 
  404                        $arguments->addElement(
$n);
 
  411            if ($node instanceof 
Twig_Node_Expression_Name && 
null !== $this->parser->getImportedSymbol(
'template', $node->getAttribute(
'name'))) {
 
  413                    throw new Twig_Error_Syntax(
sprintf(
'Dynamic macro names are not supported (called on "%s").', $node->getAttribute(
'name')), $token->getLine(), 
$stream->getSourceContext());
 
  416                $name = $arg->getAttribute(
'value');
 
  418                if ($this->parser->isReservedMacroName(
$name)) {
 
  423                $node->setAttribute(
'safe', 
true);
 
  451                $arguments = 
new Twig_Node(array($arg, $length));
 
  467        $this->parser->getStream()->next();
 
  486            $node = 
new $class($node, 
$name, $arguments, $token->getLine(), 
$tag);
 
  492            $this->parser->getStream()->next();
 
  511        $stream = $this->parser->getStream();
 
  529                    throw new Twig_Error_Syntax(
sprintf(
'A parameter name must be a string, "%s" given.', get_class($value)), $token->getLine(), 
$stream->getSourceContext());
 
  531                $name = $value->getAttribute(
'name');
 
  537                        throw new Twig_Error_Syntax(
sprintf(
'A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), 
$stream->getSourceContext());
 
  545                if (
null === 
$name) {
 
  546                    $name = $value->getAttribute(
'name');
 
  549                $args[
$name] = $value;
 
  551                if (
null === 
$name) {
 
  554                    $args[
$name] = $value;
 
  565        $stream = $this->parser->getStream();
 
  569            $value = $token->getValue();
 
  570            if (in_array(strtolower($value), array(
'true', 
'false', 
'none', 
'null'))) {
 
  603        $stream = $this->parser->getStream();
 
  609            $arguments = $this->parser->getExpressionParser()->parseArguments(
true);
 
  612        return new $class($node, 
$name, $arguments, $this->parser->getCurrentToken()->getLine());
 
  617        $stream = $this->parser->getStream();
 
  626            $name = 
$name.
' '.$this->parser->getCurrentToken()->getValue();
 
  636        $e->addSuggestions(
$name, array_keys($this->env->getTests()));
 
  644            $stream = $this->parser->getStream();
 
  646            if (!is_bool(
$test->getDeprecatedVersion())) {
 
  649            if (
$test->getAlternative()) {
 
  652            $src = 
$stream->getSourceContext();
 
  653            $message .= 
sprintf(
' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), 
$stream->getCurrent()->getLine());
 
  655            @trigger_error(
$message, E_USER_DEPRECATED);
 
  659            return $test->getNodeClass();
 
  669            $e->addSuggestions(
$name, array_keys($this->env->getFunctions()));
 
  676            if (!is_bool(
$function->getDeprecatedVersion())) {
 
  682            $src = $this->parser->getStream()->getSourceContext();
 
  683            $message .= 
sprintf(
' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
 
  685            @trigger_error(
$message, E_USER_DEPRECATED);
 
  697        if (
false === $filter = $this->env->getFilter(
$name)) {
 
  699            $e->addSuggestions(
$name, array_keys($this->env->getFilters()));
 
  705            $message = 
sprintf(
'Twig Filter "%s" is deprecated', $filter->getName());
 
  706            if (!is_bool($filter->getDeprecatedVersion())) {
 
  707                $message .= 
sprintf(
' since version %s', $filter->getDeprecatedVersion());
 
  709            if ($filter->getAlternative()) {
 
  712            $src = $this->parser->getStream()->getSourceContext();
 
  713            $message .= 
sprintf(
' in %s at line %d.', $src->getPath() ? $src->getPath() : $src->getName(), $line);
 
  715            @trigger_error(
$message, E_USER_DEPRECATED);
 
  719            return $filter->getNodeClass();
 
  734        foreach ($node as 
$n) {
 
  744class_alias(
'Twig_ExpressionParser', 
'Twig\ExpressionParser', 
false);
 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Stores the Twig configuration.
Exception thrown when a syntax error occurs during lexing or parsing of a template.
getFunctionNodeClass($name, $line)
isUnary(Twig_Token $token)
getFunctionNode($name, $line)
parseNotTestExpression(Twig_NodeInterface $node)
parseFilterExpression($node)
parseConditionalExpression($expr)
parseSubscriptExpression($node)
parsePostfixExpression($node)
parseAssignmentExpression()
getFilterNodeClass($name, $line)
parseExpression($precedence=0)
parseFilterExpressionRaw($node, $tag=null)
parseMultitargetExpression()
__construct(Twig_Parser $parser, $env=null)
parseArguments($namedArguments=false, $definition=false)
Parses arguments.
checkConstantExpression(Twig_NodeInterface $node)
isBinary(Twig_Token $token)
parseTestExpression(Twig_NodeInterface $node)
Represents a template filter as a node.
Represents a template function as a node.
Represents a block call node.
Represents a parent node.
Represents a node in the AST.
Default parser implementation.
Represents a template filter.
Represents a template function.
Represents a template test.
Represents a template test as a Node.
const INTERPOLATION_START_TYPE
test($type, $values=null)
Tests the current token for a type and/or a value.
const INTERPOLATION_END_TYPE
static typeToEnglish($type)
Returns the English representation of a given type.
Represents a node in the AST.
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
catch(Exception $e) $message
$stream
PHP stream implementation.