Skip to content

Commit 887da99

Browse files
committed
Add regression test
1 parent 1b56b0c commit 887da99

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ public function testBug1216(): void
139139
]);
140140
}
141141

142+
public function testBug1311(): void
143+
{
144+
$this->analyse([__DIR__ . '/data/bug-1311.php'], []);
145+
}
146+
142147
public function testTypesAssignedToPropertiesExpressionNames(): void
143148
{
144149
$this->analyse([__DIR__ . '/data/properties-from-array-into-object.php'], [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug1311;
4+
5+
class HelloWorld
6+
{
7+
/**
8+
* @var array<int, string>
9+
*/
10+
private $list = [];
11+
12+
public function convertList(): void
13+
{
14+
$temp = [1, 2, 3];
15+
16+
for ($i = 0; $i < count($temp); $i++) {
17+
$temp[$i] = (string) $temp[$i];
18+
}
19+
20+
$this->list = $temp;
21+
}
22+
}
23+
24+
(new HelloWorld())->convertList();

0 commit comments

Comments
 (0)