Browse code

fixed CS

Fabien Potencier authored on 15/02/2019 04:56:07
Showing 24 changed files
... ...
@@ -54,7 +54,7 @@ class Twig_Compiler
54 54
     /**
55 55
      * Compiles a node.
56 56
      *
57
-     * @param int       $indentation The current indentation
57
+     * @param int $indentation The current indentation
58 58
      *
59 59
      * @return $this
60 60
      */
... ...
@@ -241,7 +241,7 @@ class Twig_Environment
241 241
         } elseif ($cache instanceof Twig_CacheInterface) {
242 242
             $this->originalCache = $this->cache = $cache;
243 243
         } else {
244
-            throw new LogicException(sprintf('Cache can only be a string, false, or a Twig_CacheInterface implementation.'));
244
+            throw new \LogicException(sprintf('Cache can only be a string, false, or a Twig_CacheInterface implementation.'));
245 245
         }
246 246
     }
247 247
 
... ...
@@ -563,7 +563,7 @@ class Twig_Environment
563 563
         } catch (Twig_Error $e) {
564 564
             $e->setSourceContext($source);
565 565
             throw $e;
566
-        } catch (Exception $e) {
566
+        } catch (\Exception $e) {
567 567
             throw new Twig_Error_Syntax(sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $source, $e);
568 568
         }
569 569
     }
... ...
@@ -871,7 +871,7 @@ class Twig_Environment
871 871
     public function addGlobal($name, $value)
872 872
     {
873 873
         if ($this->extensionSet->isInitialized() && !array_key_exists($name, $this->getGlobals())) {
874
-            throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
874
+            throw new \LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
875 875
         }
876 876
 
877 877
         if (null !== $this->resolvedGlobals) {
... ...
@@ -24,9 +24,9 @@
24 24
  */
25 25
 class Twig_Error_Loader extends Twig_Error
26 26
 {
27
-    public function __construct($message, $lineno = -1, $source = null, Exception $previous = null)
27
+    public function __construct($message, $lineno = -1, $source = null, \Exception $previous = null)
28 28
     {
29
-        Exception::__construct('', 0, $previous);
29
+        \Exception::__construct('', 0, $previous);
30 30
         $this->appendMessage($message);
31 31
         $this->setTemplateLine(false);
32 32
     }
... ...
@@ -67,22 +67,22 @@ final class Twig_Extension_Core extends Twig_Extension
67 67
     /**
68 68
      * Sets the default timezone to be used by the date filter.
69 69
      *
70
-     * @param DateTimeZone|string $timezone The default timezone string or a DateTimeZone object
70
+     * @param \DateTimeZone|string $timezone The default timezone string or a \DateTimeZone object
71 71
      */
72 72
     public function setTimezone($timezone)
73 73
     {
74
-        $this->timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
74
+        $this->timezone = $timezone instanceof \DateTimeZone ? $timezone : new \DateTimeZone($timezone);
75 75
     }
76 76
 
77 77
     /**
78 78
      * Gets the default timezone to be used by the date filter.
79 79
      *
80
-     * @return DateTimeZone The default timezone currently in use
80
+     * @return \DateTimeZone The default timezone currently in use
81 81
      */
82 82
     public function getTimezone()
83 83
     {
84 84
         if (null === $this->timezone) {
85
-            $this->timezone = new DateTimeZone(date_default_timezone_get());
85
+            $this->timezone = new \DateTimeZone(date_default_timezone_get());
86 86
         }
87 87
 
88 88
         return $this->timezone;
... ...
@@ -275,11 +275,11 @@ function twig_cycle($values, $position)
275 275
 
276 276
 /**
277 277
  * Returns a random value depending on the supplied parameter type:
278
- * - a random item from a Traversable or array
278
+ * - a random item from a \Traversable or array
279 279
  * - a random character from a string
280 280
  * - a random integer between 0 and the integer parameter.
281 281
  *
282
- * @param Traversable|array|int|float|string $values The values to pick a random item from
282
+ * @param \Traversable|array|int|float|string $values The values to pick a random item from
283 283
  *
284 284
  * @throws Twig_Error_Runtime when $values is an empty array (does not apply to an empty string which is returned as is)
285 285
  *
... ...
@@ -295,7 +295,7 @@ function twig_random(Twig_Environment $env, $values = null)
295 295
         return $values < 0 ? mt_rand($values, 0) : mt_rand(0, $values);
296 296
     }
297 297
 
298
-    if ($values instanceof Traversable) {
298
+    if ($values instanceof \Traversable) {
299 299
         $values = iterator_to_array($values);
300 300
     } elseif (is_string($values)) {
301 301
         if ('' === $values) {
... ...
@@ -335,9 +335,9 @@ function twig_random(Twig_Environment $env, $values = null)
335 335
  *
336 336
  *   {{ post.published_at|date("m/d/Y") }}
337 337
  *
338
- * @param DateTimeInterface|DateInterval|string $date     A date
339
- * @param string|null                           $format   The target format, null to use the default
340
- * @param DateTimeZone|string|false|null        $timezone The target timezone, null to use the default, false to leave unchanged
338
+ * @param \DateTimeInterface|\DateInterval|string $date     A date
339
+ * @param string|null                             $format   The target format, null to use the default
340
+ * @param \DateTimeZone|string|false|null         $timezone The target timezone, null to use the default, false to leave unchanged
341 341
  *
342 342
  * @return string The formatted date
343 343
  */
... ...
@@ -345,10 +345,10 @@ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $
345 345
 {
346 346
     if (null === $format) {
347 347
         $formats = $env->getExtension('Twig_Extension_Core')->getDateFormat();
348
-        $format = $date instanceof DateInterval ? $formats[1] : $formats[0];
348
+        $format = $date instanceof \DateInterval ? $formats[1] : $formats[0];
349 349
     }
350 350
 
351
-    if ($date instanceof DateInterval) {
351
+    if ($date instanceof \DateInterval) {
352 352
         return $date->format($format);
353 353
     }
354 354
 
... ...
@@ -360,10 +360,10 @@ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $
360 360
  *
361 361
  *   {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
362 362
  *
363
- * @param DateTimeInterface|string $date     A date
364
- * @param string                   $modifier A modifier string
363
+ * @param \DateTimeInterface|string $date     A date
364
+ * @param string                    $modifier A modifier string
365 365
  *
366
- * @return DateTimeInterface A new date object
366
+ * @return \DateTimeInterface A new date object
367 367
  */
368 368
 function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
369 369
 {
... ...
@@ -373,16 +373,16 @@ function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
373 373
 }
374 374
 
375 375
 /**
376
- * Converts an input to a DateTime instance.
376
+ * Converts an input to a \DateTime instance.
377 377
  *
378 378
  *    {% if date(user.created_at) < date('+2days') %}
379 379
  *      {# do something #}
380 380
  *    {% endif %}
381 381
  *
382
- * @param DateTimeInterface|string|null  $date     A date or null to use the current time
383
- * @param DateTimeZone|string|false|null $timezone The target timezone, null to use the default, false to leave unchanged
382
+ * @param \DateTimeInterface|string|null  $date     A date or null to use the current time
383
+ * @param \DateTimeZone|string|false|null $timezone The target timezone, null to use the default, false to leave unchanged
384 384
  *
385
- * @return DateTime A DateTime instance
385
+ * @return \DateTime A \DateTime instance
386 386
  */
387 387
 function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null)
388 388
 {
... ...
@@ -390,17 +390,17 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
390 390
     if (false !== $timezone) {
391 391
         if (null === $timezone) {
392 392
             $timezone = $env->getExtension('Twig_Extension_Core')->getTimezone();
393
-        } elseif (!$timezone instanceof DateTimeZone) {
394
-            $timezone = new DateTimeZone($timezone);
393
+        } elseif (!$timezone instanceof \DateTimeZone) {
394
+            $timezone = new \DateTimeZone($timezone);
395 395
         }
396 396
     }
397 397
 
398 398
     // immutable dates
399
-    if ($date instanceof DateTimeImmutable) {
399
+    if ($date instanceof \DateTimeImmutable) {
400 400
         return false !== $timezone ? $date->setTimezone($timezone) : $date;
401 401
     }
402 402
 
403
-    if ($date instanceof DateTimeInterface) {
403
+    if ($date instanceof \DateTimeInterface) {
404 404
         $date = clone $date;
405 405
         if (false !== $timezone) {
406 406
             $date->setTimezone($timezone);
... ...
@@ -410,14 +410,14 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
410 410
     }
411 411
 
412 412
     if (null === $date || 'now' === $date) {
413
-        return new DateTime($date, false !== $timezone ? $timezone : $env->getExtension('Twig_Extension_Core')->getTimezone());
413
+        return new \DateTime($date, false !== $timezone ? $timezone : $env->getExtension('Twig_Extension_Core')->getTimezone());
414 414
     }
415 415
 
416 416
     $asString = (string) $date;
417 417
     if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
418
-        $date = new DateTime('@'.$date);
418
+        $date = new \DateTime('@'.$date);
419 419
     } else {
420
-        $date = new DateTime($date, $env->getExtension('Twig_Extension_Core')->getTimezone());
420
+        $date = new \DateTime($date, $env->getExtension('Twig_Extension_Core')->getTimezone());
421 421
     }
422 422
 
423 423
     if (false !== $timezone) {
... ...
@@ -430,14 +430,14 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu
430 430
 /**
431 431
  * Replaces strings within a string.
432 432
  *
433
- * @param string            $str  String to replace in
434
- * @param array|Traversable $from Replace values
433
+ * @param string             $str  String to replace in
434
+ * @param array|\Traversable $from Replace values
435 435
  *
436 436
  * @return string
437 437
  */
438 438
 function twig_replace_filter($str, $from)
439 439
 {
440
-    if ($from instanceof Traversable) {
440
+    if ($from instanceof \Traversable) {
441 441
         $from = iterator_to_array($from);
442 442
     } elseif (!is_array($from)) {
443 443
         throw new Twig_Error_Runtime(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".', is_object($from) ? get_class($from) : gettype($from)));
... ...
@@ -475,10 +475,10 @@ function twig_round($value, $precision = 0, $method = 'common')
475 475
  * be used.  Supplying any of the parameters will override the defaults set in the
476 476
  * environment object.
477 477
  *
478
- * @param mixed            $number       A float/int/string of the number to format
479
- * @param int              $decimal      the number of decimal points to display
480
- * @param string           $decimalPoint the character(s) to use for the decimal point
481
- * @param string           $thousandSep  the character(s) to use for the thousands separator
478
+ * @param mixed  $number       A float/int/string of the number to format
479
+ * @param int    $decimal      the number of decimal points to display
480
+ * @param string $decimalPoint the character(s) to use for the decimal point
481
+ * @param string $thousandSep  the character(s) to use for the thousands separator
482 482
  *
483 483
  * @return string The formatted number
484 484
  */
... ...
@@ -525,20 +525,20 @@ function twig_urlencode_filter($url)
525 525
  *
526 526
  *  {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #}
527 527
  *
528
- * @param array|Traversable $arr1 An array
529
- * @param array|Traversable $arr2 An array
528
+ * @param array|\Traversable $arr1 An array
529
+ * @param array|\Traversable $arr2 An array
530 530
  *
531 531
  * @return array The merged array
532 532
  */
533 533
 function twig_array_merge($arr1, $arr2)
534 534
 {
535
-    if ($arr1 instanceof Traversable) {
535
+    if ($arr1 instanceof \Traversable) {
536 536
         $arr1 = iterator_to_array($arr1);
537 537
     } elseif (!is_array($arr1)) {
538 538
         throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', gettype($arr1)));
539 539
     }
540 540
 
541
-    if ($arr2 instanceof Traversable) {
541
+    if ($arr2 instanceof \Traversable) {
542 542
         $arr2 = iterator_to_array($arr2);
543 543
     } elseif (!is_array($arr2)) {
544 544
         throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', gettype($arr2)));
... ...
@@ -550,24 +550,24 @@ function twig_array_merge($arr1, $arr2)
550 550
 /**
551 551
  * Slices a variable.
552 552
  *
553
- * @param mixed            $item         A variable
554
- * @param int              $start        Start of the slice
555
- * @param int              $length       Size of the slice
556
- * @param bool             $preserveKeys Whether to preserve key or not (when the input is an array)
553
+ * @param mixed $item         A variable
554
+ * @param int   $start        Start of the slice
555
+ * @param int   $length       Size of the slice
556
+ * @param bool  $preserveKeys Whether to preserve key or not (when the input is an array)
557 557
  *
558 558
  * @return mixed The sliced variable
559 559
  */
560 560
 function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
561 561
 {
562
-    if ($item instanceof Traversable) {
563
-        while ($item instanceof IteratorAggregate) {
562
+    if ($item instanceof \Traversable) {
563
+        while ($item instanceof \IteratorAggregate) {
564 564
             $item = $item->getIterator();
565 565
         }
566 566
 
567
-        if ($start >= 0 && $length >= 0 && $item instanceof Iterator) {
567
+        if ($start >= 0 && $length >= 0 && $item instanceof \Iterator) {
568 568
             try {
569
-                return iterator_to_array(new LimitIterator($item, $start, null === $length ? -1 : $length), $preserveKeys);
570
-            } catch (OutOfBoundsException $exception) {
569
+                return iterator_to_array(new \LimitIterator($item, $start, null === $length ? -1 : $length), $preserveKeys);
570
+            } catch (\OutOfBoundsException $exception) {
571 571
                 return [];
572 572
             }
573 573
         }
... ...
@@ -587,7 +587,7 @@ function twig_slice(Twig_Environment $env, $item, $start, $length = null, $prese
587 587
 /**
588 588
  * Returns the first element of the item.
589 589
  *
590
- * @param mixed            $item A variable
590
+ * @param mixed $item A variable
591 591
  *
592 592
  * @return mixed The first element of the item
593 593
  */
... ...
@@ -601,7 +601,7 @@ function twig_first(Twig_Environment $env, $item)
601 601
 /**
602 602
  * Returns the last element of the item.
603 603
  *
604
- * @param mixed            $item A variable
604
+ * @param mixed $item A variable
605 605
  *
606 606
  * @return mixed The last element of the item
607 607
  */
... ...
@@ -634,7 +634,7 @@ function twig_last(Twig_Environment $env, $item)
634 634
  */
635 635
 function twig_join_filter($value, $glue = '', $and = null)
636 636
 {
637
-    if ($value instanceof Traversable) {
637
+    if ($value instanceof \Traversable) {
638 638
         $value = iterator_to_array($value, false);
639 639
     } else {
640 640
         $value = (array) $value;
... ...
@@ -671,9 +671,9 @@ function twig_join_filter($value, $glue = '', $and = null)
671 671
  *  {{ "aabbcc"|split('', 2) }}
672 672
  *  {# returns [aa, bb, cc] #}
673 673
  *
674
- * @param string           $value     A string
675
- * @param string           $delimiter The delimiter
676
- * @param int              $limit     The limit
674
+ * @param string $value     A string
675
+ * @param string $delimiter The delimiter
676
+ * @param int    $limit     The limit
677 677
  *
678 678
  * @return array The split string as an array
679 679
  */
... ...
@@ -730,12 +730,12 @@ function _twig_default_filter($value, $default = '')
730 730
  */
731 731
 function twig_get_array_keys_filter($array)
732 732
 {
733
-    if ($array instanceof Traversable) {
734
-        while ($array instanceof IteratorAggregate) {
733
+    if ($array instanceof \Traversable) {
734
+        while ($array instanceof \IteratorAggregate) {
735 735
             $array = $array->getIterator();
736 736
         }
737 737
 
738
-        if ($array instanceof Iterator) {
738
+        if ($array instanceof \Iterator) {
739 739
             $keys = [];
740 740
             $array->rewind();
741 741
             while ($array->valid()) {
... ...
@@ -764,14 +764,14 @@ function twig_get_array_keys_filter($array)
764 764
 /**
765 765
  * Reverses a variable.
766 766
  *
767
- * @param array|Traversable|string $item         An array, a Traversable instance, or a string
768
- * @param bool                     $preserveKeys Whether to preserve key or not
767
+ * @param array|\Traversable|string $item         An array, a \Traversable instance, or a string
768
+ * @param bool                      $preserveKeys Whether to preserve key or not
769 769
  *
770 770
  * @return mixed The reversed input
771 771
  */
772 772
 function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false)
773 773
 {
774
-    if ($item instanceof Traversable) {
774
+    if ($item instanceof \Traversable) {
775 775
         return array_reverse(iterator_to_array($item), $preserveKeys);
776 776
     }
777 777
 
... ...
@@ -801,13 +801,13 @@ function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false
801 801
 /**
802 802
  * Sorts an array.
803 803
  *
804
- * @param array|Traversable $array
804
+ * @param array|\Traversable $array
805 805
  *
806 806
  * @return array
807 807
  */
808 808
 function twig_sort_filter($array)
809 809
 {
810
-    if ($array instanceof Traversable) {
810
+    if ($array instanceof \Traversable) {
811 811
         $array = iterator_to_array($array);
812 812
     } elseif (!is_array($array)) {
813 813
         throw new Twig_Error_Runtime(sprintf('The sort filter only works with arrays or "Traversable", got "%s".', gettype($array)));
... ...
@@ -827,7 +827,7 @@ function twig_in_filter($value, $compare)
827 827
         return in_array($value, $compare, is_object($value) || is_resource($value));
828 828
     } elseif (is_string($compare) && (is_string($value) || is_int($value) || is_float($value))) {
829 829
         return '' === $value || false !== strpos($compare, (string) $value);
830
-    } elseif ($compare instanceof Traversable) {
830
+    } elseif ($compare instanceof \Traversable) {
831 831
         if (is_object($value) || is_resource($value)) {
832 832
             foreach ($compare as $item) {
833 833
                 if ($item === $value) {
... ...
@@ -876,10 +876,10 @@ function twig_trim_filter($string, $characterMask = null, $side = 'both')
876 876
 /**
877 877
  * Escapes a string.
878 878
  *
879
- * @param mixed            $string     The value to be escaped
880
- * @param string           $strategy   The escaping strategy
881
- * @param string           $charset    The charset
882
- * @param bool             $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
879
+ * @param mixed  $string     The value to be escaped
880
+ * @param string $strategy   The escaping strategy
881
+ * @param string $charset    The charset
882
+ * @param bool   $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
883 883
  *
884 884
  * @return string
885 885
  */
... ...
@@ -1125,7 +1125,7 @@ function twig_convert_encoding($string, $to, $from)
1125 1125
 /**
1126 1126
  * Returns the length of a variable.
1127 1127
  *
1128
- * @param mixed            $thing A variable
1128
+ * @param mixed $thing A variable
1129 1129
  *
1130 1130
  * @return int The length of the value
1131 1131
  */
... ...
@@ -1161,7 +1161,7 @@ function twig_length_filter(Twig_Environment $env, $thing)
1161 1161
 /**
1162 1162
  * Converts a string to uppercase.
1163 1163
  *
1164
- * @param string           $string A string
1164
+ * @param string $string A string
1165 1165
  *
1166 1166
  * @return string The uppercased string
1167 1167
  */
... ...
@@ -1173,7 +1173,7 @@ function twig_upper_filter(Twig_Environment $env, $string)
1173 1173
 /**
1174 1174
  * Converts a string to lowercase.
1175 1175
  *
1176
- * @param string           $string A string
1176
+ * @param string $string A string
1177 1177
  *
1178 1178
  * @return string The lowercased string
1179 1179
  */
... ...
@@ -1185,7 +1185,7 @@ function twig_lower_filter(Twig_Environment $env, $string)
1185 1185
 /**
1186 1186
  * Returns a titlecased string.
1187 1187
  *
1188
- * @param string           $string A string
1188
+ * @param string $string A string
1189 1189
  *
1190 1190
  * @return string The titlecased string
1191 1191
  */
... ...
@@ -1201,7 +1201,7 @@ function twig_title_string_filter(Twig_Environment $env, $string)
1201 1201
 /**
1202 1202
  * Returns a capitalized string.
1203 1203
  *
1204
- * @param string           $string A string
1204
+ * @param string $string A string
1205 1205
  *
1206 1206
  * @return string The capitalized string
1207 1207
  */
... ...
@@ -1217,7 +1217,7 @@ function twig_capitalize_string_filter(Twig_Environment $env, $string)
1217 1217
  */
1218 1218
 function twig_ensure_traversable($seq)
1219 1219
 {
1220
-    if ($seq instanceof Traversable || is_array($seq)) {
1220
+    if ($seq instanceof \Traversable || is_array($seq)) {
1221 1221
         return $seq;
1222 1222
     }
1223 1223
 
... ...
@@ -1238,7 +1238,7 @@ function twig_ensure_traversable($seq)
1238 1238
  */
1239 1239
 function twig_test_empty($value)
1240 1240
 {
1241
-    if ($value instanceof Countable) {
1241
+    if ($value instanceof \Countable) {
1242 1242
         return 0 == count($value);
1243 1243
     }
1244 1244
 
... ...
@@ -1263,18 +1263,18 @@ function twig_test_empty($value)
1263 1263
  */
1264 1264
 function twig_test_iterable($value)
1265 1265
 {
1266
-    return $value instanceof Traversable || is_array($value);
1266
+    return $value instanceof \Traversable || is_array($value);
1267 1267
 }
1268 1268
 
1269 1269
 /**
1270 1270
  * Renders a template.
1271 1271
  *
1272
- * @param array            $context
1273
- * @param string|array     $template      The template to render or an array of templates to try consecutively
1274
- * @param array            $variables     The variables to pass to the template
1275
- * @param bool             $withContext
1276
- * @param bool             $ignoreMissing Whether to ignore missing templates or not
1277
- * @param bool             $sandboxed     Whether to sandbox the template or not
1272
+ * @param array        $context
1273
+ * @param string|array $template      The template to render or an array of templates to try consecutively
1274
+ * @param array        $variables     The variables to pass to the template
1275
+ * @param bool         $withContext
1276
+ * @param bool         $ignoreMissing Whether to ignore missing templates or not
1277
+ * @param bool         $sandboxed     Whether to sandbox the template or not
1278 1278
  *
1279 1279
  * @return string The rendered template
1280 1280
  */
... ...
@@ -1304,7 +1304,7 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = [
1304 1304
 
1305 1305
             throw $e;
1306 1306
         }
1307
-    } catch (Throwable $e) {
1307
+    } catch (\Throwable $e) {
1308 1308
         if ($isSandboxed && !$alreadySandboxed) {
1309 1309
             $sandbox->disableSandbox();
1310 1310
         }
... ...
@@ -1322,8 +1322,8 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = [
1322 1322
 /**
1323 1323
  * Returns a template content without rendering it.
1324 1324
  *
1325
- * @param string           $name          The template name
1326
- * @param bool             $ignoreMissing Whether to ignore missing templates or not
1325
+ * @param string $name          The template name
1326
+ * @param bool   $ignoreMissing Whether to ignore missing templates or not
1327 1327
  *
1328 1328
  * @return string The template source
1329 1329
  */
... ...
@@ -1384,7 +1384,7 @@ function twig_constant_is_defined($constant, $object = null)
1384 1384
  */
1385 1385
 function twig_array_batch($items, $size, $fill = null)
1386 1386
 {
1387
-    if ($items instanceof Traversable) {
1387
+    if ($items instanceof \Traversable) {
1388 1388
         $items = iterator_to_array($items, false);
1389 1389
     }
1390 1390
 
... ...
@@ -1427,7 +1427,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object,
1427 1427
     if (/* Twig_Template::METHOD_CALL */ 'method' !== $type) {
1428 1428
         $arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
1429 1429
 
1430
-        if (((is_array($object) || $object instanceof ArrayObject) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
1430
+        if (((is_array($object) || $object instanceof \ArrayObject) && (isset($object[$arrayItem]) || array_key_exists($arrayItem, $object)))
1431 1431
             || ($object instanceof ArrayAccess && isset($object[$arrayItem]))
1432 1432
         ) {
1433 1433
             if ($isDefinedTest) {
... ...
@@ -1588,7 +1588,7 @@ function twig_get_attribute(Twig_Environment $env, Twig_Source $source, $object,
1588 1588
     // to call is not supported. If ignoreStrictCheck is true, we should return null.
1589 1589
     try {
1590 1590
         $ret = $object->$method(...$arguments);
1591
-    } catch (BadMethodCallException $e) {
1591
+    } catch (\BadMethodCallException $e) {
1592 1592
         if ($call && ($ignoreStrictCheck || !$env->isStrictVariables())) {
1593 1593
             return;
1594 1594
         }
... ...
@@ -27,7 +27,7 @@ final class Twig_Extension_Staging extends Twig_Extension
27 27
     public function addFunction(Twig_Function $function)
28 28
     {
29 29
         if (isset($this->functions[$function->getName()])) {
30
-            throw new LogicException(sprintf('Function "%s" is already registered.', $function->getName()));
30
+            throw new \LogicException(sprintf('Function "%s" is already registered.', $function->getName()));
31 31
         }
32 32
 
33 33
         $this->functions[$function->getName()] = $function;
... ...
@@ -41,7 +41,7 @@ final class Twig_Extension_Staging extends Twig_Extension
41 41
     public function addFilter(Twig_Filter $filter)
42 42
     {
43 43
         if (isset($this->filters[$filter->getName()])) {
44
-            throw new LogicException(sprintf('Filter "%s" is already registered.', $filter->getName()));
44
+            throw new \LogicException(sprintf('Filter "%s" is already registered.', $filter->getName()));
45 45
         }
46 46
 
47 47
         $this->filters[$filter->getName()] = $filter;
... ...
@@ -65,7 +65,7 @@ final class Twig_Extension_Staging extends Twig_Extension
65 65
     public function addTokenParser(Twig_TokenParserInterface $parser)
66 66
     {
67 67
         if (isset($this->tokenParsers[$parser->getTag()])) {
68
-            throw new LogicException(sprintf('Tag "%s" is already registered.', $parser->getTag()));
68
+            throw new \LogicException(sprintf('Tag "%s" is already registered.', $parser->getTag()));
69 69
         }
70 70
 
71 71
         $this->tokenParsers[$parser->getTag()] = $parser;
... ...
@@ -79,7 +79,7 @@ final class Twig_Extension_Staging extends Twig_Extension
79 79
     public function addTest(Twig_Test $test)
80 80
     {
81 81
         if (isset($this->tests[$test->getName()])) {
82
-            throw new LogicException(sprintf('Test "%s" is already registered.', $test->getTag()));
82
+            throw new \LogicException(sprintf('Test "%s" is already registered.', $test->getTag()));
83 83
         }
84 84
 
85 85
         $this->tests[$test->getName()] = $test;
... ...
@@ -67,7 +67,7 @@ final class Twig_ExtensionSet
67 67
         $class = ltrim($class, '\\');
68 68
         if (!isset($this->extensions[$class]) && class_exists($class, false)) {
69 69
             // For BC/FC with namespaced aliases
70
-            $class = (new ReflectionClass($class))->name;
70
+            $class = (new \ReflectionClass($class))->name;
71 71
         }
72 72
 
73 73
         return isset($this->extensions[$class]);
... ...
@@ -85,7 +85,7 @@ final class Twig_ExtensionSet
85 85
         $class = ltrim($class, '\\');
86 86
         if (!isset($this->extensions[$class]) && class_exists($class, false)) {
87 87
             // For BC/FC with namespaced aliases
88
-            $class = (new ReflectionClass($class))->name;
88
+            $class = (new \ReflectionClass($class))->name;
89 89
         }
90 90
 
91 91
         if (!isset($this->extensions[$class])) {
... ...
@@ -134,7 +134,7 @@ final class Twig_ExtensionSet
134 134
         }
135 135
 
136 136
         foreach ($this->extensions as $extension) {
137
-            $r = new ReflectionObject($extension);
137
+            $r = new \ReflectionObject($extension);
138 138
             if (file_exists($r->getFileName()) && ($extensionTime = filemtime($r->getFileName())) > $this->lastModified) {
139 139
                 $this->lastModified = $extensionTime;
140 140
             }
... ...
@@ -148,22 +148,22 @@ final class Twig_ExtensionSet
148 148
         $class = get_class($extension);
149 149
 
150 150
         if ($this->initialized) {
151
-            throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $class));
151
+            throw new \LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $class));
152 152
         }
153 153
 
154 154
         if (isset($this->extensions[$class])) {
155
-            throw new LogicException(sprintf('Unable to register extension "%s" as it is already registered.', $class));
155
+            throw new \LogicException(sprintf('Unable to register extension "%s" as it is already registered.', $class));
156 156
         }
157 157
 
158 158
         // For BC/FC with namespaced aliases
159
-        $class = (new ReflectionClass($class))->name;
159
+        $class = (new \ReflectionClass($class))->name;
160 160
         $this->extensions[$class] = $extension;
161 161
     }
162 162
 
163 163
     public function addFunction(Twig_Function $function)
164 164
     {
165 165
         if ($this->initialized) {
166
-            throw new LogicException(sprintf('Unable to add function "%s" as extensions have already been initialized.', $function->getName()));
166
+            throw new \LogicException(sprintf('Unable to add function "%s" as extensions have already been initialized.', $function->getName()));
167 167
         }
168 168
 
169 169
         $this->staging->addFunction($function);
... ...
@@ -223,7 +223,7 @@ final class Twig_ExtensionSet
223 223
     public function addFilter(Twig_Filter $filter)
224 224
     {
225 225
         if ($this->initialized) {
226
-            throw new LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $filter->getName()));
226
+            throw new \LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $filter->getName()));
227 227
         }
228 228
 
229 229
         $this->staging->addFilter($filter);
... ...
@@ -286,7 +286,7 @@ final class Twig_ExtensionSet
286 286
     public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
287 287
     {
288 288
         if ($this->initialized) {
289
-            throw new LogicException('Unable to add a node visitor as extensions have already been initialized.');
289
+            throw new \LogicException('Unable to add a node visitor as extensions have already been initialized.');
290 290
         }
291 291
 
292 292
         $this->staging->addNodeVisitor($visitor);
... ...
@@ -304,7 +304,7 @@ final class Twig_ExtensionSet
304 304
     public function addTokenParser(Twig_TokenParserInterface $parser)
305 305
     {
306 306
         if ($this->initialized) {
307
-            throw new LogicException('Unable to add a token parser as extensions have already been initialized.');
307
+            throw new \LogicException('Unable to add a token parser as extensions have already been initialized.');
308 308
         }
309 309
 
310 310
         $this->staging->addTokenParser($parser);
... ...
@@ -333,7 +333,7 @@ final class Twig_ExtensionSet
333 333
 
334 334
             $extGlobals = $extension->getGlobals();
335 335
             if (!is_array($extGlobals)) {
336
-                throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
336
+                throw new \UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
337 337
             }
338 338
 
339 339
             $globals = array_merge($globals, $extGlobals);
... ...
@@ -349,7 +349,7 @@ final class Twig_ExtensionSet
349 349
     public function addTest(Twig_Test $test)
350 350
     {
351 351
         if ($this->initialized) {
352
-            throw new LogicException(sprintf('Unable to add test "%s" as extensions have already been initialized.', $test->getName()));
352
+            throw new \LogicException(sprintf('Unable to add test "%s" as extensions have already been initialized.', $test->getName()));
353 353
         }
354 354
 
355 355
         $this->staging->addTest($test);
... ...
@@ -463,7 +463,7 @@ final class Twig_ExtensionSet
463 463
         // token parsers
464 464
         foreach ($extension->getTokenParsers() as $parser) {
465 465
             if (!$parser instanceof Twig_TokenParserInterface) {
466
-                throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface.');
466
+                throw new \LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface.');
467 467
             }
468 468
 
469 469
             $this->parsers[] = $parser;
... ...
@@ -477,11 +477,11 @@ final class Twig_ExtensionSet
477 477
         // operators
478 478
         if ($operators = $extension->getOperators()) {
479 479
             if (!is_array($operators)) {
480
-                throw new InvalidArgumentException(sprintf('"%s::getOperators()" must return an array with operators, got "%s".', get_class($extension), is_object($operators) ? get_class($operators) : gettype($operators).(is_resource($operators) ? '' : '#'.$operators)));
480
+                throw new \InvalidArgumentException(sprintf('"%s::getOperators()" must return an array with operators, got "%s".', get_class($extension), is_object($operators) ? get_class($operators) : gettype($operators).(is_resource($operators) ? '' : '#'.$operators)));
481 481
             }
482 482
 
483 483
             if (2 !== count($operators)) {
484
-                throw new InvalidArgumentException(sprintf('"%s::getOperators()" must return an array of 2 elements, got %d.', get_class($extension), count($operators)));
484
+                throw new \InvalidArgumentException(sprintf('"%s::getOperators()" must return an array of 2 elements, got %d.', get_class($extension), count($operators)));
485 485
             }
486 486
 
487 487
             $this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
... ...
@@ -388,7 +388,7 @@ class Twig_Lexer
388 388
     private function popState()
389 389
     {
390 390
         if (0 === count($this->states)) {
391
-            throw new LogicException('Cannot pop state without a previous state.');
391
+            throw new \LogicException('Cannot pop state without a previous state.');
392 392
         }
393 393
 
394 394
         $this->state = array_pop($this->states);
... ...
@@ -14,7 +14,7 @@
14 14
  *
15 15
  * @author Fabien Potencier <fabien@symfony.com>
16 16
  */
17
-class Twig_Markup implements Countable, JsonSerializable
17
+class Twig_Markup implements \Countable, JsonSerializable
18 18
 {
19 19
     private $content;
20 20
     private $charset;
... ...
@@ -15,7 +15,7 @@
15 15
  *
16 16
  * @author Fabien Potencier <fabien@symfony.com>
17 17
  */
18
-class Twig_Node implements Countable, IteratorAggregate
18
+class Twig_Node implements \Countable, \IteratorAggregate
19 19
 {
20 20
     protected $nodes;
21 21
     protected $attributes;
... ...
@@ -39,7 +39,7 @@ class Twig_Node implements Countable, IteratorAggregate
39 39
     {
40 40
         foreach ($nodes as $name => $node) {
41 41
             if (!$node instanceof self) {
42
-                throw new InvalidArgumentException(sprintf('Using "%s" for the value of node "%s" of "%s" is not supported. You must pass a Twig_Node instance.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)));
42
+                throw new \InvalidArgumentException(sprintf('Using "%s" for the value of node "%s" of "%s" is not supported. You must pass a Twig_Node instance.', is_object($node) ? get_class($node) : null === $node ? 'null' : gettype($node), $name, get_class($this)));
43 43
             }
44 44
         }
45 45
         $this->nodes = $nodes;
... ...
@@ -107,7 +107,7 @@ class Twig_Node implements Countable, IteratorAggregate
107 107
     public function getAttribute($name)
108 108
     {
109 109
         if (!array_key_exists($name, $this->attributes)) {
110
-            throw new LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this)));
110
+            throw new \LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this)));
111 111
         }
112 112
 
113 113
         return $this->attributes[$name];
... ...
@@ -141,7 +141,7 @@ class Twig_Node implements Countable, IteratorAggregate
141 141
     public function getNode($name)
142 142
     {
143 143
         if (!isset($this->nodes[$name])) {
144
-            throw new LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this)));
144
+            throw new \LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this)));
145 145
         }
146 146
 
147 147
         return $this->nodes[$name];
... ...
@@ -164,7 +164,7 @@ class Twig_Node implements Countable, IteratorAggregate
164 164
 
165 165
     public function getIterator()
166 166
     {
167
-        return new ArrayIterator($this->nodes);
167
+        return new \ArrayIterator($this->nodes);
168 168
     }
169 169
 
170 170
     public function setTemplateName($name)
... ...
@@ -22,15 +22,15 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
22 22
             $compiler->raw($callable);
23 23
         } else {
24 24
             list($r, $callable) = $this->reflectCallable($callable);
25
-            if ($r instanceof ReflectionMethod && is_string($callable[0])) {
25
+            if ($r instanceof \ReflectionMethod && is_string($callable[0])) {
26 26
                 if ($r->isStatic()) {
27 27
                     $compiler->raw(sprintf('%s::%s', $callable[0], $callable[1]));
28 28
                 } else {
29 29
                     $compiler->raw(sprintf('$this->env->getRuntime(\'%s\')->%s', $callable[0], $callable[1]));
30 30
                 }
31
-            } elseif ($r instanceof ReflectionMethod && $callable[0] instanceof Twig_ExtensionInterface) {
31
+            } elseif ($r instanceof \ReflectionMethod && $callable[0] instanceof Twig_ExtensionInterface) {
32 32
                 // For BC/FC with namespaced aliases
33
-                $class = (new ReflectionClass(get_class($callable[0])))->name;
33
+                $class = (new \ReflectionClass(get_class($callable[0])))->name;
34 34
                 if (!$compiler->getEnvironment()->hasExtension($class)) {
35 35
                     // Compile a non-optimized call to trigger a Twig_Error_Runtime, which cannot be a compile-time error
36 36
                     $compiler->raw(sprintf('$this->env->getExtension(\'%s\')', $class));
... ...
@@ -135,7 +135,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
135 135
                 $message = sprintf('Arbitrary positional arguments are not supported for %s "%s".', $callType, $callName);
136 136
             }
137 137
 
138
-            throw new LogicException($message);
138
+            throw new \LogicException($message);
139 139
         }
140 140
 
141 141
         $callableParameters = $this->getCallableParameters($callable, $isVariadic);
... ...
@@ -250,11 +250,11 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
250 250
                 array_pop($parameters);
251 251
             } else {
252 252
                 $callableName = $r->name;
253
-                if ($r instanceof ReflectionMethod) {
253
+                if ($r instanceof \ReflectionMethod) {
254 254
                     $callableName = $r->getDeclaringClass()->name.'::'.$callableName;
255 255
                 }
256 256
 
257
-                throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = []".', $callableName, $this->getAttribute('type'), $this->getAttribute('name')));
257
+                throw new \LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = []".', $callableName, $this->getAttribute('type'), $this->getAttribute('name')));
258 258
             }
259 259
         }
260 260
 
... ...
@@ -272,9 +272,9 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
272 272
                 // __call()
273 273
                 return [null, []];
274 274
             }
275
-            $r = new ReflectionMethod($callable[0], $callable[1]);
275
+            $r = new \ReflectionMethod($callable[0], $callable[1]);
276 276
         } elseif (is_object($callable) && !$callable instanceof Closure) {
277
-            $r = new ReflectionObject($callable);
277
+            $r = new \ReflectionObject($callable);
278 278
             $r = $r->getMethod('__invoke');
279 279
             $callable = [$callable, '__invoke'];
280 280
         } elseif (is_string($callable) && false !== $pos = strpos($callable, '::')) {
... ...
@@ -284,10 +284,10 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
284 284
                 // __staticCall()
285 285
                 return [null, []];
286 286
             }
287
-            $r = new ReflectionMethod($callable);
287
+            $r = new \ReflectionMethod($callable);
288 288
             $callable = [$class, $method];
289 289
         } else {
290
-            $r = new ReflectionFunction($callable);
290
+            $r = new \ReflectionFunction($callable);
291 291
         }
292 292
 
293 293
         return $this->reflector = [$r, $callable];
... ...
@@ -181,7 +181,7 @@ abstract class Twig_Template
181 181
 
182 182
         // avoid RCEs when sandbox is enabled
183 183
         if (null !== $template && !$template instanceof self) {
184
-            throw new LogicException('A block must be a method on a Twig_Template instance.');
184
+            throw new \LogicException('A block must be a method on a Twig_Template instance.');
185 185
         }
186 186
 
187 187
         if (null !== $template) {
... ...
@@ -200,7 +200,7 @@ abstract class Twig_Template
200 200
                 }
201 201
 
202 202
                 throw $e;
203
-            } catch (Exception $e) {
203
+            } catch (\Exception $e) {
204 204
                 throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getSourceContext(), $e);
205 205
             }
206 206
         } elseif (false !== $parent = $this->getParent($context)) {
... ...
@@ -369,7 +369,7 @@ abstract class Twig_Template
369 369
         ob_start();
370 370
         try {
371 371
             $this->display($context);
372
-        } catch (Throwable $e) {
372
+        } catch (\Throwable $e) {
373 373
             while (ob_get_level() > $level) {
374 374
                 ob_end_clean();
375 375
             }
... ...
@@ -397,7 +397,7 @@ abstract class Twig_Template
397 397
             }
398 398
 
399 399
             throw $e;
400
-        } catch (Exception $e) {
400
+        } catch (\Exception $e) {
401 401
             throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getSourceContext(), $e);
402 402
         }
403 403
     }
... ...
@@ -97,7 +97,7 @@ final class Twig_TemplateWrapper
97 97
         ob_start();
98 98
         try {
99 99
             $this->template->displayBlock($name, $context);
100
-        } catch (Throwable $e) {
100
+        } catch (\Throwable $e) {
101 101
             while (ob_get_level() > $level) {
102 102
                 ob_end_clean();
103 103
             }
... ...
@@ -86,7 +86,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
86 86
         $fixturesDir = realpath($this->getFixturesDir());
87 87
         $tests = [];
88 88
 
89
-        foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
89
+        foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($fixturesDir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
90 90
             if (!preg_match('/\.test$/', $file)) {
91 91
                 continue;
92 92
             }
... ...
@@ -112,7 +112,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
112 112
                 $exception = false;
113 113
                 preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER);
114 114
             } else {
115
-                throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file)));
115
+                throw new \InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file)));
116 116
             }
117 117
 
118 118
             $tests[] = [str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs, $deprecation];
... ...
@@ -174,7 +174,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
174 174
             }
175 175
 
176 176
             // avoid using the same PHP class name for different cases
177
-            $p = new ReflectionProperty($twig, 'templateClassPrefix');
177
+            $p = new \ReflectionProperty($twig, 'templateClassPrefix');
178 178
             $p->setAccessible(true);
179 179
             $p->setValue($twig, '__TwigTemplate_'.hash('sha256', uniqid(mt_rand(), true), false).'_');
180 180
 
... ...
@@ -191,7 +191,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
191 191
                 });
192 192
 
193 193
                 $template = $twig->loadTemplate('index.twig');
194
-            } catch (Exception $e) {
194
+            } catch (\Exception $e) {
195 195
                 if (false !== $exception) {
196 196
                     $message = $e->getMessage();
197 197
                     $this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $message)));
... ...
@@ -210,7 +210,7 @@ abstract class Twig_Test_IntegrationTestCase extends TestCase
210 210
 
211 211
             try {
212 212
                 $output = trim($template->render(eval($match[1].';')), "\n ");
213
-            } catch (Exception $e) {
213
+            } catch (\Exception $e) {
214 214
                 if (false !== $exception) {
215 215
                     $this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage())));
216 216
 
... ...
@@ -89,7 +89,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
89 89
         try {
90 90
             $twig->addGlobal('bar', 'bar');
91 91
             $this->fail();
92
-        } catch (LogicException $e) {
92
+        } catch (\LogicException $e) {
93 93
             $this->assertArrayNotHasKey('bar', $twig->getGlobals());
94 94
         }
95 95
 
... ...
@@ -101,7 +101,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
101 101
         try {
102 102
             $twig->addGlobal('bar', 'bar');
103 103
             $this->fail();
104
-        } catch (LogicException $e) {
104
+        } catch (\LogicException $e) {
105 105
             $this->assertArrayNotHasKey('bar', $twig->getGlobals());
106 106
         }
107 107
 
... ...
@@ -114,7 +114,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
114 114
         try {
115 115
             $twig->addGlobal('bar', 'bar');
116 116
             $this->fail();
117
-        } catch (LogicException $e) {
117
+        } catch (\LogicException $e) {
118 118
             $this->assertArrayNotHasKey('bar', $twig->getGlobals());
119 119
         }
120 120
 
... ...
@@ -124,7 +124,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
124 124
         try {
125 125
             $twig->addGlobal('bar', 'bar');
126 126
             $this->fail();
127
-        } catch (LogicException $e) {
127
+        } catch (\LogicException $e) {
128 128
             $this->assertArrayNotHasKey('bar', $twig->getGlobals());
129 129
         }
130 130
     }
... ...
@@ -296,7 +296,7 @@ final class CoreTestIteratorAggregateAggregate implements \IteratorAggregate
296 296
     }
297 297
 }
298 298
 
299
-final class CoreTestIterator implements Iterator
299
+final class CoreTestIterator implements \Iterator
300 300
 {
301 301
     private $position;
302 302
     private $array;
... ...
@@ -268,7 +268,7 @@ EOF
268 268
         $e = null;
269 269
         try {
270 270
             $twig->loadTemplate('1_include')->render(self::$params);
271
-        } catch (Throwable $e) {
271
+        } catch (\Throwable $e) {
272 272
         }
273 273
         if (null === $e) {
274 274
             $this->fail('An exception should be thrown for this test to be valid.');
... ...
@@ -13,7 +13,7 @@ class Twig_Tests_FilesystemHelper
13 13
 {
14 14
     public static function removeDir($dir)
15 15
     {
16
-        $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
16
+        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
17 17
         foreach ($iterator as $filename => $fileInfo) {
18 18
             if ($fileInfo->isDir()) {
19 19
                 rmdir($filename);
... ...
@@ -46,7 +46,7 @@ Twig supports array notation
46 46
 {{ does_not_exist[0].does_not_exist_either|default('ok') }}
47 47
 {{ does_not_exist[0]['does_not_exist_either']|default('ok') }}
48 48
 --DATA--
49
-return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new ArrayObject(['a' => 'b'])]
49
+return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new \ArrayObject(['a' => 'b'])]
50 50
 --EXPECT--
51 51
 1,2
52 52
 foo,bar
... ...
@@ -74,7 +74,7 @@ ok
74 74
 ok
75 75
 ok
76 76
 --DATA--
77
-return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new ArrayObject(['a' =>  'b'])]
77
+return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'array_access' => new \ArrayObject(['a' =>  'b'])]
78 78
 --CONFIG--
79 79
 return ['strict_variables' => false]
80 80
 --EXPECT--
... ...
@@ -16,7 +16,7 @@
16 16
   * {{ key }}
17 17
 {% endfor %}
18 18
 --DATA--
19
-class ItemsIterator implements Iterator
19
+class ItemsIterator implements \Iterator
20 20
 {
21 21
   protected $values = ['foo' => 'bar', 'bar' => 'foo'];
22 22
   public function current() { return current($this->values); }
... ...
@@ -17,7 +17,7 @@
17 17
   * {{ key }}
18 18
 {% endfor %}
19 19
 --DATA--
20
-class ItemsIteratorCountable implements Iterator, \Countable
20
+class ItemsIteratorCountable implements \Iterator, \Countable
21 21
 {
22 22
   protected $values = ['foo' => 'bar', 'bar' => 'foo'];
23 23
   public function current() { return current($this->values); }
... ...
@@ -74,7 +74,7 @@ TRUE
74 74
 {{ 5.5 in '125.5' ? 'TRUE' : 'FALSE' }}
75 75
 {{ '5.5' in 125.5 ? 'TRUE' : 'FALSE' }}
76 76
 --DATA--
77
-return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'dir_object' => new SplFileInfo(__DIR__), 'object' => new stdClass(), 'resource' => opendir(__DIR__)]
77
+return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'dir_object' => new \SplFileInfo(__DIR__), 'object' => new \stdClass(), 'resource' => opendir(__DIR__)]
78 78
 --EXPECT--
79 79
 TRUE
80 80
 TRUE
... ...
@@ -41,7 +41,7 @@ function test_foo($value = 'foo')
41 41
     return $value;
42 42
 }
43 43
 
44
-class TwigTestFoo implements Iterator
44
+class TwigTestFoo implements \Iterator
45 45
 {
46 46
     const BAR_NAME = 'bar';
47 47
 
... ...
@@ -100,7 +100,7 @@ class Twig_Tests_Node_Expression_CallTest extends \PHPUnit\Framework\TestCase
100 100
 
101 101
     private function getArguments($call, $args)
102 102
     {
103
-        $m = new ReflectionMethod($call, 'getArguments');
103
+        $m = new \ReflectionMethod($call, 'getArguments');
104 104
         $m->setAccessible(true);
105 105
 
106 106
         return $m->invokeArgs($call, $args);
... ...
@@ -48,7 +48,7 @@ class Twig_Tests_ParserTest extends \PHPUnit\Framework\TestCase
48 48
     public function testFilterBodyNodes($input, $expected)
49 49
     {
50 50
         $parser = $this->getParser();
51
-        $m = new ReflectionMethod($parser, 'filterBodyNodes');
51
+        $m = new \ReflectionMethod($parser, 'filterBodyNodes');
52 52
         $m->setAccessible(true);
53 53
 
54 54
         $this->assertEquals($expected, $m->invoke($parser, $input));
... ...
@@ -80,7 +80,7 @@ class Twig_Tests_ParserTest extends \PHPUnit\Framework\TestCase
80 80
     {
81 81
         $parser = $this->getParser();
82 82
 
83
-        $m = new ReflectionMethod($parser, 'filterBodyNodes');
83
+        $m = new \ReflectionMethod($parser, 'filterBodyNodes');
84 84
         $m->setAccessible(true);
85 85
 
86 86
         $m->invoke($parser, $input);
... ...
@@ -101,7 +101,7 @@ class Twig_Tests_ParserTest extends \PHPUnit\Framework\TestCase
101 101
     {
102 102
         $parser = $this->getParser();
103 103
 
104
-        $m = new ReflectionMethod($parser, 'filterBodyNodes');
104
+        $m = new \ReflectionMethod($parser, 'filterBodyNodes');
105 105
         $m->setAccessible(true);
106 106
         $this->assertNull($m->invoke($parser, new Twig_Node_Text(chr(0xEF).chr(0xBB).chr(0xBF).$emptyNode, 1)));
107 107
     }
... ...
@@ -166,7 +166,7 @@ EOF
166 166
         $parser = new Twig_Parser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
167 167
         $parser->setParent(new Twig_Node());
168 168
 
169
-        $p = new ReflectionProperty($parser, 'stream');
169
+        $p = new \ReflectionProperty($parser, 'stream');
170 170
         $p->setAccessible(true);
171 171
         $p->setValue($parser, new Twig_TokenStream([]));
172 172