From 9c1fa9b3d1af9a6e53adaa1f593f3b2ceee5e614 Mon Sep 17 00:00:00 2001 From: Bastian Lederer Date: Mon, 2 Mar 2026 13:34:25 +0100 Subject: [PATCH 1/2] Adapt to `ipl-stdlib` strict typing `ipl-stdlib` introduces strict type declarations, requiring all classes implementing its interfaces to match the exact parameter and return types defined there. Updated affected classes and bumped the required `ipl/*` versions in `composer.json` accordingly. Co-authored-by: Eric Lippmann --- composer.json | 4 ++-- src/Contract/FormElement.php | 2 +- src/Form.php | 2 +- src/FormElement/FormElements.php | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 1a293a60..4a1b9119 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,8 @@ "require": { "php": ">=8.2", "ext-fileinfo": "*", - "ipl/stdlib": ">=0.12.0", - "ipl/validator": ">=0.5.0", + "ipl/stdlib": ">=0.15.0", + "ipl/validator": ">=1.0.0", "psr/http-message": "^1.1", "guzzlehttp/psr7": "^2.8" }, diff --git a/src/Contract/FormElement.php b/src/Contract/FormElement.php index da8adbd8..1604893c 100644 --- a/src/Contract/FormElement.php +++ b/src/Contract/FormElement.php @@ -56,7 +56,7 @@ public function getMessages(); * * @return $this */ - public function addMessage($message); + public function addMessage(string $message): static; /** * Get the name of the element diff --git a/src/Form.php b/src/Form.php index b198b36b..c0ae6654 100644 --- a/src/Form.php +++ b/src/Form.php @@ -277,7 +277,7 @@ public function handleRequest(ServerRequestInterface $request) $this->onSuccess(); $this->emitOnce(Contract\Form::ON_SUBMIT, [$this]); } catch (Throwable $e) { - $this->addMessage($e); + $this->addMessage($e->getMessage()); $this->onError(); $this->emit(Contract\Form::ON_ERROR, [$e, $this]); } diff --git a/src/FormElement/FormElements.php b/src/FormElement/FormElements.php index 6121b762..0a81036b 100644 --- a/src/FormElement/FormElements.php +++ b/src/FormElement/FormElements.php @@ -433,12 +433,12 @@ public function addElementsFrom($form) * Add a decorator loader * * @param string $namespace Namespace of the decorators - * @param string $postfix Decorator name postfix, if any + * @param ?string $postfix Decorator name postfix, if any * * @return $this * @deprecated Use {@see addElementDecoratorLoaderPaths()} instead */ - public function addDecoratorLoader($namespace, $postfix = null) + public function addDecoratorLoader(string $namespace, ?string $postfix = null): static { $this->addPluginLoader('decorator', $namespace, $postfix); @@ -449,11 +449,11 @@ public function addDecoratorLoader($namespace, $postfix = null) * Add an element loader * * @param string $namespace Namespace of the elements - * @param string $postfix Element name postfix, if any + * @param ?string $postfix Element name postfix, if any * * @return $this */ - public function addElementLoader($namespace, $postfix = null) + public function addElementLoader(string $namespace, ?string $postfix = null): static { $this->addPluginLoader('element', $namespace, $postfix); From d0bbb2027bdd4a0ac379201fc1519e14212ea946 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 19 Mar 2026 14:52:45 +0100 Subject: [PATCH 2/2] Replace deprecated PHPUnit `any()` usage --- tests/FormTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/FormTest.php b/tests/FormTest.php index 3ac9a6cb..a7794832 100644 --- a/tests/FormTest.php +++ b/tests/FormTest.php @@ -42,10 +42,10 @@ protected function assemble() $form->handleRequest($request); - $request2 = $this->createMock(ServerRequestInterface::class); - $request2->expects($this->any())->method('getMethod')->willReturn('POST'); - $request2->expects($this->once())->method('getParsedBody')->willReturn([]); - $request2->expects($this->once())->method('getUploadedFiles')->willReturn([]); + $request2 = $this->createStub(ServerRequestInterface::class); + $request2->method('getMethod')->willReturn('POST'); + $request2->method('getParsedBody')->willReturn([]); + $request2->method('getUploadedFiles')->willReturn([]); $form->handleRequest($request2); }