Skip to content

Commit 3d34649

Browse files
committed
support callable as string
1 parent 113c7d4 commit 3d34649

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/PHPStan/Analyser/nsrt/bug-12393b.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ class FooVoidInt {
304304
public function doFoo(): void {
305305
$this->foo = $this->returnVoid();
306306
assertType('null', $this->foo);
307-
307+
308308
$this->fooNonNull = $this->returnVoid();
309-
assertType('null', $this->foo); // should be *ERROR*
309+
assertType('int|null', $this->foo); // should be *ERROR*
310310
}
311311

312312
public function returnVoid(): void {
@@ -578,6 +578,16 @@ public function doFoo(array $list): void
578578

579579
}
580580

581+
// https://3v4l.org/LJiRB
582+
class CallableString {
583+
private string $foo;
584+
585+
public function doFoo(callable $foo): void {
586+
$this->foo = $foo;
587+
assertType('string', $this->foo); // could be non-empty-string
588+
}
589+
}
590+
581591
// https://3v4l.org/VvUsp
582592
class CallableArray {
583593
private array $foo;

0 commit comments

Comments
 (0)