Skip to content

Commit d17593f

Browse files
committed
1 parent 937be01 commit d17593f

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎tests/PHPStan/Rules/Properties/MissingReadOnlyPropertyAssignRuleTest.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,10 @@ public function testBug13856(): void
343343
]);
344344
}
345345

346+
#[RequiresPhp('>= 8.1.0')]
347+
public function testBug9789(): void
348+
{
349+
$this->analyse([__DIR__ . '/data/bug-9789.php'], []);
350+
}
351+
346352
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php // lint >= 8.1
2+
3+
declare(strict_types = 1);
4+
5+
namespace Bug9789;
6+
7+
trait T {
8+
public function __construct(public readonly string $value) {}
9+
}
10+
11+
class C {
12+
13+
use T {
14+
__construct as protected init;
15+
}
16+
17+
public function __construct(string $value) {
18+
$this->init($value);
19+
if (!$this->isValid()) {
20+
throw new \Exception();
21+
}
22+
}
23+
24+
private function isValid(): bool {
25+
return !empty($this->value);
26+
}
27+
}

0 commit comments

Comments
 (0)