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();