From d3088bcd2ce38589c36884a2004ea14e9af6344f Mon Sep 17 00:00:00 2001 From: krejzyeu Date: Thu, 22 May 2025 07:55:11 +0200 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20phpstan=20a=20test=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpstan-baseline.neon | 25 +++++++++++++++++++++++++ tests/Cases/ImageStorageTest.php | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 829fb07..fcdb5f1 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -60,6 +60,31 @@ parameters: count: 1 path: src/ImageStorage.php + - + message: "#^Negated boolean expression is always false\\.$#" + count: 1 + path: src/ImageStorage.php + + - + message: "#^Offset 1 does not exist on array\\{0\\?\\: string, 1\\?\\: ''\\|numeric\\-string, 2\\?\\: ''\\|numeric\\-string, 3\\?\\: string, 4\\?\\: ''\\|numeric\\-string, 5\\?\\: ''\\|numeric\\-string, 6\\?\\: ''\\|numeric\\-string, 7\\?\\: numeric\\-string\\}\\.$#" + count: 1 + path: src/ImageStorage.php + + - + message: "#^Offset 1 does not exist on array\\{0\\?\\: string, 1\\?\\: string, 2\\: non\\-falsy\\-string\\}\\.$#" + count: 1 + path: src/ImageStorage.php + + - + message: "#^Offset 2 does not exist on array\\{0\\?\\: string, 1\\?\\: ''\\|numeric\\-string, 2\\?\\: ''\\|numeric\\-string, 3\\?\\: string, 4\\?\\: ''\\|numeric\\-string, 5\\?\\: ''\\|numeric\\-string, 6\\?\\: ''\\|numeric\\-string, 7\\?\\: numeric\\-string\\}\\.$#" + count: 1 + path: src/ImageStorage.php + + - + message: "#^Offset 2 does not exist on array\\{0\\?\\: string, 1\\?\\: string, 2\\?\\: non\\-falsy\\-string\\}\\.$#" + count: 1 + path: src/ImageStorage.php + - message: "#^Only booleans are allowed in &&, int given on the right side\\.$#" count: 1 diff --git a/tests/Cases/ImageStorageTest.php b/tests/Cases/ImageStorageTest.php index 9eb4df7..7e6c889 100644 --- a/tests/Cases/ImageStorageTest.php +++ b/tests/Cases/ImageStorageTest.php @@ -109,7 +109,7 @@ public function testUpload(): void $upload = new FileUpload([ 'name' => 'upload.jpg', 'type' => 'image/jpg', - 'size' => '20', + 'size' => 20, 'tmp_name' => $tempImagePath, 'error' => 0, ]); From 5dc31f9e9461f9dd1b5d5615114eb70de2f9172d Mon Sep 17 00:00:00 2001 From: krejzyeu Date: Thu, 22 May 2025 09:55:04 +0200 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20podpora=20pro=20modifikaci=20obr?= =?UTF-8?q?=C3=A1zk=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ImageNameScript.php | 5 +++++ src/ImageStorage.php | 1 + tests/Cases/ImageNameScriptTest.php | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ImageNameScript.php b/src/ImageNameScript.php index b375b07..827c040 100644 --- a/src/ImageNameScript.php +++ b/src/ImageNameScript.php @@ -94,6 +94,11 @@ public function setQuality(int $quality): void $this->quality = $quality; } + public function setExtension(string $extension): void + { + $this->extension = $extension; + } + public function getIdentifier(): string { $identifier = implode('/', [$this->namespace, $this->prefix, $this->name]); diff --git a/src/ImageStorage.php b/src/ImageStorage.php index e34e851..d285bdc 100644 --- a/src/ImageStorage.php +++ b/src/ImageStorage.php @@ -208,6 +208,7 @@ public function fromIdentifier(mixed $args): Image $script->setCrop($crop); $script->setFlag($flag); $script->setQuality($quality); + $script->setExtension($args[4] ?? $script->extension); $identifier = $script->getIdentifier(); $data_file = implode('/', [$this->data_path, $identifier]); diff --git a/tests/Cases/ImageNameScriptTest.php b/tests/Cases/ImageNameScriptTest.php index 2c7ba27..2ea2188 100644 --- a/tests/Cases/ImageNameScriptTest.php +++ b/tests/Cases/ImageNameScriptTest.php @@ -48,9 +48,10 @@ public function testFromIdentifier(): void $s->setQuality(2); $s->setSize([2, 2]); $s->setFlag('exact'); + $s->setExtension('png'); - Assert::same($s->getIdentifier(), 'images/49/kitty.2x2.exact.q2.jpg'); - Assert::same($s->toQuery(), 'images/49/2x2.exact.q2/kitty.jpg?_image_storage'); + Assert::same($s->getIdentifier(), 'images/49/kitty.2x2.exact.q2.png'); + Assert::same($s->toQuery(), 'images/49/2x2.exact.q2/kitty.png?_image_storage'); } }