Skip to content
This repository was archived by the owner on Dec 5, 2022. It is now read-only.

Commit 5e119b7

Browse files
Enable "native_constant_invocation" CS rule
1 parent 04a7e4c commit 5e119b7

10 files changed

+27
-27
lines changed

ApcClassLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
@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);
14+
@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);
1515

1616
/**
1717
* ApcClassLoader implements a wrapping autoloader cached in APC for PHP 5.3.

ClassCollectionLoader.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\ClassLoader;
1313

1414
if (\PHP_VERSION_ID >= 70000) {
15-
@trigger_error('The '.__NAMESPACE__.'\ClassCollectionLoader class is deprecated since Symfony 3.3 and will be removed in 4.0.', E_USER_DEPRECATED);
15+
@trigger_error('The '.__NAMESPACE__.'\ClassCollectionLoader class is deprecated since Symfony 3.3 and will be removed in 4.0.', \E_USER_DEPRECATED);
1616
}
1717

1818
/**
@@ -216,7 +216,7 @@ public static function fixNamespaceDeclarations($source)
216216
$inNamespace = false;
217217
$tokens = token_get_all($source);
218218

219-
$nsTokens = [T_WHITESPACE => true, T_NS_SEPARATOR => true, T_STRING => true];
219+
$nsTokens = [\T_WHITESPACE => true, \T_NS_SEPARATOR => true, \T_STRING => true];
220220
if (\defined('T_NAME_QUALIFIED')) {
221221
$nsTokens[T_NAME_QUALIFIED] = true;
222222
}
@@ -225,10 +225,10 @@ public static function fixNamespaceDeclarations($source)
225225
$token = $tokens[$i];
226226
if (!isset($token[1]) || 'b"' === $token) {
227227
$rawChunk .= $token;
228-
} elseif (\in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
228+
} elseif (\in_array($token[0], [\T_COMMENT, \T_DOC_COMMENT])) {
229229
// strip comments
230230
continue;
231-
} elseif (T_NAMESPACE === $token[0]) {
231+
} elseif (\T_NAMESPACE === $token[0]) {
232232
if ($inNamespace) {
233233
$rawChunk .= "}\n";
234234
}
@@ -245,15 +245,15 @@ public static function fixNamespaceDeclarations($source)
245245
$rawChunk = rtrim($rawChunk)."\n{";
246246
$inNamespace = true;
247247
}
248-
} elseif (T_START_HEREDOC === $token[0]) {
248+
} elseif (\T_START_HEREDOC === $token[0]) {
249249
$output .= self::compressCode($rawChunk).$token[1];
250250
do {
251251
$token = $tokens[++$i];
252252
$output .= isset($token[1]) && 'b"' !== $token ? $token[1] : $token;
253-
} while (T_END_HEREDOC !== $token[0]);
253+
} while (\T_END_HEREDOC !== $token[0]);
254254
$output .= "\n";
255255
$rawChunk = '';
256-
} elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) {
256+
} elseif (\T_CONSTANT_ENCAPSED_STRING === $token[0]) {
257257
$output .= self::compressCode($rawChunk).$token[1];
258258
$rawChunk = '';
259259
} else {

ClassLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
@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);
14+
@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);
1515

1616
/**
1717
* ClassLoader implements an PSR-0 class loader.

ClassMapGenerator.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
@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);
14+
@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);
1515

1616
/**
1717
* ClassMapGenerator.
@@ -62,7 +62,7 @@ public static function createMap($dir)
6262

6363
$path = $file->getRealPath() ?: $file->getPathname();
6464

65-
if ('php' !== pathinfo($path, PATHINFO_EXTENSION)) {
65+
if ('php' !== pathinfo($path, \PATHINFO_EXTENSION)) {
6666
continue;
6767
}
6868

@@ -93,7 +93,7 @@ private static function findClasses($path)
9393
$contents = file_get_contents($path);
9494
$tokens = token_get_all($contents);
9595

96-
$nsTokens = [T_STRING => true, T_NS_SEPARATOR => true];
96+
$nsTokens = [\T_STRING => true, \T_NS_SEPARATOR => true];
9797
if (\defined('T_NAME_QUALIFIED')) {
9898
$nsTokens[T_NAME_QUALIFIED] = true;
9999
}
@@ -111,7 +111,7 @@ private static function findClasses($path)
111111
$class = '';
112112

113113
switch ($token[0]) {
114-
case T_NAMESPACE:
114+
case \T_NAMESPACE:
115115
$namespace = '';
116116
// If there is a namespace, extract it
117117
while (isset($tokens[++$i][1])) {
@@ -121,20 +121,20 @@ private static function findClasses($path)
121121
}
122122
$namespace .= '\\';
123123
break;
124-
case T_CLASS:
125-
case T_INTERFACE:
126-
case T_TRAIT:
124+
case \T_CLASS:
125+
case \T_INTERFACE:
126+
case \T_TRAIT:
127127
// Skip usage of ::class constant
128128
$isClassConstant = false;
129129
for ($j = $i - 1; $j > 0; --$j) {
130130
if (!isset($tokens[$j][1])) {
131131
break;
132132
}
133133

134-
if (T_DOUBLE_COLON === $tokens[$j][0]) {
134+
if (\T_DOUBLE_COLON === $tokens[$j][0]) {
135135
$isClassConstant = true;
136136
break;
137-
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
137+
} elseif (!\in_array($tokens[$j][0], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT])) {
138138
break;
139139
}
140140
}
@@ -146,9 +146,9 @@ private static function findClasses($path)
146146
// Find the classname
147147
while (isset($tokens[++$i][1])) {
148148
$t = $tokens[$i];
149-
if (T_STRING === $t[0]) {
149+
if (\T_STRING === $t[0]) {
150150
$class .= $t[1];
151-
} elseif ('' !== $class && T_WHITESPACE === $t[0]) {
151+
} elseif ('' !== $class && \T_WHITESPACE === $t[0]) {
152152
break;
153153
}
154154
}

MapClassLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
@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);
14+
@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);
1515

1616
/**
1717
* A class loader that uses a mapping file to look up paths.

Psr4ClassLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
@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);
14+
@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);
1515

1616
/**
1717
* A PSR-4 compatible class loader.

Tests/ApcClassLoaderTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ApcClassLoaderTest extends TestCase
2222
{
2323
protected function setUp()
2424
{
25-
if (!(filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN))) {
25+
if (!(filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
2626
$this->markTestSkipped('The apc extension is not enabled.');
2727
} else {
2828
apcu_clear_cache();
@@ -31,7 +31,7 @@ protected function setUp()
3131

3232
protected function tearDown()
3333
{
34-
if (filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
34+
if (filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) {
3535
apcu_clear_cache();
3636
}
3737
}

Tests/ClassLoaderTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testUseIncludePath()
124124
$loader->setUseIncludePath(true);
125125
$this->assertTrue($loader->getUseIncludePath());
126126

127-
set_include_path(__DIR__.'/Fixtures/includepath'.PATH_SEPARATOR.$includePath);
127+
set_include_path(__DIR__.'/Fixtures/includepath'.\PATH_SEPARATOR.$includePath);
128128

129129
$this->assertEquals(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'includepath'.\DIRECTORY_SEPARATOR.'Foo.php', $loader->findFile('Foo'));
130130

WinCacheClassLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
@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);
14+
@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);
1515

1616
/**
1717
* WinCacheClassLoader implements a wrapping autoloader cached in WinCache.

XcacheClassLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
@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);
14+
@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);
1515

1616
/**
1717
* XcacheClassLoader implements a wrapping autoloader cached in XCache for PHP 5.3.

0 commit comments

Comments
 (0)