Skip to content

Commit 61e0eea

Browse files
committed
added strict-type test-variants for callable array/string
1 parent c6db4e7 commit 61e0eea

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,23 @@ public function getMixed()
143143
}
144144

145145
}
146+
147+
// https://3v4l.org/LK6Rh
148+
class CallableString {
149+
private string $foo;
150+
151+
public function doFoo(callable $foo): void {
152+
$this->foo = $foo; // PHPStorm wrongly reports an error on this line
153+
assertType('callable-string|non-empty-string', $this->foo);
154+
}
155+
}
156+
157+
// https://3v4l.org/WJ8NW
158+
class CallableArray {
159+
private array $foo;
160+
161+
public function doFoo(callable $foo): void {
162+
$this->foo = $foo;
163+
assertType('array', $this->foo); // could be non-empty-array
164+
}
165+
}

0 commit comments

Comments
 (0)