Skip to content

Commit 58468f5

Browse files
authored
Adapt to ipl-stdlib strict typing (#187)
Enforce strict type declarations from `ipl-stdlib`, update implementing classes for signature compliance, and bump `ipl/*` versions in `composer.json`.
2 parents 02f1a34 + d0bbb20 commit 58468f5

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"require": {
1212
"php": ">=8.2",
1313
"ext-fileinfo": "*",
14-
"ipl/stdlib": ">=0.12.0",
15-
"ipl/validator": ">=0.5.0",
14+
"ipl/stdlib": ">=0.15.0",
15+
"ipl/validator": ">=1.0.0",
1616
"psr/http-message": "^1.1",
1717
"guzzlehttp/psr7": "^2.8"
1818
},

src/Contract/FormElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getMessages();
5656
*
5757
* @return $this
5858
*/
59-
public function addMessage($message);
59+
public function addMessage(string $message): static;
6060

6161
/**
6262
* Get the name of the element

src/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public function handleRequest(ServerRequestInterface $request)
277277
$this->onSuccess();
278278
$this->emitOnce(Contract\Form::ON_SUBMIT, [$this]);
279279
} catch (Throwable $e) {
280-
$this->addMessage($e);
280+
$this->addMessage($e->getMessage());
281281
$this->onError();
282282
$this->emit(Contract\Form::ON_ERROR, [$e, $this]);
283283
}

src/FormElement/FormElements.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,12 @@ public function addElementsFrom($form)
433433
* Add a decorator loader
434434
*
435435
* @param string $namespace Namespace of the decorators
436-
* @param string $postfix Decorator name postfix, if any
436+
* @param ?string $postfix Decorator name postfix, if any
437437
*
438438
* @return $this
439439
* @deprecated Use {@see addElementDecoratorLoaderPaths()} instead
440440
*/
441-
public function addDecoratorLoader($namespace, $postfix = null)
441+
public function addDecoratorLoader(string $namespace, ?string $postfix = null): static
442442
{
443443
$this->addPluginLoader('decorator', $namespace, $postfix);
444444

@@ -449,11 +449,11 @@ public function addDecoratorLoader($namespace, $postfix = null)
449449
* Add an element loader
450450
*
451451
* @param string $namespace Namespace of the elements
452-
* @param string $postfix Element name postfix, if any
452+
* @param ?string $postfix Element name postfix, if any
453453
*
454454
* @return $this
455455
*/
456-
public function addElementLoader($namespace, $postfix = null)
456+
public function addElementLoader(string $namespace, ?string $postfix = null): static
457457
{
458458
$this->addPluginLoader('element', $namespace, $postfix);
459459

tests/FormTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ protected function assemble()
4242

4343
$form->handleRequest($request);
4444

45-
$request2 = $this->createMock(ServerRequestInterface::class);
46-
$request2->expects($this->any())->method('getMethod')->willReturn('POST');
47-
$request2->expects($this->once())->method('getParsedBody')->willReturn([]);
48-
$request2->expects($this->once())->method('getUploadedFiles')->willReturn([]);
45+
$request2 = $this->createStub(ServerRequestInterface::class);
46+
$request2->method('getMethod')->willReturn('POST');
47+
$request2->method('getParsedBody')->willReturn([]);
48+
$request2->method('getUploadedFiles')->willReturn([]);
4949

5050
$form->handleRequest($request2);
5151
}

0 commit comments

Comments
 (0)