mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix crash when using phantom methods as first-class callable
Fixes vimeo/psalm#8377
This commit is contained in:
parent
4defa177c8
commit
7364988934
@ -685,18 +685,22 @@ class AtomicMethodCallAnalyzer extends CallAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
if (ArgumentsAnalyzer::analyze(
|
||||
$statements_analyzer,
|
||||
$stmt->getArgs(),
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
$context
|
||||
) === false) {
|
||||
return;
|
||||
}
|
||||
if ($stmt->isFirstClassCallable()) {
|
||||
$result->return_type = Type::getClosure();
|
||||
} else {
|
||||
if (ArgumentsAnalyzer::analyze(
|
||||
$statements_analyzer,
|
||||
$stmt->getArgs(),
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
$context
|
||||
) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result->return_type = Type::getMixed();
|
||||
$result->return_type = Type::getMixed();
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
|
@ -872,6 +872,21 @@ class ClosureTest extends TestCase
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.1',
|
||||
],
|
||||
'FirstClassCallable:Method:Asserted' => [
|
||||
'code' => '<?php
|
||||
$r = false;
|
||||
/** @var object $o */;
|
||||
/** @var string $m */;
|
||||
if (method_exists($o, $m)) {
|
||||
$r = $o->$m(...);
|
||||
}
|
||||
',
|
||||
'assertions' => [
|
||||
'$r===' => 'Closure|false',
|
||||
],
|
||||
'ignored_issues' => [],
|
||||
'php_version' => '8.1',
|
||||
],
|
||||
'arrowFunctionReturnsNeverImplictly' => [
|
||||
'code' => '<?php
|
||||
$bar = ["foo", "bar"];
|
||||
|
Loading…
Reference in New Issue
Block a user