From f3a0afb25d5bc1b8310dbfaa055cc006d85a5b00 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 20 Mar 2024 10:08:15 +0100 Subject: [PATCH] Fix PHPStan issue with nette/component-model 3.1.0 nette/component-model 3.1.0 made the type annotations more precise, correctly declaring that `null` will not be returned when `$throw` argument is `true` (default): https://github.com/nette/component-model/commit/fbab7bcbb4bd44bba71baba46314c8804bf0b5d6 As a result PHPStan started to complain: Expression on left side of ?? is not nullable. (cherry picked from commit 7445d0d5d142b8a86331735742b8036095c750cb, 2afcd0861692c2f69ad73fed94e0b34f4e27060a) --- src/Multiplier.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Multiplier.php b/src/Multiplier.php index 382857d..599b827 100644 --- a/src/Multiplier.php +++ b/src/Multiplier.php @@ -11,6 +11,7 @@ use Nette\Forms\Controls\BaseControl; use Nette\Forms\Controls\SubmitButton; use Nette\Forms\Form; +use Nette\InvalidStateException; use Nette\Utils\ArrayHash; use Nette\Utils\Arrays; use Traversable; @@ -412,10 +413,11 @@ protected function fillContainer(Container $container): void /** * @return string[] + * @throws InvalidStateException when not attached. */ protected function getHtmlName(): array { - return explode('-', $this->lookupPath(Form::class) ?? ''); + return explode('-', $this->lookupPath(Form::class)); } protected function createContainer(): Container