From a161e689607db4fc0254710c108985ff45e8c708 Mon Sep 17 00:00:00 2001 From: Alexander Minkin Date: Wed, 28 Oct 2026 16:23:13 +0300 Subject: [PATCH 1/2] test: drop stale Runtime::item expectations for nette/forms <3.3 The visitor now rewrites dynamic form access for older nette/forms too, so the internal Runtime::item() call and its template-type error are gone. --- .../LatteTemplatesRuleForPresenterTest.php | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php b/tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php index 5047fcdd..c03682d5 100644 --- a/tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php +++ b/tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php @@ -1205,17 +1205,6 @@ public function testForms(): void 'default.latte', ]; } else { - $expectedErrors[] = [ - 'Parameter #1 $item of static method Nette\\Bridges\\FormsLatte\\Runtime::item() expects int|object|string, mixed given.', - 142, - 'default.latte', - ]; - $expectedErrors[] = [ - 'Unable to resolve the template type T in call to static method Nette\\Bridges\\FormsLatte\\Runtime::item()', - 142, - 'default.latte', - 'See: https://phpstan.org/blog/solving-phpstan-error-unable-to-resolve-template-type', - ]; $expectedErrors[] = [ 'PHPDoc tag @var with type Nette\\Forms\\Controls\\BaseControl is not subtype of type Nette\\Forms\\Controls\\TextArea.', 55, @@ -1358,19 +1347,6 @@ public function testForms(): void 55, 'default.latte', ]; - if (!DependencyVersion::netteFormsAtLeast33()) { - $expectedErrors[] = [ - 'Parameter #1 $item of static method Nette\\Bridges\\FormsLatte\\Runtime::item() expects int|object|string, mixed given.', - 142, - 'default.latte', - ]; - $expectedErrors[] = [ - 'Unable to resolve the template type T in call to static method Nette\\Bridges\\FormsLatte\\Runtime::item()', - 142, - 'default.latte', - 'See: https://phpstan.org/blog/solving-phpstan-error-unable-to-resolve-template-type', - ]; - } } if (DependencyVersion::phpstanAtLeast23()) { // PHPStan 2.3 dead-code checks on nette/forms 3.1 generated template code From af61a9902ef588af6245fbd48aa964384f0b5487 Mon Sep 17 00:00:00 2001 From: Alexander Minkin Date: Wed, 28 Oct 2026 16:29:44 +0300 Subject: [PATCH 2/2] test: gate item expectations on the PHPStan version PHPStan 2.3 reports the internal Runtime::item() template-type errors on unnamed forms; PHPStan 2.1 does not. Keep the expectations for the newer analysis only. --- .../LatteTemplatesRuleForPresenterTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php b/tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php index c03682d5..fbee7a52 100644 --- a/tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php +++ b/tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php @@ -1205,6 +1205,19 @@ public function testForms(): void 'default.latte', ]; } else { + if (DependencyVersion::phpstanAtLeast23()) { + $expectedErrors[] = [ + 'Parameter #1 $item of static method Nette\\Bridges\\FormsLatte\\Runtime::item() expects int|object|string, mixed given.', + 142, + 'default.latte', + ]; + $expectedErrors[] = [ + 'Unable to resolve the template type T in call to static method Nette\\Bridges\\FormsLatte\\Runtime::item()', + 142, + 'default.latte', + 'See: https://phpstan.org/blog/solving-phpstan-error-unable-to-resolve-template-type', + ]; + } $expectedErrors[] = [ 'PHPDoc tag @var with type Nette\\Forms\\Controls\\BaseControl is not subtype of type Nette\\Forms\\Controls\\TextArea.', 55,