Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 5, 2022. It is now read-only.

Commit 4459eef

Browse files
committed
switched array() to []
1 parent 4513348 commit 4459eef

13 files changed

+212
-212
lines changed

‎ApcClassLoader.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ public function __construct($prefix, $decorated)
8888
*/
8989
public function register($prepend = false)
9090
{
91-
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
91+
spl_autoload_register([$this, 'loadClass'], true, $prepend);
9292
}
9393

9494
/**
9595
* Unregisters this instance as an autoloader.
9696
*/
9797
public function unregister()
9898
{
99-
spl_autoload_unregister(array($this, 'loadClass'));
99+
spl_autoload_unregister([$this, 'loadClass']);
100100
}
101101

102102
/**
@@ -138,6 +138,6 @@ public function findFile($class)
138138
*/
139139
public function __call($method, $args)
140140
{
141-
return \call_user_func_array(array($this->decorated, $method), $args);
141+
return \call_user_func_array([$this->decorated, $method], $args);
142142
}
143143
}

‎ClassCollectionLoader.php‎

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

109109
if ($autoReload) {
110110
// save the resources
111-
self::writeCacheFile($metadata, serialize(array(array_values($files), $classes)));
111+
self::writeCacheFile($metadata, serialize([array_values($files), $classes]));
112112
}
113113
}
114114

