Skip to content

Commit e850617

Browse files
committed
Added regression test
1 parent 49e771e commit e850617

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

tests/PHPStan/Rules/Properties/MissingReadOnlyPropertyAssignRuleTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,16 @@ public function testBug10048(): void
392392
$this->analyse([__DIR__ . '/data/bug-10048.php'], []);
393393
}
394394

395+
public function testBug11828(): void
396+
{
397+
if (PHP_VERSION_ID < 80100) {
398+
$this->markTestSkipped('Test requires PHP 8.1.');
399+
}
400+
401+
$this->shouldNarrowMethodScopeFromConstructor = true;
402+
$this->analyse([__DIR__ . '/data/bug-11828.php'], []);
403+
}
404+
395405
public function testBug9864(): void
396406
{
397407
if (PHP_VERSION_ID < 80100) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug11828;
4+
5+
class Dummy
6+
{
7+
/**
8+
* @var callable
9+
*/
10+
private $callable;
11+
private readonly int $foo;
12+
13+
public function __construct(int $foo)
14+
{
15+
$this->foo = $foo;
16+
17+
$this->callable = function () {
18+
$foo = $this->getFoo();
19+
};
20+
}
21+
22+
public function getFoo(): int
23+
{
24+
return $this->foo;
25+
}
26+
27+
public function getCallable(): callable
28+
{
29+
return $this->callable;
30+
}
31+
}

0 commit comments

Comments
 (0)