diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 6cfcb8cb..5cfe54a6 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + @@ -642,9 +642,6 @@ - - - @@ -1147,12 +1144,6 @@ - - - - - - @@ -1167,13 +1158,12 @@ - - - - + + + @@ -1195,37 +1185,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - adapter->get($path, $context)]]> @@ -1243,13 +1207,6 @@ - - - - - - - @@ -1576,6 +1533,11 @@ + + + + + @@ -1627,23 +1589,7 @@ - - - - - - - - - - - - - - - - @@ -1654,9 +1600,6 @@ - - - @@ -1671,14 +1614,6 @@ - - - datatime]]> - - - - - @@ -1689,6 +1624,11 @@ + + + + + @@ -1829,9 +1769,6 @@ - - - @@ -1843,6 +1780,11 @@ + + + + + @@ -1889,7 +1831,6 @@ - @@ -2233,6 +2174,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2264,6 +2255,7 @@ + diff --git a/src/SonsOfPHP/Component/Filesystem/Adapter/NativeAdapter.php b/src/SonsOfPHP/Component/Filesystem/Adapter/NativeAdapter.php index 9b2ff184..392a0fa7 100644 --- a/src/SonsOfPHP/Component/Filesystem/Adapter/NativeAdapter.php +++ b/src/SonsOfPHP/Component/Filesystem/Adapter/NativeAdapter.php @@ -4,18 +4,17 @@ namespace SonsOfPHP\Component\Filesystem\Adapter; -use SonsOfPHP\Contract\Filesystem\Adapter\AdapterInterface; -use SonsOfPHP\Contract\Filesystem\Adapter\CopyAwareInterface; -use SonsOfPHP\Contract\Filesystem\Adapter\DirectoryAwareInterface; -use SonsOfPHP\Contract\Filesystem\Adapter\MoveAwareInterface; -use SonsOfPHP\Contract\Filesystem\ContextInterface; -use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; use SonsOfPHP\Component\Filesystem\Exception\FileNotFoundException; +use SonsOfPHP\Component\Filesystem\Exception\FilesystemException; use SonsOfPHP\Component\Filesystem\Exception\UnableToCopyFileException; use SonsOfPHP\Component\Filesystem\Exception\UnableToDeleteFileException; use SonsOfPHP\Component\Filesystem\Exception\UnableToMoveFileException; -use SonsOfPHP\Component\Filesystem\Exception\UnableToReadFileException; use SonsOfPHP\Component\Filesystem\Exception\UnableToWriteFileException; +use SonsOfPHP\Contract\Filesystem\Adapter\AdapterInterface; +use SonsOfPHP\Contract\Filesystem\Adapter\CopyAwareInterface; +use SonsOfPHP\Contract\Filesystem\Adapter\DirectoryAwareInterface; +use SonsOfPHP\Contract\Filesystem\Adapter\MoveAwareInterface; +use SonsOfPHP\Contract\Filesystem\ContextInterface; /** * The native adapter will use the underlying filesystem to store files. @@ -29,7 +28,7 @@ final class NativeAdapter implements AdapterInterface, CopyAwareInterface, Direc { public function __construct( private string $prefix, - private int $defaultPermissions = 0777, + private readonly int $defaultPermissions = 0o777, ) { $this->prefix = rtrim($prefix, '/'); } @@ -103,10 +102,8 @@ public function isDirectory(string $path, ?ContextInterface $context = null): bo public function makeDirectory(string $path, ?ContextInterface $context = null): void { - if (!$this->isDirectory($path)) { - if (false === mkdir($this->prefix . '/' . ltrim($path, '/'), $this->defaultPermissions, true)) { - throw new FilesystemException('Unable to create directory "' . $path . '"'); - } + if (!$this->isDirectory($path) && false === mkdir($this->prefix . '/' . ltrim($path, '/'), $this->defaultPermissions, true)) { + throw new FilesystemException('Unable to create directory "' . $path . '"'); } } diff --git a/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/NativeAdapterTest.php b/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/NativeAdapterTest.php index bef9616b..41c7f97e 100644 --- a/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/NativeAdapterTest.php +++ b/src/SonsOfPHP/Component/Filesystem/Tests/Adapter/NativeAdapterTest.php @@ -11,13 +11,8 @@ use SonsOfPHP\Contract\Filesystem\Adapter\CopyAwareInterface; use SonsOfPHP\Contract\Filesystem\Adapter\DirectoryAwareInterface; use SonsOfPHP\Contract\Filesystem\Adapter\MoveAwareInterface; -use SonsOfPHP\Contract\Filesystem\Exception\FilesystemExceptionInterface; use SonsOfPHP\Contract\Filesystem\Exception\FileNotFoundExceptionInterface; -use SonsOfPHP\Contract\Filesystem\Exception\UnableToCopyFileExceptionInterface; -use SonsOfPHP\Contract\Filesystem\Exception\UnableToDeleteFileExceptionInterface; -use SonsOfPHP\Contract\Filesystem\Exception\UnableToMoveFileExceptionInterface; -use SonsOfPHP\Contract\Filesystem\Exception\UnableToReadFileExceptionInterface; -use SonsOfPHP\Contract\Filesystem\Exception\UnableToWriteFileExceptionInterface; +use SonsOfPHP\Contract\Filesystem\Exception\FilesystemExceptionInterface; #[CoversClass(NativeAdapter::class)] final class NativeAdapterTest extends TestCase