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

Commit dadfb73

Browse files
committed
Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
1 parent f87f46e commit dadfb73

11 files changed

+32
-32
lines changed

ApcClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class ApcClassLoader
6565
*/
6666
public function __construct($prefix, $decorated)
6767
{
68-
if (!function_exists('apcu_fetch')) {
68+
if (!\function_exists('apcu_fetch')) {
6969
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not installed.');
7070
}
7171

@@ -134,6 +134,6 @@ public function findFile($class)
134134
*/
135135
public function __call($method, $args)
136136
{
137-
return call_user_func_array(array($this->decorated, $method), $args);
137+
return \call_user_func_array(array($this->decorated, $method), $args);
138138
}
139139
}

ApcUniversalClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ApcUniversalClassLoader extends UniversalClassLoader
7474
*/
7575
public function __construct($prefix)
7676
{
77-
if (!function_exists('apcu_fetch')) {
77+
if (!\function_exists('apcu_fetch')) {
7878
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
7979
}
8080

ClassCollectionLoader.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
4545

4646
if ($adaptive) {
4747
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
48-
if (function_exists('get_declared_traits')) {
48+
if (\function_exists('get_declared_traits')) {
4949
$declared = array_merge($declared, get_declared_traits());
5050
}
5151

@@ -99,7 +99,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
9999
}
100100
if (!$adaptive) {
101101
$declared = array_merge(get_declared_classes(), get_declared_interfaces());
102-
if (function_exists('get_declared_traits')) {
102+
if (\function_exists('get_declared_traits')) {
103103
$declared = array_merge($declared, get_declared_traits());
104104
}
105105
}
@@ -118,7 +118,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
118118
$files = array();
119119
$content = '';
120120
foreach (self::getOrderedClasses($classes) as $class) {
121-
if (in_array($class->getName(), $declared)) {
121+
if (\in_array($class->getName(), $declared)) {
122122
continue;
123123
}
124124

@@ -136,8 +136,8 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
136136
if (1 >= $i) {
137137
$file = var_export(implode('/', $file), true);
138138
} else {
139-
$file = array_slice($file, $i);
140-
$file = str_repeat('../', count($cacheDir) - $i).implode('/', $file);
139+
$file = \array_slice($file, $i);
140+
$file = str_repeat('../', \count($cacheDir) - $i).implode('/', $file);
141141
$file = '__DIR__.'.var_export('/'.$file, true);
142142
}
143143

@@ -173,7 +173,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
173173
*/
174174
public static function fixNamespaceDeclarations($source)
175175
{
176-
if (!function_exists('token_get_all') || !self::$useTokenizer) {
176+
if (!\function_exists('token_get_all') || !self::$useTokenizer) {
177177
if (preg_match('/(^|\s)namespace(.*?)\s*;/', $source)) {
178178
$source = preg_replace('/(^|\s)namespace(.*?)\s*;/', "$1namespace$2\n{", $source)."}\n";
179179
}
@@ -190,7 +190,7 @@ public static function fixNamespaceDeclarations($source)
190190
$token = $tokens[$i];
191191
if (!isset($token[1]) || 'b"' === $token) {
192192
$rawChunk .= $token;
193-
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
193+
} elseif (\in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
194194
// strip comments
195195
continue;
196196
} elseif (T_NAMESPACE === $token[0]) {
@@ -200,7 +200,7 @@ public static function fixNamespaceDeclarations($source)
200200
$rawChunk .= $token[1];
201201

202202
// namespace name and whitespaces
203-
while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
203+
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
204204
$rawChunk .= $tokens[$i][1];
205205
}
206206
if ('{' === $tokens[$i]) {
@@ -275,7 +275,7 @@ private static function compressCode($code)
275275
*/
276276
private static function writeCacheFile($file, $content)
277277
{
278-
$dir = dirname($file);
278+
$dir = \dirname($file);
279279
if (!is_writable($dir)) {
280280
throw new \RuntimeException(sprintf('Cache directory "%s" is not writable.', $dir));
281281
}

ClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ public function addPrefix($prefix, $paths)
9191
return;
9292
}
9393
if (isset($this->prefixes[$prefix])) {
94-
if (is_array($paths)) {
94+
if (\is_array($paths)) {
9595
$this->prefixes[$prefix] = array_unique(array_merge(
9696
$this->prefixes[$prefix],
9797
$paths
9898
));
99-
} elseif (!in_array($paths, $this->prefixes[$prefix])) {
99+
} elseif (!\in_array($paths, $this->prefixes[$prefix])) {
100100
$this->prefixes[$prefix][] = $paths;
101101
}
102102
} else {

ClassMapGenerator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
namespace Symfony\Component\ClassLoader;
1313

14-
if (!defined('SYMFONY_TRAIT')) {
14+
if (!\defined('SYMFONY_TRAIT')) {
1515
if (\PHP_VERSION_ID >= 50400) {
16-
define('SYMFONY_TRAIT', T_TRAIT);
16+
\define('SYMFONY_TRAIT', T_TRAIT);
1717
} else {
18-
define('SYMFONY_TRAIT', 0);
18+
\define('SYMFONY_TRAIT', 0);
1919
}
2020
}
2121

@@ -53,7 +53,7 @@ public static function dump($dirs, $file)
5353
*/
5454
public static function createMap($dir)
5555
{
56-
if (is_string($dir)) {
56+
if (\is_string($dir)) {
5757
$dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
5858
}
5959

@@ -114,7 +114,7 @@ private static function findClasses($path)
114114
$namespace = '';
115115
// If there is a namespace, extract it
116116
while (isset($tokens[++$i][1])) {
117-
if (in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) {
117+
if (\in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) {
118118
$namespace .= $tokens[$i][1];
119119
}
120120
}
@@ -133,7 +133,7 @@ private static function findClasses($path)
133133
if (T_DOUBLE_COLON === $tokens[$j][0]) {
134134
$isClassConstant = true;
135135
break;
136-
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
136+
} elseif (!\in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
137137
break;
138138
}
139139
}

DebugClassLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function getClassLoader()
5353
*/
5454
public static function enable()
5555
{
56-
if (!is_array($functions = spl_autoload_functions())) {
56+
if (!\is_array($functions = spl_autoload_functions())) {
5757
return;
5858
}
5959

@@ -62,7 +62,7 @@ public static function enable()
6262
}
6363

6464
foreach ($functions as $function) {
65-
if (is_array($function) && !$function[0] instanceof self && method_exists($function[0], 'findFile')) {
65+
if (\is_array($function) && !$function[0] instanceof self && method_exists($function[0], 'findFile')) {
6666
$function = array(new static($function[0]), 'loadClass');
6767
}
6868

@@ -104,7 +104,7 @@ public function loadClass($class)
104104
if ($file = $this->classFinder->findFile($class)) {
105105
require $file;
106106

107-
if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
107+
if (!class_exists($class, false) && !interface_exists($class, false) && (!\function_exists('trait_exists') || !trait_exists($class, false))) {
108108
if (false !== strpos($class, '/')) {
109109
throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
110110
}

DebugUniversalClassLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class DebugUniversalClassLoader extends UniversalClassLoader
2828
*/
2929
public static function enable()
3030
{
31-
if (!is_array($functions = spl_autoload_functions())) {
31+
if (!\is_array($functions = spl_autoload_functions())) {
3232
return;
3333
}
3434

@@ -37,7 +37,7 @@ public static function enable()
3737
}
3838

3939
foreach ($functions as $function) {
40-
if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
40+
if (\is_array($function) && $function[0] instanceof UniversalClassLoader) {
4141
$loader = new static();
4242
$loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks());
4343
$loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks());
@@ -60,7 +60,7 @@ public function loadClass($class)
6060
if ($file = $this->findFile($class)) {
6161
require $file;
6262

63-
if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
63+
if (!class_exists($class, false) && !interface_exists($class, false) && (!\function_exists('trait_exists') || !trait_exists($class, false))) {
6464
throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
6565
}
6666
}

Psr4ClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function findFile($class)
4545
foreach ($this->prefixes as $current) {
4646
list($currentPrefix, $currentBaseDir) = $current;
4747
if (0 === strpos($class, $currentPrefix)) {
48-
$classWithoutPrefix = substr($class, strlen($currentPrefix));
48+
$classWithoutPrefix = substr($class, \strlen($currentPrefix));
4949
$file = $currentBaseDir.str_replace('\\', DIRECTORY_SEPARATOR, $classWithoutPrefix).'.php';
5050
if (file_exists($file)) {
5151
return $file;

Tests/ClassCollectionLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function testCommentStripping()
233233
}
234234
});
235235

236-
$strictTypes = defined('HHVM_VERSION') ? '' : "\nnamespace {require __DIR__.'/Fixtures/Namespaced/WithStrictTypes.php';}";
236+
$strictTypes = \defined('HHVM_VERSION') ? '' : "\nnamespace {require __DIR__.'/Fixtures/Namespaced/WithStrictTypes.php';}";
237237

238238
ClassCollectionLoader::load(
239239
array('Namespaced\\WithComments', 'Pearlike_WithComments', 'Namespaced\\WithDirMagic', 'Namespaced\\WithFileMagic', 'Namespaced\\WithHaltCompiler', $strictTypes ? 'Namespaced\\WithStrictTypes' : 'Namespaced\\WithComments'),

WinCacheClassLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class WinCacheClassLoader
6666
*/
6767
public function __construct($prefix, $decorated)
6868
{
69-
if (!extension_loaded('wincache')) {
69+
if (!\extension_loaded('wincache')) {
7070
throw new \RuntimeException('Unable to use WinCacheClassLoader as WinCache is not enabled.');
7171
}
7272

@@ -135,6 +135,6 @@ public function findFile($class)
135135
*/
136136
public function __call($method, $args)
137137
{
138-
return call_user_func_array(array($this->decorated, $method), $args);
138+
return \call_user_func_array(array($this->decorated, $method), $args);
139139
}
140140
}

0 commit comments

Comments
 (0)