diff --git a/src/Psl/Filesystem/copy.php b/src/Psl/Filesystem/copy.php index 30f3b614..dae5d6ee 100644 --- a/src/Psl/Filesystem/copy.php +++ b/src/Psl/Filesystem/copy.php @@ -65,5 +65,5 @@ function copy(string $source, string $destination, bool $overwrite = false): voi } // preserve executable permission bits - change_permissions($destination, get_permissions($destination) | (get_permissions($source) & 0111)); + change_permissions($destination, get_permissions($destination) | (get_permissions($source) & 0o111)); } diff --git a/src/Psl/Filesystem/create_directory.php b/src/Psl/Filesystem/create_directory.php index a89cf6fd..fff8a514 100644 --- a/src/Psl/Filesystem/create_directory.php +++ b/src/Psl/Filesystem/create_directory.php @@ -16,7 +16,7 @@ * * @throws Exception\RuntimeException If unable to create the directory. */ -function create_directory(string $directory, int $permissions = 0777): void +function create_directory(string $directory, int $permissions = 0o777): void { if (namespace\is_directory($directory)) { return; diff --git a/src/Psl/Filesystem/create_directory_for_file.php b/src/Psl/Filesystem/create_directory_for_file.php index a2e9a6ce..991cd160 100644 --- a/src/Psl/Filesystem/create_directory_for_file.php +++ b/src/Psl/Filesystem/create_directory_for_file.php @@ -13,7 +13,7 @@ * * @return non-empty-string */ -function create_directory_for_file(string $filename, int $permissions = 0777): string +function create_directory_for_file(string $filename, int $permissions = 0o777): string { $directory = namespace\get_directory($filename); namespace\create_directory($directory, $permissions); diff --git a/src/Psl/Hash/Context.php b/src/Psl/Hash/Context.php index 21c2f8b3..e31c0a3a 100644 --- a/src/Psl/Hash/Context.php +++ b/src/Psl/Hash/Context.php @@ -25,13 +25,13 @@ * * @psalm-immutable */ -final class Context +final readonly class Context { /** * @pure */ private function __construct( - private readonly HashContext $internalContext, + private HashContext $internalContext, ) { } diff --git a/tests/fixture/Point.php b/tests/fixture/Point.php index edbc5822..26131e63 100644 --- a/tests/fixture/Point.php +++ b/tests/fixture/Point.php @@ -4,11 +4,11 @@ namespace Psl\Tests\Fixture; -final class Point +final readonly class Point { public function __construct( - public readonly int $x, - public readonly int $y, + public int $x, + public int $y, ) { } } diff --git a/tests/unit/DateTime/DateTimeTest.php b/tests/unit/DateTime/DateTimeTest.php index a4048783..26eaaa09 100644 --- a/tests/unit/DateTime/DateTimeTest.php +++ b/tests/unit/DateTime/DateTimeTest.php @@ -34,7 +34,7 @@ public function testNow(): void public function testTodayAt(): void { $now = DateTime::now(); - $today = DateTime::todayAt(14, 00, 00); + $today = DateTime::todayAt(14, 0o0, 0o0); static::assertSame($now->getDate(), $today->getDate()); static::assertNotSame($now->getTime(), $today->getTime()); @@ -568,7 +568,7 @@ public function testWithTime() public function testTimezoneInfo() { $timeZone = Timezone::EuropeBrussels; - $date = DateTime::fromParts($timeZone, 2024, 01, 01); + $date = DateTime::fromParts($timeZone, 2024, 0o1, 0o1); static::assertSame(!$timeZone->getDaylightSavingTimeOffset($date)->isZero(), $date->isDaylightSavingTime()); static::assertEquals($timeZone->getOffset($date), $date->getTimezoneOffset()); @@ -576,7 +576,7 @@ public function testTimezoneInfo() public function testConvertTimeZone() { - $date = DateTime::fromParts(Timezone::EuropeBrussels, 2024, 01, 01, 1); + $date = DateTime::fromParts(Timezone::EuropeBrussels, 2024, 0o1, 0o1, 1); $converted = $date->convertToTimezone($london = Timezone::EuropeLondon); static::assertSame($london, $converted->getTimezone()); diff --git a/tests/unit/File/ReadWriteHandleTest.php b/tests/unit/File/ReadWriteHandleTest.php index 7cd833ba..70cd7337 100644 --- a/tests/unit/File/ReadWriteHandleTest.php +++ b/tests/unit/File/ReadWriteHandleTest.php @@ -114,7 +114,7 @@ public function testAppendToANonWritableFile(): void } $temporary_file = Filesystem\create_temporary_file(); - Filesystem\change_permissions($temporary_file, 0555); + Filesystem\change_permissions($temporary_file, 0o555); $this->expectException(File\Exception\NotWritableException::class); $this->expectExceptionMessage('File "' . $temporary_file . '" is not writable.'); @@ -129,7 +129,7 @@ public function testOpenNonReadableFile(): void } $temporary_file = Filesystem\create_temporary_file(); - Filesystem\change_permissions($temporary_file, 0333); + Filesystem\change_permissions($temporary_file, 0o333); $this->expectException(File\Exception\NotReadableException::class); $this->expectExceptionMessage('File "' . $temporary_file . '" is not readable.'); @@ -146,7 +146,7 @@ public function testThrowsWhenCreatingFile(): void $temporary_file = Filesystem\create_temporary_file(); Filesystem\delete_file($temporary_file); Filesystem\create_directory($temporary_file); - Filesystem\change_permissions($temporary_file, 0555); + Filesystem\change_permissions($temporary_file, 0o555); $file = $temporary_file . Filesystem\SEPARATOR . 'foo'; diff --git a/tests/unit/File/ReadWriteTest.php b/tests/unit/File/ReadWriteTest.php index 424b4053..ad7080bf 100644 --- a/tests/unit/File/ReadWriteTest.php +++ b/tests/unit/File/ReadWriteTest.php @@ -96,8 +96,8 @@ public function testWriteFileThrowsForNonWritableFiles(): void { $file = Str\join([$this->directory, 'write.txt'], Filesystem\SEPARATOR); Filesystem\create_file($file); - $permissions = Filesystem\get_permissions($file) & 0777; - Filesystem\change_permissions($file, 0111); + $permissions = Filesystem\get_permissions($file) & 0o777; + Filesystem\change_permissions($file, 0o111); try { $this->expectException(File\Exception\NotWritableException::class); @@ -132,7 +132,7 @@ public function testThrowsWhenDirectoryCreationFails(): void } $target_directory = Env\temp_dir() . DIRECTORY_SEPARATOR . 'you-shall-not-pass'; - Filesystem\create_directory($target_directory, 0000); + Filesystem\create_directory($target_directory, 0o000); $target_file = $target_directory . DIRECTORY_SEPARATOR . 'fails-on-subdir-creation' . DIRECTORY_SEPARATOR . 'somefile.txt'; diff --git a/tests/unit/File/WriteHandleTest.php b/tests/unit/File/WriteHandleTest.php index 2048dfd3..03591499 100644 --- a/tests/unit/File/WriteHandleTest.php +++ b/tests/unit/File/WriteHandleTest.php @@ -36,7 +36,7 @@ public function testAppendToNonExistingFile(): void public function testAppendToANonWritableFile(): void { $temporary_file = Filesystem\create_temporary_file(); - Filesystem\change_permissions($temporary_file, 0555); + Filesystem\change_permissions($temporary_file, 0o555); $this->expectException(File\Exception\NotWritableException::class); $this->expectExceptionMessage('is not writable.'); @@ -70,7 +70,7 @@ public function testThrowsWhenCreatingFile(): void $temporary_file = Filesystem\create_temporary_file(); Filesystem\delete_file($temporary_file); Filesystem\create_directory($temporary_file); - Filesystem\change_permissions($temporary_file, 0555); + Filesystem\change_permissions($temporary_file, 0o555); $file = $temporary_file . Filesystem\SEPARATOR . 'foo'; @@ -100,7 +100,7 @@ public function testThrowsWhenDirectoryCreationFails(): void } $target_directory = Env\temp_dir() . DIRECTORY_SEPARATOR . 'you-shall-not-pass'; - Filesystem\create_directory($target_directory, 0000); + Filesystem\create_directory($target_directory, 0o000); $target_file = $target_directory . DIRECTORY_SEPARATOR . 'fails-on-subdir-creation' . DIRECTORY_SEPARATOR . 'somefile.txt'; diff --git a/tests/unit/Filesystem/AbstractFilesystemTest.php b/tests/unit/Filesystem/AbstractFilesystemTest.php index 3a6a905a..3fb98c85 100644 --- a/tests/unit/Filesystem/AbstractFilesystemTest.php +++ b/tests/unit/Filesystem/AbstractFilesystemTest.php @@ -35,7 +35,7 @@ protected function setUp(): void $this->directory = Str\join([$this->cacheDirectory, $this->function], Filesystem\SEPARATOR); Filesystem\create_directory($this->directory); - $this->directoryPermissions = Filesystem\get_permissions($this->directory) & 0777; + $this->directoryPermissions = Filesystem\get_permissions($this->directory) & 0o777; static::assertTrue(Filesystem\exists($this->directory)); static::assertTrue(Filesystem\is_directory($this->directory)); diff --git a/tests/unit/Filesystem/CopyTest.php b/tests/unit/Filesystem/CopyTest.php index 9a2333c7..f086ef6e 100644 --- a/tests/unit/Filesystem/CopyTest.php +++ b/tests/unit/Filesystem/CopyTest.php @@ -46,7 +46,7 @@ public function testCopyExecutableBits(): void $shell_file = Str\join([$this->directory, 'hello.sh'], Filesystem\SEPARATOR); Filesystem\create_file($shell_file); - Filesystem\change_permissions($shell_file, 0557); + Filesystem\change_permissions($shell_file, 0o557); static::assertTrue(Filesystem\is_executable($shell_file)); diff --git a/tests/unit/Filesystem/DirectoryTest.php b/tests/unit/Filesystem/DirectoryTest.php index 5c41c3fa..7b7bc788 100644 --- a/tests/unit/Filesystem/DirectoryTest.php +++ b/tests/unit/Filesystem/DirectoryTest.php @@ -71,7 +71,7 @@ public function testReadDirectoryThrowsIfNotDirectory(): void public function testReadDirectoryThrowsIfNotReadable(): void { - Filesystem\change_permissions($this->directory, 0077); + Filesystem\change_permissions($this->directory, 0o077); $this->expectException(Filesystem\Exception\NotReadableException::class); $this->expectExceptionMessage('Directory "' . $this->directory . '" is not readable.'); @@ -81,7 +81,7 @@ public function testReadDirectoryThrowsIfNotReadable(): void } finally { // restore $this->directory permissions, otherwise we won't // be able to delete it. - Filesystem\change_permissions($this->directory, 0777); + Filesystem\change_permissions($this->directory, 0o777); } } diff --git a/tests/unit/Filesystem/FileTest.php b/tests/unit/Filesystem/FileTest.php index 228d5c97..f8ded392 100644 --- a/tests/unit/Filesystem/FileTest.php +++ b/tests/unit/Filesystem/FileTest.php @@ -174,8 +174,8 @@ public function testFileSizeThrowsForNonReadableFile(): void { $filename = Str\join([$this->directory, 'non-readable.txt'], Filesystem\SEPARATOR); Filesystem\create_file($filename); - $permissions = Filesystem\get_permissions($filename) & 0777; - Filesystem\change_permissions($filename, 0111); + $permissions = Filesystem\get_permissions($filename) & 0o777; + Filesystem\change_permissions($filename, 0o111); static::assertFalse(Filesystem\is_readable($filename)); @@ -193,8 +193,8 @@ public function testCopyThrowsForNonReadableFile(): void { $file = Str\join([$this->directory, 'non-readable.txt'], Filesystem\SEPARATOR); Filesystem\create_file($file); - $permissions = Filesystem\get_permissions($file) & 0777; - Filesystem\change_permissions($file, 0111); + $permissions = Filesystem\get_permissions($file) & 0o777; + Filesystem\change_permissions($file, 0o111); static::assertFalse(Filesystem\is_readable($file)); diff --git a/tests/unit/Filesystem/PermissionsTest.php b/tests/unit/Filesystem/PermissionsTest.php index 6c67c1aa..8ee5491d 100644 --- a/tests/unit/Filesystem/PermissionsTest.php +++ b/tests/unit/Filesystem/PermissionsTest.php @@ -17,34 +17,34 @@ public function testChangePermissions(): void Filesystem\create_file($filename); - $permissions = Filesystem\get_permissions($filename) & 0777; + $permissions = Filesystem\get_permissions($filename) & 0o777; try { - Filesystem\change_permissions($filename, 0444); + Filesystem\change_permissions($filename, 0o444); static::assertTrue(Filesystem\is_readable($filename)); static::assertFalse(Filesystem\is_writable($filename)); static::assertFalse(Filesystem\is_executable($filename)); - Filesystem\change_permissions($filename, 0222); + Filesystem\change_permissions($filename, 0o222); static::assertTrue(Filesystem\is_writable($filename)); static::assertFalse(Filesystem\is_readable($filename)); static::assertFalse(Filesystem\is_executable($filename)); - Filesystem\change_permissions($filename, 0111); + Filesystem\change_permissions($filename, 0o111); static::assertTrue(Filesystem\is_executable($filename)); static::assertFalse(Filesystem\is_writable($filename)); static::assertFalse(Filesystem\is_readable($filename)); - Filesystem\change_permissions($filename, 0666); + Filesystem\change_permissions($filename, 0o666); static::assertTrue(Filesystem\is_writable($filename)); static::assertTrue(Filesystem\is_readable($filename)); static::assertFalse(Filesystem\is_executable($filename)); - Filesystem\change_permissions($filename, 0777); + Filesystem\change_permissions($filename, 0o777); static::assertTrue(Filesystem\is_writable($filename)); static::assertTrue(Filesystem\is_readable($filename)); @@ -61,7 +61,7 @@ public function testChangePermissionsThrowsForNonExistingFile(): void $this->expectException(Filesystem\Exception\NotFoundException::class); $this->expectExceptionMessage('Node "' . $filename . '" is not found.'); - Filesystem\change_permissions($filename, 0111); + Filesystem\change_permissions($filename, 0o111); } public function testGetPermissionsThrowsForNonExistingFile(): void