Skip to content

Commit 633c6fd

Browse files
keradusnicolas-grekas
authored andcommitted
chore: PHP CS Fixer - restore PHP / PHPUnit rulesets
1 parent 7d2dac3 commit 633c6fd

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

Filesystem.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
7070

7171
if ($originIsLocal) {
7272
// Like `cp`, preserve executable permission bits
73-
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
73+
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0o111));
7474

7575
// Like `cp`, preserve the file modification time
7676
self::box('touch', $targetFile, filemtime($originFile));
@@ -87,7 +87,7 @@ public function copy(string $originFile, string $targetFile, bool $overwriteNewe
8787
*
8888
* @throws IOException On any directory creation failure
8989
*/
90-
public function mkdir(string|iterable $dirs, int $mode = 0777): void
90+
public function mkdir(string|iterable $dirs, int $mode = 0o777): void
9191
{
9292
foreach ($this->toIterable($dirs) as $dir) {
9393
if (is_dir($dir)) {
@@ -208,7 +208,7 @@ private static function doRemove(array $files, bool $isRecursive): void
208208
*
209209
* @throws IOException When the change fails
210210
*/
211-
public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool $recursive = false): void
211+
public function chmod(string|iterable $files, int $mode, int $umask = 0o000, bool $recursive = false): void
212212
{
213213
foreach ($this->toIterable($files) as $file) {
214214
if (!self::box('chmod', $file, $mode & ~$umask)) {
@@ -670,13 +670,13 @@ public function dumpFile(string $filename, $content): void
670670
throw new IOException(\sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
671671
}
672672

673-
self::box('chmod', $tmpFile, self::box('fileperms', $filename) ?: 0666 & ~umask());
673+
self::box('chmod', $tmpFile, self::box('fileperms', $filename) ?: 0o666 & ~umask());
674674

675675
$this->rename($tmpFile, $filename, true);
676676
} finally {
677677
if (file_exists($tmpFile)) {
678678
if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
679-
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
679+
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0o200);
680680
}
681681

682682
self::box('unlink', $tmpFile);

Tests/FilesystemTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testCopyUnreadableFileFails()
6464
file_put_contents($sourceFilePath, 'SOURCE FILE');
6565

6666
// make sure target cannot be read
67-
$this->filesystem->chmod($sourceFilePath, 0222);
67+
$this->filesystem->chmod($sourceFilePath, 0o222);
6868

6969
$this->filesystem->copy($sourceFilePath, $targetFilePath);
7070
}
@@ -146,7 +146,7 @@ public function testCopyWithOverrideWithReadOnlyTargetFails()
146146
touch($targetFilePath, $modificationTime);
147147

148148
// make sure target is read-only
149-
$this->filesystem->chmod($targetFilePath, 0444);
149+
$this->filesystem->chmod($targetFilePath, 0o444);
150150

151151
$this->filesystem->copy($sourceFilePath, $targetFilePath, true);
152152
}
@@ -359,7 +359,7 @@ public function testRemoveThrowsExceptionOnPermissionDenied()
359359
mkdir($basePath);
360360
$file = $basePath.\DIRECTORY_SEPARATOR.'file';
361361
touch($file);
362-
chmod($basePath, 0400);
362+
chmod($basePath, 0o400);
363363

364364
try {
365365
$this->filesystem->remove($file);
@@ -369,7 +369,7 @@ public function testRemoveThrowsExceptionOnPermissionDenied()
369369
$this->assertStringContainsString('Permission denied', $e->getMessage());
370370
} finally {
371371
// Make sure we can clean up this file
372-
chmod($basePath, 0777);
372+
chmod($basePath, 0o777);
373373
}
374374
}
375375

@@ -476,8 +476,8 @@ public function testChmodChangesFileMode()
476476
$file = $dir.\DIRECTORY_SEPARATOR.'file';
477477
touch($file);
478478

479-
$this->filesystem->chmod($file, 0400);
480-
$this->filesystem->chmod($dir, 0753);
479+
$this->filesystem->chmod($file, 0o400);
480+
$this->filesystem->chmod($dir, 0o753);
481481

482482
$this->assertFilePermissions(753, $dir);
483483
$this->assertFilePermissions(400, $file);
@@ -492,8 +492,8 @@ public function testChmodRecursive()
492492
$file = $dir.\DIRECTORY_SEPARATOR.'file';
493493
touch($file);
494494

495-
$this->filesystem->chmod($file, 0400, 0000, true);
496-
$this->filesystem->chmod($dir, 0753, 0000, true);
495+
$this->filesystem->chmod($file, 0o400, 0o000, true);
496+
$this->filesystem->chmod($dir, 0o753, 0o000, true);
497497

498498
$this->assertFilePermissions(753, $dir);
499499
$this->assertFilePermissions(753, $file);
@@ -506,7 +506,7 @@ public function testChmodAppliesUmask()
506506
$file = $this->workspace.\DIRECTORY_SEPARATOR.'file';
507507
touch($file);
508508

509-
$this->filesystem->chmod($file, 0770, 0022);
509+
$this->filesystem->chmod($file, 0o770, 0o022);
510510
$this->assertFilePermissions(750, $file);
511511
}
512512

@@ -521,7 +521,7 @@ public function testChmodChangesModeOfArrayOfFiles()
521521
mkdir($directory);
522522
touch($file);
523523

524-
$this->filesystem->chmod($files, 0753);
524+
$this->filesystem->chmod($files, 0o753);
525525

526526
$this->assertFilePermissions(753, $file);
527527
$this->assertFilePermissions(753, $directory);
@@ -538,7 +538,7 @@ public function testChmodChangesModeOfTraversableFileObject()
538538
mkdir($directory);
539539
touch($file);
540540

541-
$this->filesystem->chmod($files, 0753);
541+
$this->filesystem->chmod($files, 0o753);
542542

543543
$this->assertFilePermissions(753, $file);
544544
$this->assertFilePermissions(753, $directory);
@@ -553,9 +553,9 @@ public function testChmodChangesZeroModeOnSubdirectoriesOnRecursive()
553553

554554
mkdir($directory);
555555
mkdir($subdirectory);
556-
chmod($subdirectory, 0000);
556+
chmod($subdirectory, 0o000);
557557

558-
$this->filesystem->chmod($directory, 0753, 0000, true);
558+
$this->filesystem->chmod($directory, 0o753, 0o000, true);
559559

560560
$this->assertFilePermissions(753, $subdirectory);
561561
}
@@ -1294,7 +1294,7 @@ public function testMirrorCopiesLinkedDirectoryContents()
12941294

