From 29a22247ca203c3a78e5285b672aa4568a030205 Mon Sep 17 00:00:00 2001 From: Tomasz Kryszan Date: Tue, 5 Dec 2023 08:52:22 +0100 Subject: [PATCH] Fixes after review --- phpstan-baseline.neon | 5 ----- src/lib/FieldType/Image/Type.php | 3 ++- src/lib/FieldType/Validator/ImageValidator.php | 3 ++- .../Content/FieldValue/Converter/ImageConverter.php | 2 +- .../Repository/FieldType/ImageIntegrationTest.php | 11 +++++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 86a64112d8..e6fbcd7697 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -30625,11 +30625,6 @@ parameters: count: 1 path: tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php - - - message: "#^Method Ibexa\\\\Tests\\\\Integration\\\\Core\\\\Repository\\\\FieldType\\\\ImageIntegrationTest\\:\\:getSettingsSchema\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php - - message: "#^Method Ibexa\\\\Tests\\\\Integration\\\\Core\\\\Repository\\\\FieldType\\\\ImageIntegrationTest\\:\\:getStoragePrefix\\(\\) has no return type specified\\.$#" count: 1 diff --git a/src/lib/FieldType/Image/Type.php b/src/lib/FieldType/Image/Type.php index 5865addc4d..a4a6936f18 100644 --- a/src/lib/FieldType/Image/Type.php +++ b/src/lib/FieldType/Image/Type.php @@ -36,7 +36,8 @@ class Type extends FieldType implements TranslationContainerInterface ], ]; - /** @var array{ + /** + * @var array{ * mimeTypes: array{ * type: string, * default: array{}, diff --git a/src/lib/FieldType/Validator/ImageValidator.php b/src/lib/FieldType/Validator/ImageValidator.php index 63a85549b5..ae57f81f4a 100644 --- a/src/lib/FieldType/Validator/ImageValidator.php +++ b/src/lib/FieldType/Validator/ImageValidator.php @@ -51,7 +51,8 @@ private function innerValidate($filePath, array $mimeTypes): bool { // silence `getimagesize` error as extension-wise valid image files might produce it anyway // note that file extension checking is done using other validation which should be called before this one - if (!$imageData = @getimagesize($filePath)) { + $imageData = @getimagesize($filePath); + if (false === $imageData) { $this->errors[] = new ValidationError( 'A valid image file is required.', null, diff --git a/src/lib/Persistence/Legacy/Content/FieldValue/Converter/ImageConverter.php b/src/lib/Persistence/Legacy/Content/FieldValue/Converter/ImageConverter.php index ee27cec8b2..3b30bd924a 100644 --- a/src/lib/Persistence/Legacy/Content/FieldValue/Converter/ImageConverter.php +++ b/src/lib/Persistence/Legacy/Content/FieldValue/Converter/ImageConverter.php @@ -210,7 +210,7 @@ public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefin } /** - * @return array + * @return array * * @throws \JsonException */ diff --git a/tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php b/tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php index 47b5e8ad38..216d945f5a 100644 --- a/tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php +++ b/tests/integration/Core/Repository/FieldType/ImageIntegrationTest.php @@ -71,11 +71,14 @@ public function getTypeName() } /** - * Get expected settings schema. - * - * @return array + * @return array{ + * mimeTypes: array{ + * type: string, + * default: array{}, + * } + * } */ - public function getSettingsSchema() + public function getSettingsSchema(): array { return [ 'mimeTypes' => [