Skip to content

Commit

Permalink
cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes committed Aug 24, 2024
1 parent 113098a commit dc250c8
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 96 deletions.
148 changes: 70 additions & 78 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.22.0@fe2c67ec89f358940f90db05efd2d663388b45a6">
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
<file src="src/SonsOfPHP/Bard/Tests/JsonFileTest.php">
<UnusedClass>
<code><![CDATA[JsonFileTest]]></code>
Expand Down Expand Up @@ -642,9 +642,6 @@
<MissingTemplateParam>
<code><![CDATA[IteratorAggregate]]></code>
</MissingTemplateParam>
<PossiblyUnusedMethod>
<code><![CDATA[jsonSerialize]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/SonsOfPHP/Component/Cqrs/AbstractQueryMessage.php">
<UnusedClass>
Expand Down Expand Up @@ -1147,12 +1144,6 @@
<code><![CDATA[MockToggle]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Adapter/AdapterInterface.php">
<UndefinedDocblockClass>
<code><![CDATA[FileNotFouneException]]></code>
<code><![CDATA[string|resouce]]></code>
</UndefinedDocblockClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Adapter/ChainAdapter.php">
<UnusedClass>
<code><![CDATA[ChainAdapter]]></code>
Expand All @@ -1167,13 +1158,12 @@
</UnusedForeachValue>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Adapter/NativeAdapter.php">
<UndefinedVariable>
<code><![CDATA[$filename]]></code>
<code><![CDATA[$filename]]></code>
</UndefinedVariable>
<UnusedClass>
<code><![CDATA[NativeAdapter]]></code>
</UnusedClass>
<UnusedParam>
<code><![CDATA[$context]]></code>
</UnusedParam>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Adapter/NullAdapter.php">
<UnusedClass>
Expand All @@ -1195,37 +1185,11 @@
<code><![CDATA[Context]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/ContextInterface.php">
<MissingTemplateParam>
<code><![CDATA[ArrayAccess]]></code>
<code><![CDATA[IteratorAggregate]]></code>
</MissingTemplateParam>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Exception/UnableToCopyFileException.php">
<UnusedClass>
<code><![CDATA[UnableToCopyFileException]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Exception/UnableToDeleteDirectoryException.php">
<UnusedClass>
<code><![CDATA[UnableToDeleteDirectoryException]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Exception/UnableToDeleteFileException.php">
<UnusedClass>
<code><![CDATA[UnableToDeleteFileException]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Exception/UnableToMoveFileException.php">
<UnusedClass>
<code><![CDATA[UnableToMoveFileException]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Exception/UnableToWriteFileException.php">
<UnusedClass>
<code><![CDATA[UnableToWriteFileException]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Filesystem.php">
<InvalidReturnStatement>
<code><![CDATA[$this->adapter->get($path, $context)]]></code>
Expand All @@ -1243,13 +1207,6 @@
<code><![CDATA[Filesystem]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/FilesystemInterface.php">
<PossiblyUnusedMethod>
<code><![CDATA[exists]]></code>
<code><![CDATA[move]]></code>
<code><![CDATA[read]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/SonsOfPHP/Component/Filesystem/Tests/Adapter/ChainAdapterTest.php">
<UnusedClass>
<code><![CDATA[ChainAdapterTest]]></code>
Expand Down Expand Up @@ -1576,6 +1533,11 @@
<code><![CDATA[GroupIdEnricher]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Logger/Enricher/HostnameEnricher.php">
<UnusedClass>
<code><![CDATA[HostnameEnricher]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Logger/Enricher/InodeEnricher.php">
<UnusedClass>
<code><![CDATA[InodeEnricher]]></code>
Expand Down Expand Up @@ -1627,23 +1589,7 @@
<code><![CDATA[MockFilter]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Logger/Formatter/SimpleFormatter.php">
<UnusedClass>
<code><![CDATA[SimpleFormatter]]></code>
</UnusedClass>
<UnusedVariable>
<code><![CDATA[$message]]></code>
</UnusedVariable>
</file>
<file src="src/SonsOfPHP/Component/Logger/Handler/AbstractHandler.php">
<UndefinedMethod>
<code><![CDATA[doHandle]]></code>
</UndefinedMethod>
</file>
<file src="src/SonsOfPHP/Component/Logger/Handler/FileHandler.php">
<PossiblyUnusedParam>
<code><![CDATA[$record]]></code>
</PossiblyUnusedParam>
<UnusedClass>
<code><![CDATA[FileHandler]]></code>
</UnusedClass>
Expand All @@ -1654,9 +1600,6 @@
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Logger/Handler/StreamHandler.php">
<PossiblyUnusedParam>
<code><![CDATA[$record]]></code>
</PossiblyUnusedParam>
<UnusedClass>
<code><![CDATA[StreamHandler]]></code>
</UnusedClass>
Expand All @@ -1671,14 +1614,6 @@
<code><![CDATA[Logger]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Logger/Record.php">
<UndefinedPropertyAssignment>
<code><![CDATA[$that->datatime]]></code>
</UndefinedPropertyAssignment>
<UndefinedVariable>
<code><![CDATA[$datatime]]></code>
</UndefinedVariable>
</file>
<file src="src/SonsOfPHP/Component/Logger/Tests/ContextTest.php">
<UnusedClass>
<code><![CDATA[ContextTest]]></code>
Expand All @@ -1689,6 +1624,11 @@
<code><![CDATA[GroupIdEnricherTest]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Logger/Tests/Enricher/HostnameEnricherTest.php">
<UnusedClass>
<code><![CDATA[HostnameEnricherTest]]></code>
</UnusedClass>
</file>
<file src="src/SonsOfPHP/Component/Logger/Tests/Enricher/InodeEnricherTest.php">
<UnusedClass>
<code><![CDATA[InodeEnricherTest]]></code>
Expand Down Expand Up @@ -1829,9 +1769,6 @@
<UnusedClass>
<code><![CDATA[NativeMailTransport]]></code>
</UnusedClass>
<UnusedFunctionCall>
<code><![CDATA[mail]]></code>
</UnusedFunctionCall>
</file>
<file src="src/SonsOfPHP/Component/Mailer/Transport/NullTransport.php">
<UnusedClass>
Expand All @@ -1843,6 +1780,11 @@
<code><![CDATA[toFloat]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/SonsOfPHP/Component/Money/Currency.php">
<PossiblyUnusedMethod>
<code><![CDATA[__callStatic]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/SonsOfPHP/Component/Money/CurrencyProvider/ChainCurrencyProvider.php">
<InvalidReturnType>
<code><![CDATA[iterable]]></code>
Expand Down Expand Up @@ -1889,7 +1831,6 @@
<PossiblyUnusedMethod>
<code><![CDATA[__callStatic]]></code>
<code><![CDATA[compare]]></code>
<code><![CDATA[jsonSerialize]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/SonsOfPHP/Component/Money/Operator/Amount/AddAmountOperator.php">
Expand Down Expand Up @@ -2233,6 +2174,56 @@
<code><![CDATA[getFeatureToggleByKey]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/SonsOfPHP/Contract/Filesystem/Adapter/AdapterInterface.php">
<InvalidThrow>
<code><![CDATA[FilesystemExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
</InvalidThrow>
<UndefinedDocblockClass>
<code><![CDATA[FileNotFouneExceptionInterface]]></code>
<code><![CDATA[string|resouce]]></code>
</UndefinedDocblockClass>
</file>
<file src="src/SonsOfPHP/Contract/Filesystem/Adapter/CopyAwareInterface.php">
<InvalidThrow>
<code><![CDATA[FileNotFoundExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
</InvalidThrow>
</file>
<file src="src/SonsOfPHP/Contract/Filesystem/Adapter/DirectoryAwareInterface.php">
<InvalidThrow>
<code><![CDATA[FilesystemExceptionInterface]]></code>
</InvalidThrow>
</file>
<file src="src/SonsOfPHP/Contract/Filesystem/Adapter/MoveAwareInterface.php">
<InvalidThrow>
<code><![CDATA[FileNotFoundExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
</InvalidThrow>
</file>
<file src="src/SonsOfPHP/Contract/Filesystem/ContextInterface.php">
<MissingTemplateParam>
<code><![CDATA[ArrayAccess]]></code>
<code><![CDATA[IteratorAggregate]]></code>
</MissingTemplateParam>
</file>
<file src="src/SonsOfPHP/Contract/Filesystem/FilesystemInterface.php">
<InvalidThrow>
<code><![CDATA[FilesystemExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
<code><![CDATA[FilesystemExceptionInterface]]></code>
</InvalidThrow>
<PossiblyUnusedMethod>
<code><![CDATA[exists]]></code>
<code><![CDATA[move]]></code>
<code><![CDATA[read]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/SonsOfPHP/Contract/HttpHandler/MiddlewareStackInterface.php">
<InvalidThrow>
<code><![CDATA[HttpHandlerExceptionInterface]]></code>
Expand Down Expand Up @@ -2264,6 +2255,7 @@
<code><![CDATA[withChannel]]></code>
<code><![CDATA[withDatetime]]></code>
<code><![CDATA[withLevel]]></code>
<code><![CDATA[withMessage]]></code>
</PossiblyUnusedMethod>
</file>
<file src="src/SonsOfPHP/Contract/Mailer/AddressInterface.php">
Expand Down
21 changes: 9 additions & 12 deletions src/SonsOfPHP/Component/Filesystem/Adapter/NativeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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, '/');
}
Expand Down Expand Up @@ -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 . '"');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dc250c8

Please sign in to comment.