From 887da9969251eb83d3ad43c8ad56b8a1d447ad44 Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Tue, 11 Mar 2025 11:09:19 +0100 Subject: [PATCH] Add regression test --- .../TypesAssignedToPropertiesRuleTest.php | 5 ++++ .../Rules/Properties/data/bug-1311.php | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 tests/PHPStan/Rules/Properties/data/bug-1311.php diff --git a/tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php b/tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php index 5e57ee2994..1c077ad8ad 100644 --- a/tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php +++ b/tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php @@ -139,6 +139,11 @@ public function testBug1216(): void ]); } + public function testBug1311(): void + { + $this->analyse([__DIR__ . '/data/bug-1311.php'], []); + } + public function testTypesAssignedToPropertiesExpressionNames(): void { $this->analyse([__DIR__ . '/data/properties-from-array-into-object.php'], [ diff --git a/tests/PHPStan/Rules/Properties/data/bug-1311.php b/tests/PHPStan/Rules/Properties/data/bug-1311.php new file mode 100755 index 0000000000..995f2d8216 --- /dev/null +++ b/tests/PHPStan/Rules/Properties/data/bug-1311.php @@ -0,0 +1,24 @@ + + */ + private $list = []; + + public function convertList(): void + { + $temp = [1, 2, 3]; + + for ($i = 0; $i < count($temp); $i++) { + $temp[$i] = (string) $temp[$i]; + } + + $this->list = $temp; + } +} + +(new HelloWorld())->convertList();