apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -15,19 +15,11 @@ use Base64Url\Base64Url;
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Exception\StoredObjectManagerException;
use DateTimeImmutable;
use DateTimeInterface;
use DateTimeZone;
use RuntimeException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
use Throwable;
use function array_key_exists;
use const OPENSSL_RAW_DATA;
final class StoredObjectManager implements StoredObjectManagerInterface
{
@@ -37,7 +29,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
public function __construct(private readonly HttpClientInterface $client, private readonly TempUrlGeneratorInterface $tempUrlGenerator) {}
public function getLastModified(StoredObject $document): DateTimeInterface
public function getLastModified(StoredObject $document): \DateTimeInterface
{
if ($this->hasCache($document)) {
$response = $this->getResponseFromCache($document);
@@ -69,7 +61,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
try {
$data = $response->getContent();
} catch (Throwable $e) {
} catch (\Throwable $e) {
throw StoredObjectManagerException::unableToGetResponseContent($e);
}
@@ -82,7 +74,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
self::ALGORITHM,
// TODO: Why using this library and not use base64_decode() ?
Base64Url::decode($document->getKeyInfos()['k']),
OPENSSL_RAW_DATA,
\OPENSSL_RAW_DATA,
pack('C*', ...$document->getIv())
);
@@ -105,7 +97,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
self::ALGORITHM,
// TODO: Why using this library and not use base64_decode() ?
Base64Url::decode($document->getKeyInfos()['k']),
OPENSSL_RAW_DATA,
\OPENSSL_RAW_DATA,
pack('C*', ...$document->getIv())
)
: $clearContent;
@@ -130,24 +122,23 @@ final class StoredObjectManager implements StoredObjectManagerInterface
throw StoredObjectManagerException::errorDuringHttpRequest($exception);
}
if ($response->getStatusCode() !== Response::HTTP_CREATED) {
if (Response::HTTP_CREATED !== $response->getStatusCode()) {
throw StoredObjectManagerException::invalidStatusCode($response->getStatusCode());
}
}
private function extractLastModifiedFromResponse(ResponseInterface $response): DateTimeImmutable
private function extractLastModifiedFromResponse(ResponseInterface $response): \DateTimeImmutable
{
$lastModifiedString = (($response->getHeaders()['last-modified'] ?? [])[0] ?? '');
$date = DateTimeImmutable::createFromFormat(
DateTimeImmutable::RFC7231,
$date = \DateTimeImmutable::createFromFormat(
\DateTimeImmutable::RFC7231,
$lastModifiedString,
new DateTimeZone('GMT')
new \DateTimeZone('GMT')
);
if (false === $date) {
throw new RuntimeException('the date from remote storage could not be parsed: '
. $lastModifiedString);
throw new \RuntimeException('the date from remote storage could not be parsed: '.$lastModifiedString);
}
return $date;
@@ -168,11 +159,11 @@ final class StoredObjectManager implements StoredObjectManagerInterface
)
->url
);
} catch (Throwable $e) {
} catch (\Throwable $e) {
throw StoredObjectManagerException::errorDuringHttpRequest($e);
}
if ($response->getStatusCode() !== Response::HTTP_OK) {
if (Response::HTTP_OK !== $response->getStatusCode()) {
throw StoredObjectManagerException::invalidStatusCode($response->getStatusCode());
}
@@ -190,7 +181,7 @@ final class StoredObjectManager implements StoredObjectManagerInterface
private function hasCache(StoredObject $document): bool
{
return array_key_exists($document->getUuid()->toString(), $this->inMemory);
return \array_key_exists($document->getUuid()->toString(), $this->inMemory);
}
private function hasKeysAndIv(StoredObject $storedObject): bool