Skip to content

Commit 8fb5645

Browse files
committed
Added regression test
1 parent 3dba381 commit 8fb5645

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -785,4 +785,14 @@ public function testBug11171(): void
785785
$this->analyse([__DIR__ . '/data/bug-11171.php'], []);
786786
}
787787

788+
public function testBug8282(): void
789+
{
790+
if (PHP_VERSION_ID < 80000) {
791+
$this->markTestSkipped('Test requires PHP 8.0.');
792+
}
793+
794+
$this->checkExplicitMixed = true;
795+
$this->analyse([__DIR__ . '/data/bug-8282.php'], []);
796+
}
797+
788798
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Bug8282;
4+
5+
/**
6+
* @phpstan-type record array{id: positive-int, name: string}
7+
*/
8+
class Collection
9+
{
10+
/** @param list<record> $list */
11+
public function __construct(
12+
public array $list
13+
)
14+
{
15+
}
16+
17+
public function updateNameById(int $id, string $name): void
18+
{
19+
foreach ($this->list as $index => $entry) {
20+
if ($entry['id'] === $id) {
21+
$this->list[$index]['name'] = $name;
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)