From ab3604b215f9afe902cbd5ee7f4fd4b3618d06ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin?= Date: Fri, 21 Apr 2023 15:38:02 +0200 Subject: [PATCH] Type interface for adapters --- src/Gaufrette/Adapter.php | 4 ++-- src/Gaufrette/Adapter/ListKeysAware.php | 6 +----- src/Gaufrette/Adapter/MetadataSupporter.php | 13 ++----------- src/Gaufrette/Adapter/MimeTypeProvider.php | 6 +----- src/Gaufrette/Adapter/SizeCalculator.php | 6 +----- 5 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/Gaufrette/Adapter.php b/src/Gaufrette/Adapter.php index 5b9c2d417..b4a412df4 100644 --- a/src/Gaufrette/Adapter.php +++ b/src/Gaufrette/Adapter.php @@ -22,7 +22,7 @@ public function read(string $key): string|bool; * * @return int|bool The number of bytes that were written into the file */ - public function write(string $key, string $content): int|bool; + public function write(string $key, mixed $content): int|bool; /** * Indicates whether the file exists. @@ -46,7 +46,7 @@ public function mtime(string $key): int|bool; /** * Deletes the file. */ - public function delete(string$key): bool; + public function delete(string $key): bool; /** * Renames a file. diff --git a/src/Gaufrette/Adapter/ListKeysAware.php b/src/Gaufrette/Adapter/ListKeysAware.php index bea2a3d8d..7b6d559d0 100644 --- a/src/Gaufrette/Adapter/ListKeysAware.php +++ b/src/Gaufrette/Adapter/ListKeysAware.php @@ -12,10 +12,6 @@ interface ListKeysAware /** * Lists keys beginning with pattern given * (no wildcard / regex matching). - * - * @param string $prefix - * - * @return array */ - public function listKeys($prefix = ''); + public function listKeys(string $prefix = ''): array; } diff --git a/src/Gaufrette/Adapter/MetadataSupporter.php b/src/Gaufrette/Adapter/MetadataSupporter.php index 16a4daeb4..19f319b5c 100644 --- a/src/Gaufrette/Adapter/MetadataSupporter.php +++ b/src/Gaufrette/Adapter/MetadataSupporter.php @@ -9,16 +9,7 @@ */ interface MetadataSupporter { - /** - * @param string $key - * @param array $content - */ - public function setMetadata($key, $content); + public function setMetadata(string $key, array $content); - /** - * @param string $key - * - * @return array - */ - public function getMetadata($key); + public function getMetadata(string $key): array; } diff --git a/src/Gaufrette/Adapter/MimeTypeProvider.php b/src/Gaufrette/Adapter/MimeTypeProvider.php index 16b1fc88a..53617beaf 100644 --- a/src/Gaufrette/Adapter/MimeTypeProvider.php +++ b/src/Gaufrette/Adapter/MimeTypeProvider.php @@ -11,10 +11,6 @@ interface MimeTypeProvider { /** * Returns the mime type of the specified key. - * - * @param string $key - * - * @return string */ - public function mimeType($key); + public function mimeType(string $key): string; } diff --git a/src/Gaufrette/Adapter/SizeCalculator.php b/src/Gaufrette/Adapter/SizeCalculator.php index 512537a5b..fa1e08100 100644 --- a/src/Gaufrette/Adapter/SizeCalculator.php +++ b/src/Gaufrette/Adapter/SizeCalculator.php @@ -11,10 +11,6 @@ interface SizeCalculator { /** * Returns the size of the specified key. - * - * @param string $key - * - * @return int */ - public function size($key); + public function size(string $key): int; }