Skip to content

Commit 1920c50

Browse files
committed
switched array() to []
1 parent c24ce3d commit 1920c50

File tree

4 files changed

+100
-100
lines changed

4 files changed

+100
-100
lines changed

Filesystem.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
5858
}
5959

6060
// Stream context created to allow files overwrite when using FTP stream wrapper - disabled by default
61-
if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
61+
if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(['ftp' => ['overwrite' => true]]))) {
6262
throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
6363
}
6464

@@ -164,7 +164,7 @@ public function remove($files)
164164
if ($files instanceof \Traversable) {
165165
$files = iterator_to_array($files, false);
166166
} elseif (!\is_array($files)) {
167-
$files = array($files);
167+
$files = [$files];
168168
}
169169
$files = array_reverse($files);
170170
foreach ($files as $file) {
@@ -281,7 +281,7 @@ public function rename($origin, $target, $overwrite = false)
281281
if (true !== @rename($origin, $target)) {
282282
if (is_dir($origin)) {
283283
// See https://bugs.php.net/bug.php?id=54097 & http://php.net/manual/en/function.rename.php#113943
284-
$this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
284+
$this->mirror($origin, $target, null, ['override' => $overwrite, 'delete' => $overwrite]);
285285
$this->remove($origin);
286286

287287
return;
@@ -471,7 +471,7 @@ public function makePathRelative($endPath, $startPath)
471471
$endPathArr = explode('/', trim($endPath, '/'));
472472

473473
$normalizePathArray = function ($pathSegments, $absolute) {
474-
$result = array();
474+
$result = [];
475475

476476
foreach ($pathSegments as $segment) {
477477
if ('..' === $segment && ($absolute || \count($result))) {
@@ -530,7 +530,7 @@ public function makePathRelative($endPath, $startPath)
530530
*
531531
* @throws IOException When file type is unknown
532532
*/
533-
public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
533+
public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = [])
534534
{
535535
$targetDir = rtrim($targetDir, '/\\');
536536
$originDir = rtrim($originDir, '/\\');
@@ -726,7 +726,7 @@ public function appendToFile($filename, $content)
726726
*/
727727
private function toIterable($files)
728728
{
729-
return \is_array($files) || $files instanceof \Traversable ? $files : array($files);
729+
return \is_array($files) || $files instanceof \Traversable ? $files : [$files];
730730
}
731731

732732
/**
@@ -740,7 +740,7 @@ private function getSchemeAndHierarchy($filename)
740740
{
741741
$components = explode('://', $filename, 2);
742742

743-
return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
743+
return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
744744
}
745745

746746
private static function box($func)

Tests/FilesystemTest.php

Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ public function testMkdirCreatesDirectoriesRecursively()
197197
public function testMkdirCreatesDirectoriesFromArray()
198198
{
199199
$basePath = $this->workspace.\DIRECTORY_SEPARATOR;
200-
$directories = array(
200+
$directories = [
201201
$basePath.'1', $basePath.'2', $basePath.'3',
202-
);
202+
];
203203

204204
$this->filesystem->mkdir($directories);
205205

@@ -211,9 +211,9 @@ public function testMkdirCreatesDirectoriesFromArray()
211211
public function testMkdirCreatesDirectoriesFromTraversableObject()
212212
{
213213
$basePath = $this->workspace.\DIRECTORY_SEPARATOR;
214-
$directories = new \ArrayObject(array(
214+
$directories = new \ArrayObject([
215215
$basePath.'1', $basePath.'2', $basePath.'3',
216-
));
216+
]);
217217

218218
$this->filesystem->mkdir($directories);
219219

@@ -257,9 +257,9 @@ public function testTouchFails()
257257
public function testTouchCreatesEmptyFilesFromArray()
258258
{
259259
$basePath = $this->workspace.\DIRECTORY_SEPARATOR;
260-
$files = array(
260+
$files = [
261261
$basePath.'1', $basePath.'2', $basePath.'3',
262-
);
262+
];
263263

264264
$this->filesystem->touch($files);
265265

@@ -271,9 +271,9 @@ public function testTouchCreatesEmptyFilesFromArray()
271271
public function testTouchCreatesEmptyFilesFromTraversableObject()
272272
{
273273
$basePath = $this->workspace.\DIRECTORY_SEPARATOR;
274-
$files = new \ArrayObject(array(
274+
$files = new \ArrayObject([
275275
$basePath.'1', $basePath.'2', $basePath.'3',
276-
));
276+
]);
277277

278278
$this->filesystem->touch($files);
279279

@@ -302,9 +302,9 @@ public function testRemoveCleansArrayOfFilesAndDirectories()
302302
mkdir($basePath.'dir');
303303
touch($basePath.'file');
304304

305-
$files = array(
305+
$files = [
306306
$basePath.'dir', $basePath.'file',
307-
);
307+
];
308308

309309
$this->filesystem->remove($files);
310310

@@ -319,9 +319,9 @@ public function testRemoveCleansTraversableObjectOfFilesAndDirectories()
319319
mkdir($basePath.'dir');
320320
touch($basePath.'file');
321321

322-
$files = new \ArrayObject(array(
322+
$files = new \ArrayObject([
323323
$basePath.'dir', $basePath.'file',
324-
));
324+
]);
325325

326326
$this->filesystem->remove($files);
327327

@@ -335,9 +335,9 @@ public function testRemoveIgnoresNonExistingFiles()
335335

336336
mkdir($basePath.'dir');
337337

338-
$files = array(
338+
$files = [
339339
$basePath.'dir', $basePath.'file',
340-
);
340+
];
341341

342342
$this->filesystem->remove($files);
343343

@@ -409,9 +409,9 @@ public function testFilesExistsTraversableObjectOfFilesAndDirectories()
409409
mkdir($basePath.'dir');
410410
touch($basePath.'file');
411411

412-
$files = new \ArrayObject(array(
412+
$files = new \ArrayObject([
413413
$basePath.'dir', $basePath.'file',
414-
));
414+
]);
415415

416416
$this->assertTrue($this->filesystem->exists($files));
417417
}
@@ -424,9 +424,9 @@ public function testFilesNotExistsTraversableObjectOfFilesAndDirectories()
424424
touch($basePath.'file');
425425
touch($basePath.'file2');
426426

427-
$files = new \ArrayObject(array(
427+
$files = new \ArrayObject([
428428
$basePath.'dir', $basePath.'file', $basePath.'file2',
429-
));
429+
]);
430430

431431
unlink($basePath.'file');
432432

@@ -507,7 +507,7 @@ public function testChmodChangesModeOfArrayOfFiles()
507507

508508
$directory = $this->workspace.\DIRECTORY_SEPARATOR.'directory';
509509
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
510-
$files = array($directory, $file);
510+
$files = [$directory, $file];
511511

512512
mkdir($directory);
513513
touch($file);
@@ -524,7 +524,7 @@ public function testChmodChangesModeOfTraversableFileObject()
524524

525525
$directory = $this->workspace.\DIRECTORY_SEPARATOR.'directory';
526526
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
527-
$files = new \ArrayObject(array($directory, $file));
527+
$files = new \ArrayObject([$directory, $file]);
528528

529529
mkdir($directory);
530530
touch($file);
@@ -979,7 +979,7 @@ public function testLinkWithSeveralTargets()
979979

980980
touch($file);
981981

982-
$this->filesystem->hardlink($file, array($link1, $link2));
982+
$this->filesystem->hardlink($file, [$link1, $link2]);
983983

984984
$this->assertTrue(is_file($link1));
985985
$this->assertEquals(fileinode($file), fileinode($link1));
@@ -997,7 +997,7 @@ public function testLinkWithSameTarget()
997997
touch($file);
998998

999999
// practically same as testLinkIsNotOverwrittenIfAlreadyCreated
1000-
$this->filesystem->hardlink($file, array($link, $link));
1000+
$this->filesystem->hardlink($file, [$link, $link]);
10011001

10021002
$this->assertTrue(is_file($link));
10031003
$this->assertEquals(fileinode($file), fileinode($link));
@@ -1106,47 +1106,47 @@ public function testMakePathRelative($endPath, $startPath, $expectedPath)
11061106

11071107
public function providePathsForMakePathRelative()
11081108
{
1109-
$paths = array(
1110-
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component', '../'),
1111-
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component/', '../'),
1112-
array('/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component', '../'),
1113-
array('/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component/', '../'),
1114-
array('/usr/lib/symfony/', '/var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'),
1115-
array('/var/lib/symfony/src/Symfony/', '/var/lib/symfony/', 'src/Symfony/'),
1116-
array('/aa/bb', '/aa/bb', './'),
1117-
array('/aa/bb', '/aa/bb/', './'),
1118-
array('/aa/bb/', '/aa/bb', './'),
1119-
array('/aa/bb/', '/aa/bb/', './'),
1120-
array('/aa/bb/cc', '/aa/bb/cc/dd', '../'),
1121-
array('/aa/bb/cc', '/aa/bb/cc/dd/', '../'),
1122-
array('/aa/bb/cc/', '/aa/bb/cc/dd', '../'),
1123-
array('/aa/bb/cc/', '/aa/bb/cc/dd/', '../'),
1124-
array('/aa/bb/cc', '/aa', 'bb/cc/'),
1125-
array('/aa/bb/cc', '/aa/', 'bb/cc/'),
1126-
array('/aa/bb/cc/', '/aa', 'bb/cc/'),
1127-
array('/aa/bb/cc/', '/aa/', 'bb/cc/'),
1128-
array('/a/aab/bb', '/a/aa', '../aab/bb/'),
1129-
array('/a/aab/bb', '/a/aa/', '../aab/bb/'),
1130-
array('/a/aab/bb/', '/a/aa', '../aab/bb/'),
1131-
array('/a/aab/bb/', '/a/aa/', '../aab/bb/'),
1132-
array('/a/aab/bb/', '/', 'a/aab/bb/'),
1133-
array('/a/aab/bb/', '/b/aab', '../../a/aab/bb/'),
1134-
array('/aab/bb', '/aa', '../aab/bb/'),
1135-
array('/aab', '/aa', '../aab/'),
1136-
array('/aa/bb/cc', '/aa/dd/..', 'bb/cc/'),
1137-
array('/aa/../bb/cc', '/aa/dd/..', '../bb/cc/'),
1138-
array('/aa/bb/../../cc', '/aa/../dd/..', 'cc/'),
1139-
array('/../aa/bb/cc', '/aa/dd/..', 'bb/cc/'),
1140-
array('/../../aa/../bb/cc', '/aa/dd/..', '../bb/cc/'),
1141-
array('C:/aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'),
1142-
array('c:/aa/../bb/cc', 'c:/aa/dd/..', '../bb/cc/'),
1143-
array('C:/aa/bb/../../cc', 'C:/aa/../dd/..', 'cc/'),
1144-
array('C:/../aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'),
1145-
array('C:/../../aa/../bb/cc', 'C:/aa/dd/..', '../bb/cc/'),
1146-
);
1109+
$paths = [
1110+
['/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component', '../'],
1111+
['/var/lib/symfony/src/Symfony/', '/var/lib/symfony/src/Symfony/Component/', '../'],
1112+
['/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component', '../'],
1113+
['/var/lib/symfony/src/Symfony', '/var/lib/symfony/src/Symfony/Component/', '../'],
1114+
['/usr/lib/symfony/', '/var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'],
1115+
['/var/lib/symfony/src/Symfony/', '/var/lib/symfony/', 'src/Symfony/'],
1116+
['/aa/bb', '/aa/bb', './'],
1117+
['/aa/bb', '/aa/bb/', './'],
1118+
['/aa/bb/', '/aa/bb', './'],
1119+
['/aa/bb/', '/aa/bb/', './'],
1120+
['/aa/bb/cc', '/aa/bb/cc/dd', '../'],
1121+
['/aa/bb/cc', '/aa/bb/cc/dd/', '../'],
1122+
['/aa/bb/cc/', '/aa/bb/cc/dd', '../'],
1123+
['/aa/bb/cc/', '/aa/bb/cc/dd/', '../'],
1124+
['/aa/bb/cc', '/aa', 'bb/cc/'],
1125+
['/aa/bb/cc', '/aa/', 'bb/cc/'],
1126+
['/aa/bb/cc/', '/aa', 'bb/cc/'],
1127+
['/aa/bb/cc/', '/aa/', 'bb/cc/'],
1128+
['/a/aab/bb', '/a/aa', '../aab/bb/'],
1129+
['/a/aab/bb', '/a/aa/', '../aab/bb/'],
1130+
['/a/aab/bb/', '/a/aa', '../aab/bb/'],
1131+
['/a/aab/bb/', '/a/aa/', '../aab/bb/'],
1132+
['/a/aab/bb/', '/', 'a/aab/bb/'],
1133+
['/a/aab/bb/', '/b/aab', '../../a/aab/bb/'],
1134+
['/aab/bb', '/aa', '../aab/bb/'],
1135+
['/aab', '/aa', '../aab/'],
1136+
['/aa/bb/cc', '/aa/dd/..', 'bb/cc/'],
1137+
['/aa/../bb/cc', '/aa/dd/..', '../bb/cc/'],
1138+
['/aa/bb/../../cc', '/aa/../dd/..', 'cc/'],
1139+
['/../aa/bb/cc', '/aa/dd/..', 'bb/cc/'],
1140+
['/../../aa/../bb/cc', '/aa/dd/..', '../bb/cc/'],
1141+
['C:/aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'],
1142+
['c:/aa/../bb/cc', 'c:/aa/dd/..', '../bb/cc/'],
1143+
['C:/aa/bb/../../cc', 'C:/aa/../dd/..', 'cc/'],
1144+
['C:/../aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'],
1145+
['C:/../../aa/../bb/cc', 'C:/aa/dd/..', '../bb/cc/'],
1146+
];
11471147

11481148
if ('\\' === \DIRECTORY_SEPARATOR) {
1149-
$paths[] = array('c:\var\lib/symfony/src/Symfony/', 'c:/var/lib/symfony/', 'src/Symfony/');
1149+
$paths[] = ['c:\var\lib/symfony/src/Symfony/', 'c:/var/lib/symfony/', 'src/Symfony/'];
11501150
}
11511151

11521152
return $paths;
@@ -1166,20 +1166,20 @@ public function testMakePathRelativeWithRelativePaths($endPath, $startPath, $exp
11661166

11671167
public function provideLegacyPathsForMakePathRelativeWithRelativePaths()
11681168
{
1169-
return array(
1170-
array('usr/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'),
1171-
array('aa/bb', 'aa/cc', '../bb/'),
1172-
array('aa/cc', 'bb/cc', '../../aa/cc/'),
1173-
array('aa/bb', 'aa/./cc', '../bb/'),
1174-
array('aa/./bb', 'aa/cc', '../bb/'),
1175-
array('aa/./bb', 'aa/./cc', '../bb/'),
1176-
array('../../', '../../', './'),
1177-
array('../aa/bb/', 'aa/bb/', '../../../aa/bb/'),
1178-
array('../../../', '../../', '../'),
1179-
array('', '', './'),
1180-
array('', 'aa/', '../'),
1181-
array('aa/', '', 'aa/'),
1182-
);
1169+
return [
1170+
['usr/lib/symfony/', 'var/lib/symfony/src/Symfony/Component', '../../../../../../usr/lib/symfony/'],
1171+
['aa/bb', 'aa/cc', '../bb/'],
1172+
['aa/cc', 'bb/cc', '../../aa/cc/'],
1173+
['aa/bb', 'aa/./cc', '../bb/'],
1174+
['aa/./bb', 'aa/cc', '../bb/'],
1175+
['aa/./bb', 'aa/./cc', '../bb/'],
1176+
['../../', '../../', './'],
1177+
['../aa/bb/', 'aa/bb/', '../../../aa/bb/'],
1178+
['../../../', '../../', '../'],
1179+
['', '', './'],
1180+
['', 'aa/', '../'],
1181+
['aa/', '', 'aa/'],
1182+
];
11831183
}
11841184

11851185
public function testMirrorCopiesFilesAndDirectoriesRecursively()
@@ -1205,19 +1205,19 @@ public function testMirrorCopiesFilesAndDirectoriesRecursively()
12051205

12061206
$this->filesystem->remove($file1);
12071207

1208-
$this->filesystem->mirror($sourcePath, $targetPath, null, array('delete' => false));
1208+
$this->filesystem->mirror($sourcePath, $targetPath, null, ['delete' => false]);
12091209
$this->assertTrue($this->filesystem->exists($targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1'));
12101210

1211-
$this->filesystem->mirror($sourcePath, $targetPath, null, array('delete' => true));
1211+
$this->filesystem->mirror($sourcePath, $targetPath, null, ['delete' => true]);
12121212
$this->assertFalse($this->filesystem->exists($targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1'));
12131213

12141214
file_put_contents($file1, 'FILE1');
12151215

1216-
$this->filesystem->mirror($sourcePath, $targetPath, null, array('delete' => true));
1216+
$this->filesystem->mirror($sourcePath, $targetPath, null, ['delete' => true]);
12171217
$this->assertTrue($this->filesystem->exists($targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1'));
12181218

12191219
$this->filesystem->remove($directory);
1220-
$this->filesystem->mirror($sourcePath, $targetPath, null, array('delete' => true));
1220+
$this->filesystem->mirror($sourcePath, $targetPath, null, ['delete' => true]);
12211221
$this->assertFalse($this->filesystem->exists($targetPath.'directory'));
12221222
$this->assertFalse($this->filesystem->exists($targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1'));
12231223
}
@@ -1339,7 +1339,7 @@ public function testMirrorContentsWithSameNameAsSourceOrTargetWithDeleteOption()
13391339
$oldPath = getcwd();
13401340
chdir($this->workspace);
13411341

1342-
$this->filesystem->mirror('source', 'target', null, array('delete' => true));
1342+
$this->filesystem->mirror('source', 'target', null, ['delete' => true]);
13431343

13441344
chdir($oldPath);
13451345

@@ -1360,15 +1360,15 @@ public function testIsAbsolutePath($path, $expectedResult)
13601360

13611361
public function providePathsForIsAbsolutePath()
13621362
{
1363-
return array(
1364-
array('/var/lib', true),
1365-
array('c:\\\\var\\lib', true),
1366-
array('\\var\\lib', true),
1367-
array('var/lib', false),
1368-
array('../var/lib', false),
1369-
array('', false),
1370-
array(null, false),
1371-
);
1363+
return [
1364+
['/var/lib', true],
1365+
['c:\\\\var\\lib', true],
1366+
['\\var\\lib', true],
1367+
['var/lib', false],
1368+
['../var/lib', false],
1369+
['', false],
1370+
[null, false],
1371+
];
13721372
}
13731373

13741374
public function testTempnam()
@@ -1498,7 +1498,7 @@ public function testDumpFileWithArray()
14981498
{
14991499
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR.'baz.txt';
15001500

1501-
$this->filesystem->dumpFile($filename, array('bar'));
1501+
$this->filesystem->dumpFile($filename, ['bar']);
15021502

15031503
$this->assertFileExists($filename);
15041504
$this->assertStringEqualsFile($filename, 'bar');

0 commit comments

Comments
 (0)