From 5e119b7df5e4db6fcd0570ea20f28e2bc57c3da2 Mon Sep 17 00:00:00 2001
From: Nicolas Grekas <nicolas.grekas@gmail.com>
Date: Wed, 2 Sep 2020 18:06:40 +0200
Subject: [PATCH] Enable "native_constant_invocation" CS rule

---
 ApcClassLoader.php           |  2 +-
 ClassCollectionLoader.php    | 14 +++++++-------
 ClassLoader.php              |  2 +-
 ClassMapGenerator.php        | 22 +++++++++++-----------
 MapClassLoader.php           |  2 +-
 Psr4ClassLoader.php          |  2 +-
 Tests/ApcClassLoaderTest.php |  4 ++--
 Tests/ClassLoaderTest.php    |  2 +-
 WinCacheClassLoader.php      |  2 +-
 XcacheClassLoader.php        |  2 +-
 10 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/ApcClassLoader.php b/ApcClassLoader.php
index 57d22bf..54d6861 100644
--- a/ApcClassLoader.php
+++ b/ApcClassLoader.php
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\ClassLoader;
 
-@trigger_error('The '.__NAMESPACE__.'\ApcClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED);
+@trigger_error('The '.__NAMESPACE__.'\ApcClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', \E_USER_DEPRECATED);
 
 /**
  * ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3.
diff --git a/ClassCollectionLoader.php b/ClassCollectionLoader.php
index 3ed8cd9..db04ea5 100644
--- a/ClassCollectionLoader.php
+++ b/ClassCollectionLoader.php
@@ -12,7 +12,7 @@
 namespace Symfony\Component\ClassLoader;
 
 if (\PHP_VERSION_ID >= 70000) {
-    @trigger_error('The '.__NAMESPACE__.'\ClassCollectionLoader class is deprecated since Symfony 3.3 and will be removed in 4.0.', E_USER_DEPRECATED);
+    @trigger_error('The '.__NAMESPACE__.'\ClassCollectionLoader class is deprecated since Symfony 3.3 and will be removed in 4.0.', \E_USER_DEPRECATED);
 }
 
 /**
@@ -216,7 +216,7 @@ public static function fixNamespaceDeclarations($source)
         $inNamespace = false;
         $tokens = token_get_all($source);
 
-        $nsTokens = [T_WHITESPACE => true, T_NS_SEPARATOR => true, T_STRING => true];
+        $nsTokens = [\T_WHITESPACE => true, \T_NS_SEPARATOR => true, \T_STRING => true];
         if (\defined('T_NAME_QUALIFIED')) {
             $nsTokens[T_NAME_QUALIFIED] = true;
         }
@@ -225,10 +225,10 @@ public static function fixNamespaceDeclarations($source)
             $token = $tokens[$i];
             if (!isset($token[1]) || 'b"' === $token) {
                 $rawChunk .= $token;
-            } elseif (\in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
+            } elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) {
                 // strip comments
                 continue;
-            } elseif (T_NAMESPACE === $token[0]) {
+            } elseif (\T_NAMESPACE === $token[0]) {
                 if ($inNamespace) {
                     $rawChunk .= "}\n";
                 }
@@ -245,15 +245,15 @@ public static function fixNamespaceDeclarations($source)
                     $rawChunk = rtrim($rawChunk)."\n{";
                     $inNamespace = true;
                 }
-            } elseif (T_START_HEREDOC === $token[0]) {
+            } elseif (\T_START_HEREDOC === $token[0]) {
                 $output .= self::compressCode($rawChunk).$token[1];
                 do {
                     $token = $tokens[++$i];
                     $output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
-                } while (T_END_HEREDOC !== $token[0]);
+                } while (\T_END_HEREDOC !== $token[0]);
                 $output .= "\n";
                 $rawChunk = '';
-            } elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {
+            } elseif (\T_CONSTANT_ENCAPSED_STRING === $token[0]) {
                 $output .= self::compressCode($rawChunk).$token[1];
                 $rawChunk = '';
             } else {
diff --git a/ClassLoader.php b/ClassLoader.php
index 277aa52..349c4a9 100644
--- a/ClassLoader.php
+++ b/ClassLoader.php
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\ClassLoader;
 
-@trigger_error('The '.__NAMESPACE__.'\ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
+@trigger_error('The '.__NAMESPACE__.'\ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', \E_USER_DEPRECATED);
 
 /**
  * ClassLoader implements an PSR-0 class loader.
diff --git a/ClassMapGenerator.php b/ClassMapGenerator.php
index eb0bb10..740d37e 100644
--- a/ClassMapGenerator.php
+++ b/ClassMapGenerator.php
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\ClassLoader;
 
-@trigger_error('The '.__NAMESPACE__.'\ClassMapGenerator class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
+@trigger_error('The '.__NAMESPACE__.'\ClassMapGenerator class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', \E_USER_DEPRECATED);
 
 /**
  * ClassMapGenerator.
@@ -62,7 +62,7 @@ public static function createMap($dir)
 
             $path = $file->getRealPath() ?: $file->getPathname();
 
-            if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) {
+            if ('php' !== pathinfo($path, \PATHINFO_EXTENSION)) {
                 continue;
             }
 
@@ -93,7 +93,7 @@ private static function findClasses($path)
         $contents = file_get_contents($path);
         $tokens = token_get_all($contents);
 
-        $nsTokens = [T_STRING => true, T_NS_SEPARATOR => true];
+        $nsTokens = [\T_STRING => true, \T_NS_SEPARATOR => true];
         if (\defined('T_NAME_QUALIFIED')) {
             $nsTokens[T_NAME_QUALIFIED] = true;
         }
@@ -111,7 +111,7 @@ private static function findClasses($path)
             $class = '';
 
             switch ($token[0]) {
-                case T_NAMESPACE:
+                case \T_NAMESPACE:
                     $namespace = '';
                     // If there is a namespace, extract it
                     while (isset($tokens[++$i][1])) {
@@ -121,9 +121,9 @@ private static function findClasses($path)
                     }
                     $namespace .= '\\';
                     break;
-                case T_CLASS:
-                case T_INTERFACE:
-                case T_TRAIT:
+                case \T_CLASS:
+                case \T_INTERFACE:
+                case \T_TRAIT:
                     // Skip usage of ::class constant
                     $isClassConstant = false;
                     for ($j = $i - 1; $j > 0; --$j) {
@@ -131,10 +131,10 @@ private static function findClasses($path)
                             break;
                         }
 
-                        if (T_DOUBLE_COLON === $tokens[$j][0]) {
+                        if (\T_DOUBLE_COLON === $tokens[$j][0]) {
                             $isClassConstant = true;
                             break;
-                        } elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
+                        } elseif (!\in_array($tokens[$j][0], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT])) {
                             break;
                         }
                     }
@@ -146,9 +146,9 @@ private static function findClasses($path)
                     // Find the classname
                     while (isset($tokens[++$i][1])) {
                         $t = $tokens[$i];
-                        if (T_STRING === $t[0]) {
+                        if (\T_STRING === $t[0]) {
                             $class .= $t[1];
-                        } elseif ('' !== $class && T_WHITESPACE === $t[0]) {
+                        } elseif ('' !== $class && \T_WHITESPACE === $t[0]) {
                             break;
                         }
                     }
diff --git a/MapClassLoader.php b/MapClassLoader.php
index e6b89e5..41f07cb 100644
--- a/MapClassLoader.php
+++ b/MapClassLoader.php
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\ClassLoader;
 
-@trigger_error('The '.__NAMESPACE__.'\MapClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
+@trigger_error('The '.__NAMESPACE__.'\MapClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', \E_USER_DEPRECATED);
 
 /**
  * A class loader that uses a mapping file to look up paths.
diff --git a/Psr4ClassLoader.php b/Psr4ClassLoader.php
index f4e79ca..09c456b 100644
--- a/Psr4ClassLoader.php
+++ b/Psr4ClassLoader.php
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\ClassLoader;
 
-@trigger_error('The '.__NAMESPACE__.'\Psr4ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', E_USER_DEPRECATED);
+@trigger_error('The '.__NAMESPACE__.'\Psr4ClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use Composer instead.', \E_USER_DEPRECATED);
 
 /**
  * A PSR-4 compatible class loader.
diff --git a/Tests/ApcClassLoaderTest.php b/Tests/ApcClassLoaderTest.php
index 6706acb..82eb9aa 100644
--- a/Tests/ApcClassLoaderTest.php
+++ b/Tests/ApcClassLoaderTest.php
@@ -22,7 +22,7 @@ class ApcClassLoaderTest extends TestCase
 {
     protected function setUp()
     {
-        if (!(filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
+        if (!(filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
             $this->markTestSkipped('The apc extension is not enabled.');
         } else {
             apcu_clear_cache();
@@ -31,7 +31,7 @@ protected function setUp()
 
     protected function tearDown()
     {
-        if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
+        if (filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
             apcu_clear_cache();
         }
     }
diff --git a/Tests/ClassLoaderTest.php b/Tests/ClassLoaderTest.php
index af8a94b..8de9e24 100644
--- a/Tests/ClassLoaderTest.php
+++ b/Tests/ClassLoaderTest.php
@@ -124,7 +124,7 @@ public function testUseIncludePath()
         $loader->setUseIncludePath(true);
         $this->assertTrue($loader->getUseIncludePath());
 
-        set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath);
+        set_include_path(__DIR__.'/Fixtures/includepath'.\PATH_SEPARATOR.$includePath);
 
         $this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'includepath'.\DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo'));
 
diff --git a/WinCacheClassLoader.php b/WinCacheClassLoader.php
index 374608b..025750a 100644
--- a/WinCacheClassLoader.php
+++ b/WinCacheClassLoader.php
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\ClassLoader;
 
-@trigger_error('The '.__NAMESPACE__.'\WinCacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED);
+@trigger_error('The '.__NAMESPACE__.'\WinCacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', \E_USER_DEPRECATED);
 
 /**
  * WinCacheClassLoader implements a wrapping autoloader cached in WinCache.
diff --git a/XcacheClassLoader.php b/XcacheClassLoader.php
index d236bb4..0897ea9 100644
--- a/XcacheClassLoader.php
+++ b/XcacheClassLoader.php
@@ -11,7 +11,7 @@
 
 namespace Symfony\Component\ClassLoader;
 
-@trigger_error('The '.__NAMESPACE__.'\XcacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', E_USER_DEPRECATED);
+@trigger_error('The '.__NAMESPACE__.'\XcacheClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.', \E_USER_DEPRECATED);
 
 /**
  * XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3.