diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 2f829560..d68945fd 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -21,7 +21,7 @@ 'no_break_comment' => false, 'no_extra_blank_lines' => true, 'no_spaces_around_offset' => true, - 'no_trailing_comma_in_singleline' => true, + 'no_trailing_comma_in_singleline_array' => true, 'no_unused_imports' => true, 'no_useless_else' => true, 'no_useless_return' => true, diff --git a/spec/Gaufrette/FilesystemSpec.php b/spec/Gaufrette/FilesystemSpec.php index 6924bad5..f40b13b0 100644 --- a/spec/Gaufrette/FilesystemSpec.php +++ b/spec/Gaufrette/FilesystemSpec.php @@ -322,7 +322,7 @@ function it_delegates_checksum_calculation_to_adapter_when_adapter_is_checksum_c $extendedAdapter->read('filename')->shouldNotBeCalled(); $extendedAdapter->checksum('filename')->shouldBeCalled()->willReturn(12); - $this->checksum('filename')->shouldReturn("12"); + $this->checksum('filename')->shouldReturn('12'); } function it_delegates_mime_type_resolution_to_adapter_when_adapter_is_mime_type_provider(ExtendedAdapter $extendedAdapter) diff --git a/src/Gaufrette/Adapter/AsyncAwsS3.php b/src/Gaufrette/Adapter/AsyncAwsS3.php index 972cdf38..a11b7cd9 100644 --- a/src/Gaufrette/Adapter/AsyncAwsS3.php +++ b/src/Gaufrette/Adapter/AsyncAwsS3.php @@ -176,11 +176,11 @@ public function size(string $key): int return (int) $result->getContentLength(); } - public function mimeType(string $key): string + public function mimeType(string $key): string|bool { $result = $this->service->headObject($this->getOptions($key)); - return $result->getContentType(); + return $result->getContentType() ?: false; } /** diff --git a/src/Gaufrette/Adapter/AwsS3.php b/src/Gaufrette/Adapter/AwsS3.php index ace91dc4..9e9141de 100644 --- a/src/Gaufrette/Adapter/AwsS3.php +++ b/src/Gaufrette/Adapter/AwsS3.php @@ -173,7 +173,7 @@ public function size(string $key): int } } - public function mimeType(string $key): string|bool + public function mimeType(string $key): bool|string { try { $result = $this->service->headObject($this->getOptions($key)); diff --git a/src/Gaufrette/Adapter/AzureBlobStorage.php b/src/Gaufrette/Adapter/AzureBlobStorage.php index f94d03b2..5352e5bc 100644 --- a/src/Gaufrette/Adapter/AzureBlobStorage.php +++ b/src/Gaufrette/Adapter/AzureBlobStorage.php @@ -286,7 +286,7 @@ public function size(string $key): int /** * {@inheritdoc} */ - public function mimeType(string $key): string + public function mimeType(string $key): string|bool { $this->init(); list($containerName, $key) = $this->tokenizeKey($key); diff --git a/src/Gaufrette/Adapter/InMemory.php b/src/Gaufrette/Adapter/InMemory.php index 7f76b388..f87d6892 100644 --- a/src/Gaufrette/Adapter/InMemory.php +++ b/src/Gaufrette/Adapter/InMemory.php @@ -120,7 +120,7 @@ public function isDirectory(string $path): bool return false; } - public function mimeType(string $key): string + public function mimeType(string $key): bool|string { $fileInfo = new \finfo(FILEINFO_MIME_TYPE); diff --git a/src/Gaufrette/Adapter/Local.php b/src/Gaufrette/Adapter/Local.php index e19af1a1..e56da5f0 100644 --- a/src/Gaufrette/Adapter/Local.php +++ b/src/Gaufrette/Adapter/Local.php @@ -183,11 +183,12 @@ public function size(string $key): int } /** + * {@inheritdoc} * @throws \OutOfBoundsException If the computed path is out of the directory * @throws \InvalidArgumentException if the directory already exists * @throws \RuntimeException if the directory could not be created */ - public function mimeType(string $key): string + public function mimeType(string $key): bool|string { $fileInfo = new \finfo(FILEINFO_MIME_TYPE); diff --git a/src/Gaufrette/Adapter/MimeTypeProvider.php b/src/Gaufrette/Adapter/MimeTypeProvider.php index 53617bea..863e9a75 100644 --- a/src/Gaufrette/Adapter/MimeTypeProvider.php +++ b/src/Gaufrette/Adapter/MimeTypeProvider.php @@ -10,7 +10,7 @@ interface MimeTypeProvider { /** - * Returns the mime type of the specified key. + * @return false|string the mime type of the specified key. */ - public function mimeType(string $key): string; + public function mimeType(string $key): string|bool; } diff --git a/src/Gaufrette/FilesystemInterface.php b/src/Gaufrette/FilesystemInterface.php index 9a686ab8..57d16dd7 100644 --- a/src/Gaufrette/FilesystemInterface.php +++ b/src/Gaufrette/FilesystemInterface.php @@ -167,7 +167,7 @@ public function createFile($key); * * @param string $key * - * @return string + * @return string|false * * @throws \InvalidArgumentException If $key is invalid */