You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Variable written by a closure through use (&$x) is assumed to keep its initial null #13809
Actual: TypeDoesNotContainType: Type null for $terminationException is always null, so its negation can never be true on line 23.
Expected: no issue. The closure captures $terminationException by reference and assigns it in its catch, so after handle_request($handler) it may hold a Throwable.
Found by comparing Psalm 6.20.11 and master on Symfony v8.1.11. Psalm 6.20.11 reports it too. Symfony location: Runtime/Runner/FrankenPhpWorkerRunner.php:86. The reverse case, a closure assuming the initial type, was #10670.
<?phpinterface App { publicfunctionsend(): void; }
interface Term { publicfunctionterminate(): void; }
finalclass R {
publicfunction__construct(privateApp$app) {}
publicfunctionrun(): void {
$terminationException = null;
$handler = function () use (&$terminationException): void {
try {
$this->app->send();
} finally {
if ($this->appinstanceof Term) {
try {
$this->app->terminate();
} catch (\Throwable$e) {
$terminationException = $e;
}
}
}
};
do {
$ret = handle_request($handler);
if (null !== $terminationException) {
throw$terminationException;
}
} while ($ret);
}
}
functionhandle_request(callable$c): bool { returntrue; }
Psalm output (using commit 9a75b79):
INFO: UnusedParam - 29:34 - Param c is never referenced in this method
ERROR: TypeDoesNotContainType - 23:17 - Type null for $terminationException is always null, so its negation can never be true
Activity
psalm-github-bot commentedon Nov 15, 2026
I found these snippets:
https://psalm.dev/r/008b447f82