Skip to content

Commit a59dad3

Browse files
committed
Regression tests
Closes phpstan/phpstan#12553
1 parent fb3618b commit a59dad3

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

tests/PHPStan/Rules/Properties/WritingToReadOnlyPropertiesRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,14 @@ public function testPropertyHooks(): void
107107
]);
108108
}
109109

110+
public function testBug12553(): void
111+
{
112+
if (PHP_VERSION_ID < 80400) {
113+
$this->markTestSkipped('Test requires PHP 8.4.');
114+
}
115+
116+
$this->checkThisOnly = false;
117+
$this->analyse([__DIR__ . '/../Variables/data/bug-12553.php'], []);
118+
}
119+
110120
}

tests/PHPStan/Rules/Variables/NullCoalesceRuleTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,14 @@ public function testBug10610(): void
346346
$this->analyse([__DIR__ . '/data/bug-10610.php'], []);
347347
}
348348

349+
public function testBug12553(): void
350+
{
351+
if (PHP_VERSION_ID < 80400) {
352+
$this->markTestSkipped('Test requires PHP 8.4.');
353+
}
354+
355+
$this->treatPhpDocTypesAsCertain = true;
356+
$this->analyse([__DIR__ . '/data/bug-12553.php'], []);
357+
}
358+
349359
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Bug12553;
4+
5+
interface TimestampsInterface
6+
{
7+
public \DateTimeImmutable $createdAt { get; }
8+
}
9+
10+
trait Timestamps
11+
{
12+
public private(set) \DateTimeImmutable $createdAt {
13+
get {
14+
return $this->createdAt ??= new \DateTimeImmutable();
15+
}
16+
}
17+
}
18+
19+
class Example implements TimestampsInterface
20+
{
21+
use Timestamps;
22+
}

0 commit comments

Comments
 (0)