We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4292e7c commit 27f95ccCopy full SHA for 27f95cc
tests/PHPStan/Analyser/nsrt/remember-readonly-constructor-narrowed.php
@@ -1,10 +1,10 @@
1
-<?php // lint >= 8.1
+<?php // lint >= 8.2
2
3
namespace RememberReadOnlyConstructor;
4
5
use function PHPStan\Testing\assertType;
6
7
-class HelloWorldReadonly {
+class HelloWorldReadonlyProperty {
8
private readonly int $i;
9
10
public function __construct()
@@ -21,6 +21,23 @@ public function doFoo() {
21
}
22
23
24
+readonly class HelloWorldReadonlyClass {
25
+ private int $i;
26
+
27
+ public function __construct()
28
+ {
29
+ if (rand(0,1)) {
30
+ $this->i = 4;
31
+ } else {
32
+ $this->i = 10;
33
+ }
34
35
36
+ public function doFoo() {
37
+ assertType('4|10', $this->i);
38
39
+}
40
41
42
class HelloWorldRegular {
43
private int $i;
0 commit comments