Closure definition with a method call changes type dumped after it #14038
-
|
After upgrading to 2.1.37, the following code started throwing wrong type error for the public function sayHello(): void
{
if ($this->d === null) {
throw new Exception;
}
$this->clo(
function(): void {
$this->redirect(); // comment this, dumped type changes
},
dumpType($this->d), // or move this above the closure to change the dumped type
);If I comment out the call in the closure, the type is just Here's a full code to reproduce the problem: https://phpstan.org/r/df30b1b1-47d5-46bb-9ee7-0b9fe59d8b0e I know I could introduce a variable ( |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
Can you please tell me when it last worked? At first sight it looked like a problem introduced by the Fibers thing in https://github.com/phpstan/phpstan/releases/tag/2.1.34, but I'm testing older releases and it's Anyway, I'm sure this is your punishment for using |
Beta Was this translation helpful? Give feedback.
-
|
Haha, I wish it was that easy as getting rid of The real code doesn't use
Anyway, it worked in 2.1.36, doesn't work in 2.1.37. |
Beta Was this translation helpful? Give feedback.
Anyway, here's the bugfix :) phpstan/phpstan-src@2a92c7b