@@ -125,7 +125,7 @@ public static function load($classes, $cacheDir, $name, $autoReload, $adaptive =
125125
*/
126126
public static function inline($classes, $cache, array $excluded)
127127
{
128-
$declared = array();
128+
$declared = [];
129129
foreach (self::getOrderedClasses($excluded) as $class) {
130130
$declared[$class->getName()] = true;
131131
}
@@ -147,7 +147,7 @@ public static function inline($classes, $cache, array $excluded)
147147
$dontInlineRegex = str_replace('.', $spacesRegex, $dontInlineRegex);
148148

149149
$cacheDir = explode('/', str_replace(\DIRECTORY_SEPARATOR, '/', $cacheDir));
150-
$files = array();
150+
$files = [];
151151
$content = '';
152152
foreach (self::getOrderedClasses($classes) as $class) {
153153
if (isset($declared[$class->getName()])) {
@@ -176,7 +176,7 @@ public static function inline($classes, $cache, array $excluded)
176176

177177
$c = "\nnamespace {require $file;}";
178178
} else {
179-
$c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', $c);
179+
$c = preg_replace(['/^\s*<\?php/', '/\?>\s*$/'], '', $c);
180180

181181
// fakes namespace declaration for global code
182182
if (!$class->inNamespace()) {
@@ -220,7 +220,7 @@ public static function fixNamespaceDeclarations($source)
220220
$token = $tokens[$i];
221221
if (!isset($token[1]) || 'b"' === $token) {
222222
$rawChunk .= $token;
223-
} elseif (\in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
223+
} elseif (\in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
224224
// strip comments
225225
continue;
226226
} elseif (T_NAMESPACE === $token[0]) {
@@ -230,7 +230,7 @@ public static function fixNamespaceDeclarations($source)
230230
$rawChunk .= $token[1];
231231

232232
// namespace name and whitespaces
233-
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
233+
while (isset($tokens[++$i][1]) && \in_array($tokens[$i][0], [T_WHITESPACE, T_NS_SEPARATOR, T_STRING])) {
234234
$rawChunk .= $tokens[$i][1];
235235
}
236236
if ('{' === $tokens[$i]) {
@@ -289,8 +289,8 @@ public static function enableTokenizer($bool)
289289
private static function compressCode($code)
290290
{
291291
return preg_replace(
292-
array('/^\s+/m', '/\s+$/m', '/([\n\r]+ *[\n\r]+)+/', '/[ \t]+/'),
293-
array('', '', "\n", ''),
292+
['/^\s+/m', '/\s+$/m', '/([\n\r]+ *[\n\r]+)+/', '/[ \t]+/'],
293+
['', '', "\n", ''],
294294
$code
295295
);
296296
}
@@ -330,8 +330,8 @@ private static function writeCacheFile($file, $content)
330330
*/
331331
private static function getOrderedClasses(array $classes)
332332
{
333-
$map = array();
334-
self::$seen = array();
333+
$map = [];
334+
self::$seen = [];
335335
foreach ($classes as $class) {
336336
try {
337337
$reflectionClass = new \ReflectionClass($class);
@@ -348,20 +348,20 @@ private static function getOrderedClasses(array $classes)
348348
private static function getClassHierarchy(\ReflectionClass $class)
349349
{
350350
if (isset(self::$seen[$class->getName()])) {
351-
return array();
351+
return [];
352352
}
353353

354354
self::$seen[$class->getName()] = true;
355355

356-
$classes = array($class);
356+
$classes = [$class];
357357
$parent = $class;
358358
while (($parent = $parent->getParentClass()) && $parent->isUserDefined() && !isset(self::$seen[$parent->getName()])) {
359359
self::$seen[$parent->getName()] = true;
360360

361361
array_unshift($classes, $parent);
362362
}
363363

364-
$traits = array();
364+
$traits = [];
365365

366366
foreach ($classes as $c) {
367367
foreach (self::resolveDependencies(self::computeTraitDeps($c), $c) as $trait) {
@@ -376,7 +376,7 @@ private static function getClassHierarchy(\ReflectionClass $class)
376376

377377
private static function getInterfaces(\ReflectionClass $class)
378378
{
379-
$classes = array();
379+
$classes = [];
380380

381381
foreach ($class->getInterfaces() as $interface) {
382382
$classes = array_merge($classes, self::getInterfaces($interface));
@@ -394,7 +394,7 @@ private static function getInterfaces(\ReflectionClass $class)
394394
private static function computeTraitDeps(\ReflectionClass $class)
395395
{
396396
$traits = $class->getTraits();
397-
$deps = array($class->getName() => $traits);
397+
$deps = [$class->getName() => $traits];
398398
while ($trait = array_pop($traits)) {
399399
if ($trait->isUserDefined() && !isset(self::$seen[$trait->getName()])) {
400400
self::$seen[$trait->getName()] = true;

‎ClassLoader.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
*/
4444
class ClassLoader
4545
{
46-
private $prefixes = array();
47-
private $fallbackDirs = array();
46+
private $prefixes = [];
47+
private $fallbackDirs = [];
4848
private $useIncludePath = false;
4949

5050
/**
@@ -136,15 +136,15 @@ public function getUseIncludePath()
136136
*/
137137
public function register($prepend = false)
138138
{
139-
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
139+
spl_autoload_register([$this, 'loadClass'], true, $prepend);
140140
}
141141

142142
/**
143143
* Unregisters this instance as an autoloader.
144144
*/
145145
public function unregister()
146146
{
147-
spl_autoload_unregister(array($this, 'loadClass'));
147+
spl_autoload_unregister([$this, 'loadClass']);
148148
}
149149

150150
/**

‎ClassMapGenerator.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ClassMapGenerator
3131
public static function dump($dirs, $file)
3232
{
3333
$dirs = (array) $dirs;
34-
$maps = array();
34+
$maps = [];
3535

3636
foreach ($dirs as $dir) {
3737
$maps = array_merge($maps, static::createMap($dir));
@@ -53,7 +53,7 @@ public static function createMap($dir)
5353
$dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir));
5454
}
5555

56-
$map = array();
56+
$map = [];
5757

5858
foreach ($dir as $file) {
5959
if (!$file->isFile()) {
@@ -93,7 +93,7 @@ private static function findClasses($path)
9393
$contents = file_get_contents($path);
9494
$tokens = token_get_all($contents);
9595

96-
$classes = array();
96+
$classes = [];
9797

9898
$namespace = '';
9999
for ($i = 0; isset($tokens[$i]); ++$i) {
@@ -110,7 +110,7 @@ private static function findClasses($path)
110110
$namespace = '';
111111
// If there is a namespace, extract it
112112
while (isset($tokens[++$i][1])) {
113-
if (\in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) {
113+
if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR])) {
114114
$namespace .= $tokens[$i][1];
115115
}
116116
}
@@ -129,7 +129,7 @@ private static function findClasses($path)
129129
if (T_DOUBLE_COLON === $tokens[$j][0]) {
130130
$isClassConstant = true;
131131
break;
132-
} elseif (!\in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
132+
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
133133
break;
134134
}
135135
}

‎MapClassLoader.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class MapClassLoader
2424
{
25-
private $map = array();
25+
private $map = [];
2626

2727
/**
2828
* @param array $map A map where keys are classes and values the absolute file path
@@ -39,7 +39,7 @@ public function __construct(array $map)
3939
*/
4040
public function register($prepend = false)
4141
{
42-
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
42+
spl_autoload_register([$this, 'loadClass'], true, $prepend);
4343
}
4444

4545
/**

‎Psr4ClassLoader.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class Psr4ClassLoader
2626
{
27-
private $prefixes = array();
27+
private $prefixes = [];
2828

2929
/**
3030
* @param string $prefix
@@ -34,7 +34,7 @@ public function addPrefix($prefix, $baseDir)
3434
{
3535
$prefix = trim($prefix, '\\').'\\';
3636
$baseDir = rtrim($baseDir, \DIRECTORY_SEPARATOR).\DIRECTORY_SEPARATOR;
37-
$this->prefixes[] = array($prefix, $baseDir);
37+
$this->prefixes[] = [$prefix, $baseDir];
3838
}
3939

4040
/**
@@ -81,14 +81,14 @@ public function loadClass($class)
8181
*/
8282
public function register($prepend = false)
8383
{
84-
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
84+
spl_autoload_register([$this, 'loadClass'], true, $prepend);
8585
}
8686

8787
/**
8888
* Removes this instance from the registered autoloaders.
8989
*/
9090
public function unregister()
9191
{
92-
spl_autoload_unregister(array($this, 'loadClass'));
92+
spl_autoload_unregister([$this, 'loadClass']);
9393
}
9494
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /