Skip to content

Commit 7aeda4a

Browse files
committed
test remembered types in inherited scopes
1 parent 7e6e901 commit 7aeda4a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/PHPStan/Analyser/nsrt/remember-readonly-constructor-narrowed.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,28 @@ public function doFoo() {
143143
assertType('int', $this->prop->writable);
144144
}
145145
}
146+
147+
class HelloWorldReadonlyPropertyInClosureScope {
148+
private readonly int $i;
149+
150+
public function __construct()
151+
{
152+
if (rand(0,1)) {
153+
$this->i = 4;
154+
} else {
155+
$this->i = 10;
156+
}
157+
}
158+
159+
public function doFoo() {
160+
assertType('4|10', $this->i);
161+
162+
(function() {
163+
assertType('4|10', $this->i);
164+
})();
165+
166+
$func = function() {
167+
assertType('4|10', $this->i);
168+
};
169+
}
170+
}

0 commit comments

Comments
 (0)