Project

General

Profile

« Previous | Next » 

Revision 1852

Added by darkviper over 11 years ago

updated Twig template engine to stable version 1.11.1 step2

View differences:

ExpressionParser.php
158 158
                } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
159 159
                    $node = $this->parseHashExpression();
160 160
                } else {
161
                    throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine());
161
                    throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token->getType(), $token->getLine()), $token->getValue()), $token->getLine(), $this->parser->getFilename());
162 162
                }
163 163
        }
164 164

  
......
252 252
            } else {
253 253
                $current = $stream->getCurrent();
254 254

  
255
                throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($current->getType(), $current->getLine()), $current->getValue()), $current->getLine());
255
                throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($current->getType(), $current->getLine()), $current->getValue()), $current->getLine(), $this->parser->getFilename());
256 256
            }
257 257

  
258 258
            $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
......
291 291
        switch ($name) {
292 292
            case 'parent':
293 293
                if (!count($this->parser->getBlockStack())) {
294
                    throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line);
294
                    throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line, $this->parser->getFilename());
295 295
                }
296 296

  
297 297
                if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
298
                    throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden', $line);
298
                    throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden', $line, $this->parser->getFilename());
299 299
                }
300 300

  
301 301
                return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
......
303 303
                return new Twig_Node_Expression_BlockReference($args->getNode(0), false, $line);
304 304
            case 'attribute':
305 305
                if (count($args) < 2) {
306
                    throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes)', $line);
306
                    throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes)', $line, $this->parser->getFilename());
307 307
                }
308 308

  
309 309
                return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : new Twig_Node_Expression_Array(array(), $line), Twig_TemplateInterface::ANY_CALL, $line);
310 310
            default:
311
                if (null !== $alias = $this->parser->getImportedFunction($name)) {
311
                if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
312 312
                    $arguments = new Twig_Node_Expression_Array(array(), $line);
313 313
                    foreach ($args as $n) {
314 314
                        $arguments->addElement($n);
......
351 351
                    }
352 352
                }
353 353
            } else {
354
                throw new Twig_Error_Syntax('Expected name or number', $lineno);
354
                throw new Twig_Error_Syntax('Expected name or number', $lineno, $this->parser->getFilename());
355 355
            }
356 356
        } else {
357 357
            $type = Twig_TemplateInterface::ARRAY_CALL;
......
380 380
            $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
381 381
        }
382 382

  
383
        if ($node instanceof Twig_Node_Expression_Name && null !== $alias = $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
384
            $node = new Twig_Node_Expression_MethodCall($node, 'get'.$arg->getAttribute('value'), $arguments, $lineno);
385
            $node->setAttribute('safe', true);
386

  
387
            return $node;
388
        }
389

  
383 390
        return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno);
384 391
    }
385 392

  
......
439 446
        while (true) {
440 447
            $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
441 448
            if (in_array($token->getValue(), array('true', 'false', 'none'))) {
442
                throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s"', $token->getValue()), $token->getLine());
449
                throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s"', $token->getValue()), $token->getLine(), $this->parser->getFilename());
443 450
            }
444 451
            $targets[] = new Twig_Node_Expression_AssignName($token->getValue(), $token->getLine());
445 452

  

Also available in: Unified diff