From 73f42f50ef5463cedf53e1a68c2ffab4461f399a Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 8 May 2024 02:07:10 +0200 Subject: [PATCH 1/2] Re-add phpdoc annotation for PHPStan This was accidentally deleted in 1d9a35683bfdd287d0a7ed762806aa94e6ceb793 --- src/Multiplier.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Multiplier.php b/src/Multiplier.php index 593e6a4..6152948 100644 --- a/src/Multiplier.php +++ b/src/Multiplier.php @@ -324,6 +324,7 @@ public function getContainers(): iterable } /** + * @param mixed[]|object $values * @internal */ public function setValues(array|object $values, bool $erase = false, bool $onlyDisabled = false): static From 45cf2a8ed2ea230686db813ba93fcd459c2f35b7 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 8 May 2024 02:13:53 +0200 Subject: [PATCH 2/2] Fix PHPStan issue after nette/forms added more types https://github.com/nette/forms/commit/0cd5069a1737f2438ce23a097f7b6e8f6441e9c1 added more types but that is overly broad for our usage pattern. We need to cast it to proper value until the return type is clarified upstream. Also use `$this->getForm()` instead of `$this->form` since the former is already checked not to be `null` by `$this->isFormSubmitted()`. --- src/Multiplier.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Multiplier.php b/src/Multiplier.php index 6152948..8888c71 100644 --- a/src/Multiplier.php +++ b/src/Multiplier.php @@ -390,7 +390,9 @@ protected function isFormSubmitted(): bool protected function loadHttpData(): void { if ($this->isFormSubmitted()) { - $httpData = Arrays::get($this->form->getHttpData(), $this->getHtmlName(), []); + /** @var array The other types from the union can only be returned when the htmlName argument is passed. https://github.com/nette/forms/pull/333 */ + $httpData = $this->getForm()->getHttpData(); + $httpData = Arrays::get($httpData, $this->getHtmlName(), []); $this->resolver = new ComponentResolver($httpData ?? [], $this->maxCopies, $this->minCopies); } }