From 64b74aa6c13dd059c3c09eb873b93ec175ac0df0 Mon Sep 17 00:00:00 2001 From: Marcello Duarte Date: Fri, 31 Jul 2026 17:30:15 +0100 Subject: [PATCH] Correct imageSize in the image contract, which is a string Every provider that implements ImageProviderInterface names its own sizes, and they are all strings: "1K", "2K" and "4K" on Google, "1024x1024" on OpenAI. The docblock said int, which no implementation has ever honoured. Google's provider passes "2K" today, so Psalm rejected the implementation as soon as the provider's own docblock was made honest. Correcting the contract rather than the provider closes it at the source. Docblock only, so no behaviour changes. --- src/Contracts/ImageProviderInterface.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Contracts/ImageProviderInterface.php b/src/Contracts/ImageProviderInterface.php index c42461b..7e5a8cd 100644 --- a/src/Contracts/ImageProviderInterface.php +++ b/src/Contracts/ImageProviderInterface.php @@ -25,11 +25,14 @@ interface ImageProviderInterface /** * Generate images from a text prompt. * + * Providers name their own sizes, so `imageSize` is whatever string the provider + * understands: "1K", "2K" and "4K" on Google, "1024x1024" on OpenAI. + * * @param string $prompt The image generation prompt * @param array{ * model?: string, * aspectRatio?: string, - * imageSize?: int, + * imageSize?: string, * numberOfImages?: int, * } $options Provider-specific options * @return array{images: array} @@ -44,7 +47,7 @@ public function generateImage(string $prompt, array $options = []): array; * @param array{ * model?: string, * aspectRatio?: string, - * imageSize?: int, + * imageSize?: string, * } $options Provider-specific options * @return array{images: array, text: string} */