Skip to content

Commit 719d208

Browse files
committed
Merge branch '4.1' into 4.2
* 4.1: fixed tests fixed CS fixed CS fixed CS fixed short array CS in comments fixed CS in ExpressionLanguage fixtures fixed CS in generated files fixed CS on generated container files fixed CS on Form PHP templates fixed CS on YAML fixtures fixed fixtures switched array() to []
2 parents c2ffd9a + 93f4b83 commit 719d208

File tree

4 files changed

+87
-87
lines changed

4 files changed

+87
-87
lines changed

Filesystem.php

Lines changed: 8 additions & 8 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, '/\\');
@@ -727,17 +727,17 @@ public function appendToFile($filename, $content)
727727

728728
private function toIterable($files): iterable
729729
{
730-
return \is_array($files) || $files instanceof \Traversable ? $files : array($files);
730+
return \is_array($files) || $files instanceof \Traversable ? $files : [$files];
731731
}
732732

733733
/**
734-
* Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> array(file, tmp)).
734+
* Gets a 2-tuple of scheme (may be null) and hierarchical part of a filename (e.g. file:///tmp -> [file, tmp]).
735735
*/
736736
private function getSchemeAndHierarchy(string $filename): array
737737
{
738738
$components = explode('://', $filename, 2);
739739

740-
return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
740+
return 2 === \count($components) ? [$components[0], $components[1]] : [null, $components[0]];
741741
}
742742

743743
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

@@ -1384,15 +1384,15 @@ public function testIsAbsolutePath($path, $expectedResult)
13841384

13851385
public function providePathsForIsAbsolutePath()
13861386
{
1387-
return array(
1388-
array('/var/lib', true),
1389-
array('c:\\\\var\\lib', true),
1390-
array('\\var\\lib', true),
1391-
array('var/lib', false),
1392-
array('../var/lib', false),
1393-
array('', false),
1394-
array(null, false),
1395-
);
1387+
return [
1388+
['/var/lib', true],
1389+
['c:\\\\var\\lib', true],
1390+
['\\var\\lib', true],
1391+
['var/lib', false],
1392+
['../var/lib', false],
1393+
['', false],
1394+
[null, false],
1395+
];
13961396
}
13971397

13981398
public function testTempnam()
@@ -1522,7 +1522,7 @@ public function testDumpFileWithArray()
15221522
{
15231523
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo'.\DIRECTORY_SEPARATOR.'baz.txt';
15241524

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

15271527
$this->assertFileExists($filename);
15281528
$this->assertStringEqualsFile($filename, 'bar');

Tests/FilesystemTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class FilesystemTestCase extends TestCase
1818
{
1919
private $umask;
2020

21-
protected $longPathNamesWindows = array();
21+
protected $longPathNamesWindows = [];
2222

2323
/**
2424
* @var \Symfony\Component\Filesystem\Filesystem
@@ -84,7 +84,7 @@ protected function tearDown()
8484
foreach ($this->longPathNamesWindows as $path) {
8585
exec('DEL '.$path);
8686
}
87-
$this->longPathNamesWindows = array();
87+
$this->longPathNamesWindows = [];
8888
}
8989

9090
$this->filesystem->remove($this->workspace);

Tests/Fixtures/MockStream/MockStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public function stream_open($path, $mode, $options, &$opened_path)
4141
*/
4242
public function url_stat($path, $flags)
4343
{
44-
return array();
44+
return [];
4545
}
4646
}

0 commit comments

Comments
 (0)