Skip to content

Commit

Permalink
apply mago fix
Browse files Browse the repository at this point in the history
Signed-off-by: azjezz <azjezz@protonmail.com>
  • Loading branch information
azjezz committed Dec 14, 2024
1 parent 1957c18 commit 5bbaa93
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/copy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/create_directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Psl/Filesystem/create_directory_for_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/DateTime/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -568,15 +568,15 @@ 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());
}

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());
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/File/ReadWriteHandleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -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.');
Expand All @@ -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';

Expand Down
6 changes: 3 additions & 3 deletions tests/unit/File/ReadWriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/File/WriteHandleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Filesystem/AbstractFilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Filesystem/CopyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Filesystem/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -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);
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Filesystem/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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));

Expand Down
14 changes: 7 additions & 7 deletions tests/unit/Filesystem/PermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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
Expand Down

0 comments on commit 5bbaa93

Please sign in to comment.