From f42c9c91d55fd4621bab283ed18686627690457f Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 28 Jul 2025 09:47:55 +0200 Subject: [PATCH 1/3] Add non regression test --- .../ExistingClassesInClosureTypehintsRuleTest.php | 5 +++++ tests/PHPStan/Rules/Functions/data/bug-5206.php | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/PHPStan/Rules/Functions/data/bug-5206.php diff --git a/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php b/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php index b01e0f5230..52160c6b05 100644 --- a/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php @@ -353,4 +353,9 @@ public function testDeprecatedImplicitlyNullableParameterType(): void ]); } + public function testBug5206(): void + { + $this->analyse([__DIR__ . '/data/bug-5206.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Functions/data/bug-5206.php b/tests/PHPStan/Rules/Functions/data/bug-5206.php new file mode 100644 index 0000000000..58738ac19a --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-5206.php @@ -0,0 +1,11 @@ + '`mixed` type!'; + } +} From be438352e5d2347dc6a440167f6ddab0b8837502 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 29 Jul 2025 12:30:00 +0200 Subject: [PATCH 2/3] Try --- .../ExistingClassesInArrowFunctionTypehintsRuleTest.php | 5 +++++ .../Functions/ExistingClassesInClosureTypehintsRuleTest.php | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php b/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php index b7d14e5ee6..1ef1f89ec6 100644 --- a/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php @@ -311,4 +311,9 @@ public function testNever(): void $this->analyse([__DIR__ . '/data/arrow-function-never.php'], $errors); } + public function testBug5206(): void + { + $this->analyse([__DIR__ . '/data/bug-5206.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php b/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php index 52160c6b05..b01e0f5230 100644 --- a/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ExistingClassesInClosureTypehintsRuleTest.php @@ -353,9 +353,4 @@ public function testDeprecatedImplicitlyNullableParameterType(): void ]); } - public function testBug5206(): void - { - $this->analyse([__DIR__ . '/data/bug-5206.php'], []); - } - } From cbc6c11150b99feca10f8f11a30b7b409fbd019e Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 29 Jul 2025 12:43:05 +0200 Subject: [PATCH 3/3] Fix --- ...ExistingClassesInArrowFunctionTypehintsRuleTest.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php b/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php index 1ef1f89ec6..b54bf39163 100644 --- a/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php +++ b/tests/PHPStan/Rules/Functions/ExistingClassesInArrowFunctionTypehintsRuleTest.php @@ -313,7 +313,15 @@ public function testNever(): void public function testBug5206(): void { - $this->analyse([__DIR__ . '/data/bug-5206.php'], []); + $errors = []; + if (PHP_VERSION_ID < 80000) { + $errors[] = [ + 'Parameter $mixed of anonymous function has invalid type Bug5206\mixed.', + 9, + ]; + } + + $this->analyse([__DIR__ . '/data/bug-5206.php'], $errors); } }