summaryrefslogtreecommitdiffstats
path: root/php-symfony-upstream.patch
blob: 7ee4018665002cfffbf6758bb4ddd1656308c296 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
From f0849d833118e69b0d630047594b046f0d4a34bc Mon Sep 17 00:00:00 2001
From: Fabien Potencier <fabien.potencier@gmail.com>
Date: Sat, 15 Oct 2016 12:33:44 -0700
Subject: [PATCH] [TwigBridge] removed deprecations added in Twig 1.27

---
 composer.json                                      |  2 +-
 src/Symfony/Bridge/Twig/Command/LintCommand.php    |  2 +-
 .../Twig/Tests/Extension/RoutingExtensionTest.php  |  2 +-
 .../Tests/Extension/TranslationExtensionTest.php   |  2 +-
 .../Twig/Tests/NodeVisitor/TwigNodeProvider.php    |  2 +-
 .../Tests/TokenParser/FormThemeTokenParserTest.php |  2 +-
 .../Twig/TokenParser/TransChoiceTokenParser.php    |  2 +-
 .../Bridge/Twig/TokenParser/TransTokenParser.php   |  4 ++--
 .../Bridge/Twig/Translation/TwigExtractor.php      |  6 +++---
 src/Symfony/Bridge/Twig/composer.json              |  2 +-
 src/Symfony/Bundle/SecurityBundle/composer.json    |  2 +-
 .../DependencyInjection/Configuration.php          |  2 +-
 .../DependencyInjection/TwigExtensionTest.php      |  2 +-
 .../TokenParser/LegacyRenderTokenParserTest.php    |  2 +-
 src/Symfony/Bundle/TwigBundle/TwigEngine.php       | 10 ++++-----
 src/Symfony/Bundle/TwigBundle/composer.json        |  2 +-
 .../HttpKernel/DataCollector/DumpDataCollector.php | 25 ++++++++++++----------
 17 files changed, 37 insertions(+), 34 deletions(-)

diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php
index df603f9..4ed6324 100644
--- a/src/Symfony/Bridge/Twig/Command/LintCommand.php
+++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php
@@ -146,7 +146,7 @@ private function validate(\Twig_Environment $twig, $template, $file)
         try {
             $temporaryLoader = new \Twig_Loader_Array(array((string) $file => $template));
             $twig->setLoader($temporaryLoader);
-            $nodeTree = $twig->parse($twig->tokenize($template, (string) $file));
+            $nodeTree = $twig->parse($twig->tokenize(new \Twig_Source($template, (string) $file)));
             $twig->compile($nodeTree);
             $twig->setLoader($realLoader);
         } catch (\Twig_Error $e) {
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
index 1c1ac64..87b6052 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
@@ -23,7 +23,7 @@ public function testEscaping($template, $mustBeEscaped)
         $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
         $twig->addExtension(new RoutingExtension($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')));
 
-        $nodes = $twig->parse($twig->tokenize($template));
+        $nodes = $twig->parse($twig->tokenize(new \Twig_Source($template)));
 
         $this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof \Twig_Node_Expression_Filter);
     }
diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php
index a02edc7..0235c4d 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php
@@ -36,7 +36,7 @@ public function testTrans($template, $expected, array $variables = array())
             $twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false));
             $twig->addExtension(new TranslationExtension(new Translator('en', new MessageSelector())));
 
-            echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSource('index'), 'index')))."\n\n";
+            echo $twig->compile($twig->parse($twig->tokenize(new \Twig_Source($twig->getLoader()->getSource('index'), 'index'))))."\n\n";
             $this->assertEquals($expected, $this->getTemplate($template)->render($variables));
         }
 
diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php
index 0e401f6..a90b556 100644
--- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php
+++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php
@@ -25,7 +25,7 @@ public static function getModule($content)
             new \Twig_Node_Expression_Array(array(), 0),
             new \Twig_Node_Expression_Array(array(), 0),
             null,
-            null
+            new \Twig_Source('')
         );
     }
 
diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
index 2986cd1..aa99132 100644
--- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
@@ -23,7 +23,7 @@ public function testCompile($source, $expected)
     {
         $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
         $env->addTokenParser(new FormThemeTokenParser());
-        $stream = $env->tokenize($source);
+        $stream = $env->tokenize(new \Twig_Source($source));
         $parser = new \Twig_Parser($env);
 
         $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
index 7ea1a2c..e9e65ad 100644
--- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
+++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
@@ -64,7 +64,7 @@ public function parse(\Twig_Token $token)
         $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
 
         if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
-            throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getFilename());
+            throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getSourceContext()->getName());
         }
 
         $stream->expect(\Twig_Token::BLOCK_END_TYPE);
diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
index 06472d0..1493cf8 100644
--- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
+++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
@@ -55,7 +55,7 @@ public function parse(\Twig_Token $token)
                 $stream->next();
                 $locale = $this->parser->getExpressionParser()->parseExpression();
             } elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) {
-                throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getFilename());
+                throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName());
             }
         }
 
@@ -64,7 +64,7 @@ public function parse(\Twig_Token $token)
         $body = $this->parser->subparse(array($this, 'decideTransFork'), true);
 
         if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
-            throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getFilename());
+            throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getSourceContext()->getName());
         }
 
         $stream->expect(\Twig_Token::BLOCK_END_TYPE);
diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
index 2a9450c..69ec1d9 100644
--- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
+++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
@@ -62,9 +62,9 @@ public function extract($resource, MessageCatalogue $catalogue)
                 $this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
             } catch (\Twig_Error $e) {
                 if ($file instanceof SplFileInfo) {
-                    $e->setTemplateFile($file->getRelativePathname());
+                    $e->setTemplateName($file->getRelativePathname());
                 } elseif ($file instanceof \SplFileInfo) {
-                    $e->setTemplateFile($file->getRealPath());
+                    $e->setTemplateName($file->getRealPath());
                 }
 
                 throw $e;
@@ -85,7 +85,7 @@ protected function extractTemplate($template, MessageCatalogue $catalogue)
         $visitor = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor();
         $visitor->enable();
 
-        $this->twig->parse($this->twig->tokenize($template));
+        $this->twig->parse($this->twig->tokenize(new \Twig_Source($template)));
 
         foreach ($visitor->getMessages() as $message) {
             $catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
index 52c70f3..008f9b7 100644
--- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
@@ -167,7 +167,7 @@ private function addTwigOptions(ArrayNodeDefinition $rootNode)
         $rootNode
             ->fixXmlConfig('path')
             ->children()
-                ->variableNode('autoescape')->defaultValue('filename')->end()
+                ->variableNode('autoescape')->defaultValue('name')->end()
                 ->scalarNode('autoescape_service')->defaultNull()->end()
                 ->scalarNode('autoescape_service_method')->defaultNull()->end()
                 ->scalarNode('base_template_class')->example('Twig_Template')->cannotBeEmpty()->end()
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php
index cd39680..fcfa38a 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php
@@ -147,7 +147,7 @@ public function testLoadDefaultTemplateEscapingGuesserConfiguration($format)
         $this->compileContainer($container);
 
         $options = $container->getDefinition('twig')->getArgument(1);
-        $this->assertEquals('filename', $options['autoescape']);
+        $this->assertEquals('name', $options['autoescape']);
     }
 
     public function testGlobalsWithDifferentTypesAndValues()
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
index e3d0a72..b1f81ec 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
@@ -27,7 +27,7 @@ public function testCompile($source, $expected)
     {
         $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
         $env->addTokenParser(new RenderTokenParser());
-        $stream = $env->tokenize($source);
+        $stream = $env->tokenize(new \Twig_Source($source));
         $parser = new \Twig_Parser($env);
 
         $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php
index 3092fe9..0d01648 100644
--- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php
+++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php
@@ -54,13 +54,13 @@ public function setDefaultEscapingStrategy($strategy)
 
     /**
      * @deprecated since version 2.7, to be removed in 3.0.
-     *             Use the 'filename' strategy instead.
+     *             Use the 'name' strategy instead.
      */
-    public function guessDefaultEscapingStrategy($filename)
+    public function guessDefaultEscapingStrategy($name)
     {
         @trigger_error('The '.__METHOD__.' method is deprecated since version 2.7 and will be removed in 3.0. Use the Twig_FileExtensionEscapingStrategy::guess method instead.', E_USER_DEPRECATED);
 
-        return \Twig_FileExtensionEscapingStrategy::guess($filename);
+        return \Twig_FileExtensionEscapingStrategy::guess($name);
     }
 
     /**
@@ -73,8 +73,8 @@ public function render($name, array $parameters = array())
         } catch (\Twig_Error $e) {
             if ($name instanceof TemplateReference) {
                 try {
-                    // try to get the real file name of the template where the error occurred
-                    $e->setTemplateFile(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateFile()))));
+                    // try to get the real name of the template where the error occurred
+                    $e->setTemplateName(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateName()))));
                 } catch (\Exception $e2) {
                 }
             }
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
index 985db4b..3a445f4 100644
--- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
+++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php
@@ -97,21 +97,24 @@ public function dump(Data $data)
 
                         break;
                     } elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof \Twig_Template) {
-                        $info = $trace[$i]['object'];
-                        $name = $info->getTemplateName();
-                        $src = method_exists($info, 'getSource') ? $info->getSource() : $info->getEnvironment()->getLoader()->getSource($name);
-                        $info = $info->getDebugInfo();
+                        $template = $trace[$i]['object'];
+                        $name = $template->getTemplateName();
+                        $file = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getPath() : false;
+                        $src = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : false);
+                        $info = $template->getDebugInfo();
                         if (null !== $src && isset($info[$trace[$i - 1]['line']])) {
-                            $file = false;
                             $line = $info[$trace[$i - 1]['line']];
-                            $src = explode("\n", $src);
-                            $fileExcerpt = array();
 
-                            for ($i = max($line - 3, 1), $max = min($line + 3, count($src)); $i <= $max; ++$i) {
-                                $fileExcerpt[] = '<li'.($i === $line ? ' class="selected"' : '').'><code>'.$this->htmlEncode($src[$i - 1]).'</code></li>';
-                            }
+                            if ($src) {
+                                $src = explode("\n", $src);
+                                $fileExcerpt = array();
+
+                                for ($i = max($line - 3, 1), $max = min($line + 3, count($src)); $i <= $max; ++$i) {
+                                    $fileExcerpt[] = '<li'.($i === $line ? ' class="selected"' : '').'><code>'.$this->htmlEncode($src[$i - 1]).'</code></li>';
+                                }
 
-                            $fileExcerpt = '<ol start="'.max($line - 3, 1).'">'.implode("\n", $fileExcerpt).'</ol>';
+                                $fileExcerpt = '<ol start="'.max($line - 3, 1).'">'.implode("\n", $fileExcerpt).'</ol>';
+                            }
                         }
                         break;
                     }
From bb791d076444e016f7da768212233357eeac49de Mon Sep 17 00:00:00 2001
From: Fabien Potencier <fabien.potencier@gmail.com>
Date: Wed, 19 Oct 2016 15:17:26 -0700
Subject: [PATCH] [TwigBridge] Use non-deprecated Twig_Node::getTemplateLine()

---
 src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php         | 2 +-
 src/Symfony/Bridge/Twig/Node/TransNode.php                        | 6 +++---
 .../Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php      | 8 ++++----
 src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php    | 2 +-
 src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php          | 2 +-
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php b/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php
index 8c42bcd..9cb9648 100644
--- a/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php
+++ b/src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php
@@ -37,7 +37,7 @@ public function compile(\Twig_Compiler $compiler)
                     // the variables in the third argument
                     $label = $arguments[1];
                     $variables = isset($arguments[2]) ? $arguments[2] : null;
-                    $lineno = $label->getLine();
+                    $lineno = $label->getTemplateLine();
 
                     if ($label instanceof \Twig_Node_Expression_Constant) {
                         // If the label argument is given as a constant, we can either
diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php
index 114b38c..7b2f9c0 100644
--- a/src/Symfony/Bridge/Twig/Node/TransNode.php
+++ b/src/Symfony/Bridge/Twig/Node/TransNode.php
@@ -109,18 +109,18 @@ protected function compileString(\Twig_Node $body, \Twig_Node_Expression_Array $
         preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);
 
         foreach ($matches[1] as $var) {
-            $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine());
+            $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getTemplateLine());
             if (!$vars->hasElement($key)) {
                 if ('count' === $var && $this->hasNode('count')) {
                     $vars->addElement($this->getNode('count'), $key);
                 } else {
-                    $varExpr = new \Twig_Node_Expression_Name($var, $body->getLine());
+                    $varExpr = new \Twig_Node_Expression_Name($var, $body->getTemplateLine());
                     $varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck);
                     $vars->addElement($varExpr, $key);
                 }
             }
         }
 
-        return array(new \Twig_Node_Expression_Constant(str_replace('%%', '%', trim($msg)), $body->getLine()), $vars);
+        return array(new \Twig_Node_Expression_Constant(str_replace('%%', '%', trim($msg)), $body->getTemplateLine()), $vars);
     }
 }
diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php
index 3e85035..b226d91 100644
--- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php
+++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php
@@ -50,10 +50,10 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env)
                 return $node;
             } else {
                 $var = $env->getParser()->getVarName();
-                $name = new \Twig_Node_Expression_AssignName($var, $node->getLine());
-                $this->scope->set('domain', new \Twig_Node_Expression_Name($var, $node->getLine()));
+                $name = new \Twig_Node_Expression_AssignName($var, $node->getTemplateLine());
+                $this->scope->set('domain', new \Twig_Node_Expression_Name($var, $node->getTemplateLine()));
 
-                return new \Twig_Node_Set(false, new \Twig_Node(array($name)), new \Twig_Node(array($node->getNode('expr'))), $node->getLine());
+                return new \Twig_Node_Set(false, new \Twig_Node(array($name)), new \Twig_Node(array($node->getNode('expr'))), $node->getTemplateLine());
             }
         }
 
@@ -71,7 +71,7 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env)
             } else {
                 if (!$arguments->hasNode($ind)) {
                     if (!$arguments->hasNode($ind - 1)) {
-                        $arguments->setNode($ind - 1, new \Twig_Node_Expression_Array(array(), $node->getLine()));
+                        $arguments->setNode($ind - 1, new \Twig_Node_Expression_Array(array(), $node->getTemplateLine()));
                     }
 
                     $arguments->setNode($ind, $this->scope->get('domain'));
diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
index e9e65ad..fa61a2f 100644
--- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
+++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php
@@ -64,7 +64,7 @@ public function parse(\Twig_Token $token)
         $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
 
         if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
-            throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getSourceContext()->getName());
+            throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
         }
 
         $stream->expect(\Twig_Token::BLOCK_END_TYPE);
diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
index 1493cf8..4c8e7d3 100644
--- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
+++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
@@ -64,7 +64,7 @@ public function parse(\Twig_Token $token)
         $body = $this->parser->subparse(array($this, 'decideTransFork'), true);
 
         if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
-            throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getSourceContext()->getName());
+            throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
         }
 
         $stream->expect(\Twig_Token::BLOCK_END_TYPE);
From b9a4586b24d671a43160cebd58f51bcc278af139 Mon Sep 17 00:00:00 2001
From: Fabien Potencier <fabien.potencier@gmail.com>
Date: Fri, 21 Oct 2016 18:08:29 -0700
Subject: [PATCH] [TwigBridge] fixed Twig_Source required argument

---
 src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php       | 2 +-
 src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php         | 2 +-
 src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php | 2 +-
 src/Symfony/Bridge/Twig/Translation/TwigExtractor.php                  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
index 87b6052..9733cd7 100644
--- a/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/Extension/RoutingExtensionTest.php
@@ -23,7 +23,7 @@ public function testEscaping($template, $mustBeEscaped)
         $twig = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0));
         $twig->addExtension(new RoutingExtension($this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface')));
 
-        $nodes = $twig->parse($twig->tokenize(new \Twig_Source($template)));
+        $nodes = $twig->parse($twig->tokenize(new \Twig_Source($template, '')));
 
         $this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof \Twig_Node_Expression_Filter);
     }
diff --git a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php
index a90b556..502cad3 100644
--- a/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php
+++ b/src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php
@@ -25,7 +25,7 @@ public static function getModule($content)
             new \Twig_Node_Expression_Array(array(), 0),
             new \Twig_Node_Expression_Array(array(), 0),
             null,
-            new \Twig_Source('')
+            new \Twig_Source('', '')
         );
     }
 
diff --git a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
index aa99132..6b6a92a 100644
--- a/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
+++ b/src/Symfony/Bridge/Twig/Tests/TokenParser/FormThemeTokenParserTest.php
@@ -23,7 +23,7 @@ public function testCompile($source, $expected)
     {
         $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
         $env->addTokenParser(new FormThemeTokenParser());
-        $stream = $env->tokenize(new \Twig_Source($source));
+        $stream = $env->tokenize(new \Twig_Source($source, ''));
         $parser = new \Twig_Parser($env);
 
         $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
diff --git a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
index 69ec1d9..917687a 100644
--- a/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
+++ b/src/Symfony/Bridge/Twig/Translation/TwigExtractor.php
@@ -85,7 +85,7 @@ protected function extractTemplate($template, MessageCatalogue $catalogue)
         $visitor = $this->twig->getExtension('Symfony\Bridge\Twig\Extension\TranslationExtension')->getTranslationNodeVisitor();
         $visitor->enable();
 
-        $this->twig->parse($this->twig->tokenize(new \Twig_Source($template)));
+        $this->twig->parse($this->twig->tokenize(new \Twig_Source($template, '')));
 
         foreach ($visitor->getMessages() as $message) {
             $catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ?: $this->defaultDomain);
From 7b56cc08767bfaa2b1a53f211fd657a8a8328c0f Mon Sep 17 00:00:00 2001
From: Fabien Potencier <fabien.potencier@gmail.com>
Date: Sun, 23 Oct 2016 22:48:00 -0700
Subject: [PATCH] removed usage of Twig_Compiler::addIndentation

---
 src/Symfony/Bridge/Twig/Node/DumpNode.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Symfony/Bridge/Twig/Node/DumpNode.php b/src/Symfony/Bridge/Twig/Node/DumpNode.php
index a7c1529..a66781e 100644
--- a/src/Symfony/Bridge/Twig/Node/DumpNode.php
+++ b/src/Symfony/Bridge/Twig/Node/DumpNode.php
@@ -65,7 +65,7 @@ public function compile(\Twig_Compiler $compiler)
                 ->write('\Symfony\Component\VarDumper\VarDumper::dump(array('."\n")
                 ->indent();
             foreach ($values as $node) {
-                $compiler->addIndentation();
+                $compiler->write('');
                 if ($node->hasAttribute('name')) {
                     $compiler
                         ->string($node->getAttribute('name'))
From 317d46f249893dbb5b0f7b7f4acf2243d3da9127 Mon Sep 17 00:00:00 2001
From: Fabien Potencier <fabien.potencier@gmail.com>
Date: Fri, 21 Oct 2016 18:11:17 -0700
Subject: [PATCH] [TwigBundle] fixed usage of getSource in tests

---
 .../TwigBundle/Tests/Loader/FilesystemLoaderTest.php |  6 +++---
 .../TokenParser/LegacyRenderTokenParserTest.php      |  2 +-
 .../WebProfilerBundle/Profiler/TemplateManager.php   |  6 +++++-
 .../Tests/Profiler/TemplateManagerTest.php           | 20 +++++++-------------
 4 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
index 269e029..9804c08 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/Loader/FilesystemLoaderTest.php
@@ -17,7 +17,7 @@
 
 class FilesystemLoaderTest extends TestCase
 {
-    public function testGetSource()
+    public function testGetSourceContext()
     {
         $parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
         $locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
@@ -30,10 +30,10 @@ public function testGetSource()
         $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views', 'namespace');
 
         // Twig-style
-        $this->assertEquals("This is a layout\n", $loader->getSource('@namespace/layout.html.twig'));
+        $this->assertEquals("This is a layout\n", $loader->getSourceContext('@namespace/layout.html.twig')->getCode());
 
         // Symfony-style
-        $this->assertEquals("This is a layout\n", $loader->getSource('TwigBundle::layout.html.twig'));
+        $this->assertEquals("This is a layout\n", $loader->getSourceContext('TwigBundle::layout.html.twig')->getCode());
     }
 
     public function testExists()
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
index b1f81ec..6a5806c 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/TokenParser/LegacyRenderTokenParserTest.php
@@ -27,7 +27,7 @@ public function testCompile($source, $expected)
     {
         $env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
         $env->addTokenParser(new RenderTokenParser());
-        $stream = $env->tokenize(new \Twig_Source($source));
+        $stream = $env->tokenize(new \Twig_Source($source, ''));
         $parser = new \Twig_Parser($env);
 
         $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php
index 5d0fd27..415034a 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Profiler/TemplateManager.php
@@ -126,7 +126,11 @@ protected function templateExists($template)
         }
 
         try {
-            $loader->getSource($template);
+            if ($loader instanceof \Twig_SourceContextLoaderInterface) {
+                $loader->getSourceContext($template);
+            } else {
+                $loader->getSource($template);
+            }
 
             return true;
         } catch (\Twig_Error_Loader $e) {
diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
index 29238a2..c9b199e 100644
--- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
+++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php
@@ -32,11 +32,6 @@ class TemplateManagerTest extends TestCase
     protected $profiler;
 
     /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $profile;
-
-    /**
      * @var \Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager
      */
     protected $templateManager;
@@ -129,11 +124,7 @@ public function profileHasCollectorCallback($panel)
 
     protected function mockProfile()
     {
-        $this->profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        return  $this->profile;
+        return $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')->disableOriginalConstructor()->getMock();
     }
 
     protected function mockTwigEnvironment()
@@ -144,9 +135,12 @@ protected function mockTwigEnvironment()
             ->method('loadTemplate')
             ->will($this->returnValue('loadedTemplate'));
 
-        $this->twigEnvironment->expects($this->any())
-            ->method('getLoader')
-            ->will($this->returnValue($this->getMock('\Twig_LoaderInterface')));
+        if (interface_exists('\Twig_SourceContextLoaderInterface')) {
+            $loader = $this->getMock('\Twig_SourceContextLoaderInterface');
+        } else {
+            $loader = $this->getMock('\Twig_LoaderInterface');
+        }
+        $this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader));
 
         return $this->twigEnvironment;
     }