From c2dc7fde0d0bc759e23f96e7570feb3d981a966b Mon Sep 17 00:00:00 2001 From: Pierre PLAZANET Date: Mon, 26 Feb 2024 17:23:43 +0100 Subject: [PATCH] refactor: fix phpstan lvl5 error for AwsS3 adapter (#713) --- phpstan-baseline.neon | 20 -------------------- src/Gaufrette/Adapter/AwsS3.php | 2 +- src/Gaufrette/Adapter/SizeCalculator.php | 4 ++-- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a1df5892..0dbc06c6 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,25 +1,5 @@ parameters: ignoreErrors: - - - message: "#^Call to function is_resource\\(\\) with string will always evaluate to false\\.$#" - count: 2 - path: src/Gaufrette/Adapter/AwsS3.php - - - - message: "#^Method Gaufrette\\\\Adapter\\\\AwsS3\\:\\:write\\(\\) should return bool\\|int but returns string\\.$#" - count: 1 - path: src/Gaufrette/Adapter/AwsS3.php - - - - message: "#^Method Gaufrette\\\\Adapter\\\\AwsS3\\:\\:size\\(\\) should return int but returns false\\.$#" - count: 1 - path: src/Gaufrette/Adapter/AwsS3.php - - - - message: "#^Method Gaufrette\\\\Adapter\\\\AwsS3\\:\\:mimeType\\(\\) should return string but returns false\\.$#" - count: 1 - path: src/Gaufrette/Adapter/AwsS3.php - - message: "#^Parameter \\$options of method Gaufrette\\\\Adapter\\\\AzureBlobStorage\\:\\:deleteContainer\\(\\) has invalid typehint type MicrosoftAzure\\\\Storage\\\\Blob\\\\Models\\\\DeleteContainerOptions\\.$#" count: 2 diff --git a/src/Gaufrette/Adapter/AwsS3.php b/src/Gaufrette/Adapter/AwsS3.php index 185446fd..decf8842 100644 --- a/src/Gaufrette/Adapter/AwsS3.php +++ b/src/Gaufrette/Adapter/AwsS3.php @@ -162,7 +162,7 @@ public function mtime(string $key): int|bool /** * {@inheritdoc} */ - public function size(string $key): int + public function size(string $key): bool|int { try { $result = $this->service->headObject($this->getOptions($key)); diff --git a/src/Gaufrette/Adapter/SizeCalculator.php b/src/Gaufrette/Adapter/SizeCalculator.php index fa1e0810..e08a9d2a 100644 --- a/src/Gaufrette/Adapter/SizeCalculator.php +++ b/src/Gaufrette/Adapter/SizeCalculator.php @@ -10,7 +10,7 @@ interface SizeCalculator { /** - * Returns the size of the specified key. + * @return false|int size of the specified key. */ - public function size(string $key): int; + public function size(string $key): bool|int; }