12951295
$sourcePath = $this->workspace.\DIRECTORY_SEPARATOR.'source'.\DIRECTORY_SEPARATOR;
12961296

1297-
mkdir($sourcePath.'nested/', 0777, true);
1297+
mkdir($sourcePath.'nested/', 0o777, true);
12981298
file_put_contents($sourcePath.'/nested/file1.txt', 'FILE1');
12991299
// Note: We symlink directory, not file
13001300
symlink($sourcePath.'nested', $sourcePath.'link1');
@@ -1315,7 +1315,7 @@ public function testMirrorCopiesRelativeLinkedContents()
13151315
$sourcePath = $this->workspace.\DIRECTORY_SEPARATOR.'source'.\DIRECTORY_SEPARATOR;
13161316
$oldPath = getcwd();
13171317

1318-
mkdir($sourcePath.'nested/', 0777, true);
1318+
mkdir($sourcePath.'nested/', 0o777, true);
13191319
file_put_contents($sourcePath.'/nested/file1.txt', 'FILE1');
13201320
// Note: Create relative symlink
13211321
chdir($sourcePath);
@@ -1565,7 +1565,7 @@ public function testDumpFile()
15651565

15661566
// skip mode check on Windows
15671567
if ('\\' !== \DIRECTORY_SEPARATOR) {
1568-
$oldMask = umask(0002);
1568+
$oldMask = umask(0o002);
15691569
}
15701570

15711571
$this->filesystem->dumpFile($filename, 'bar');
@@ -1661,7 +1661,7 @@ public function testAppendToFile()
16611661

16621662
// skip mode check on Windows
16631663
if ('\\' !== \DIRECTORY_SEPARATOR) {
1664-
$oldMask = umask(0002);
1664+
$oldMask = umask(0o002);
16651665
}
16661666

16671667
$this->filesystem->dumpFile($filename, 'foo');
@@ -1684,7 +1684,7 @@ public function testAppendToFileWithResource()
16841684

16851685
// skip mode check on Windows
16861686
if ('\\' !== \DIRECTORY_SEPARATOR) {
1687-
$oldMask = umask(0002);
1687+
$oldMask = umask(0o002);
16881688
}
16891689

16901690
$this->filesystem->dumpFile($filename, 'foo');
@@ -1767,7 +1767,7 @@ public function testAppendToFileCreateTheFileIfNotExists()
17671767

17681768
// skip mode check on Windows
17691769
if ('\\' !== \DIRECTORY_SEPARATOR) {
1770-
$oldMask = umask(0002);
1770+
$oldMask = umask(0o002);
17711771
}
17721772

17731773
$this->filesystem->appendToFile($filename, 'bar');
@@ -1800,7 +1800,7 @@ public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()
18001800

18011801
$filename = $this->workspace.\DIRECTORY_SEPARATOR.'foo.txt';
18021802
file_put_contents($filename, 'FOO BAR');
1803-
chmod($filename, 0745);
1803+
chmod($filename, 0o745);
18041804

18051805
$this->filesystem->dumpFile($filename, 'bar');
18061806

@@ -1811,13 +1811,13 @@ public function testDumpFileCleansUpAfterFailure()
18111811
{
18121812
$targetFile = $this->workspace.'/dump-file';
18131813
$this->filesystem->touch($targetFile);
1814-
$this->filesystem->chmod($targetFile, 0444);
1814+
$this->filesystem->chmod($targetFile, 0o444);
18151815

18161816
try {
18171817
$this->filesystem->dumpFile($targetFile, 'any content');
18181818
} catch (IOException $e) {
18191819
} finally {
1820-
$this->filesystem->chmod($targetFile, 0666);
1820+
$this->filesystem->chmod($targetFile, 0o666);
18211821
}
18221822

18231823
$this->assertSame([$targetFile], glob($this->workspace.'/*'));
@@ -1868,7 +1868,7 @@ public function testCopyShouldKeepExecutionPermission()
18681868
$targetFilePath = $this->workspace.\DIRECTORY_SEPARATOR.'copy_target_file';
18691869

18701870
file_put_contents($sourceFilePath, 'SOURCE FILE');
1871-
chmod($sourceFilePath, 0745);
1871+
chmod($sourceFilePath, 0o745);
18721872

18731873
$this->filesystem->copy($sourceFilePath, $targetFilePath);
18741874

Tests/FilesystemTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function setUp(): void
5959
$this->umask = umask(0);
6060
$this->filesystem = new Filesystem();
6161
$this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand();
62-
mkdir($this->workspace, 0777, true);
62+
mkdir($this->workspace, 0o777, true);
6363
$this->workspace = realpath($this->workspace);
6464
}
6565

0 commit comments

Comments
 (0)