Skip to content

Commit 5199360

Browse files
committed
fixed CS
1 parent 5e7c3fd commit 5199360

File tree

2 files changed

+83
-83
lines changed

2 files changed

+83
-83
lines changed

Filesystem.php

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

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

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

288288
return;
@@ -476,7 +476,7 @@ public function makePathRelative($endPath, $startPath)
476476
$endPathArr = explode('/', trim($endPath, '/'));
477477

478478
$normalizePathArray = function ($pathSegments) {
479-
$result = array();
479+
$result = [];
480480

481481
foreach ($pathSegments as $segment) {
482482
if ('..' === $segment) {
@@ -535,7 +535,7 @@ public function makePathRelative($endPath, $startPath)
535535
*
536536
* @throws IOException When file type is unknown
537537
*/
538-
public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
538+
public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = [])
539539
{
540540
$targetDir = rtrim($targetDir, '/\\');
541541
$originDir = rtrim($originDir, '/\\');
@@ -723,7 +723,7 @@ public function appendToFile($filename, $content)
723723

724724
private function toIterable($files): iterable
725725
{
726-
return \is_array($files) || $files instanceof \Traversable ? $files : array($files);
726+
return \is_array($files) || $files instanceof \Traversable ? $files : [$files];
727727
}
728728

729729
/**
@@ -733,7 +733,7 @@ private function getSchemeAndHierarchy(string $filename): array
733733
{
734734
$components = explode('://', $filename, 2);
735735

736-
return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
736+
return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
737737
}
738738

739739
private static function box($func)

Tests/FilesystemTest.php

Lines changed: 76 additions & 76 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

@@ -503,7 +503,7 @@ public function testChmodChangesModeOfArrayOfFiles()
503503

504504
$directory = $this->workspace.\DIRECTORY_SEPARATOR.'directory';
505505
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
506-
$files = array($directory, $file);
506+
$files = [$directory, $file];
507507

508508
mkdir($directory);
509509
touch($file);
@@ -520,7 +520,7 @@ public function testChmodChangesModeOfTraversableFileObject()
520520

521521
$directory = $this->workspace.\DIRECTORY_SEPARATOR.'directory';
522522
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
523-
$files = new \ArrayObject(array($directory, $file));
523+
$files = new \ArrayObject([$directory, $file]);
524524

525525
mkdir($directory);
526526
touch($file);
@@ -975,7 +975,7 @@ public function testLinkWithSeveralTargets()
975975

976976
touch($file);
977977

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

980980
$this->assertTrue(is_file($link1));
981981
$this->assertEquals(fileinode($file), fileinode($link1));
@@ -993,7 +993,7 @@ public function testLinkWithSameTarget()
993993
touch($file);
994994

995995
// practically same as testLinkIsNotOverwrittenIfAlreadyCreated
996-
$this->filesystem->hardlink($file, array($link, $link));
996+
$this->filesystem->hardlink($file, [$link, $link]);
997997

998998
$this->assertTrue(is_file($link));
999999
$this->assertEquals(fileinode($file), fileinode($link));
@@ -1102,47 +1102,47 @@ public function testMakePathRelative($endPath, $startPath, $expectedPath)
11021102

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

11441144
if ('\\' === \DIRECTORY_SEPARATOR) {
1145-
$paths[] = array('c:\var\lib/symfony/src/Symfony/', 'c:/var/lib/symfony/', 'src/Symfony/');
1145+
$paths[] = ['c:\var\lib/symfony/src/Symfony/', 'c:/var/lib/symfony/', 'src/Symfony/'];
11461146
}
11471147

11481148
return $paths;
@@ -1189,19 +1189,19 @@ public function testMirrorCopiesFilesAndDirectoriesRecursively()
11891189

11901190
$this->filesystem->remove($file1);
11911191

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

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

11981198
file_put_contents($file1, 'FILE1');
11991199

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

12031203
$this->filesystem->remove($directory);
1204-
$this->filesystem->mirror($sourcePath, $targetPath, null, array('delete' => true));
1204+
$this->filesystem->mirror($sourcePath, $targetPath, null, ['delete' => true]);
12051205
$this->assertFalse($this->filesystem->exists($targetPath.'directory'));
12061206
$this->assertFalse($this->filesystem->exists($targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1'));
12071207
}
@@ -1323,7 +1323,7 @@ public function testMirrorContentsWithSameNameAsSourceOrTargetWithDeleteOption()
13231323
$oldPath = getcwd();
13241324
chdir($this->workspace);
13251325

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

13281328
chdir($oldPath);
13291329

@@ -1344,15 +1344,15 @@ public function testIsAbsolutePath($path, $expectedResult)
13441344

13451345
public function providePathsForIsAbsolutePath()
13461346
{
1347-
return array(
1348-
array('/var/lib', true),
1349-
array('c:\\\\var\\lib', true),
1350-
array('\\var\\lib', true),
1351-
array('var/lib', false),
1352-
array('../var/lib', false),
1353-
array('', false),
1354-
array(null, false),
1355-
);
1347+
return [
1348+
['/var/lib', true],
1349+
['c:\\\\var\\lib', true],
1350+
['\\var\\lib', true],
1351+
['var/lib', false],
1352+
['../var/lib', false],
1353+
['', false],
1354+
[null, false],
1355+
];
13561356
}
13571357

13581358
public function testTempnam()
@@ -1482,7 +1482,7 @@ public function testDumpFileWithArray()
14821482
{
14831483
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR.'baz.txt';
14841484

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

14871487
$this->assertFileExists($filename);
14881488
$this->assertStringEqualsFile($filename, 'bar');

0 commit comments

Comments
 (0)