1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Merge pull request #8814 from weirdan/fix-8377

Fixes https://github.com/vimeo/psalm/issues/8377
This commit is contained in:
Bruce Weirdan 2022-12-02 23:38:57 -04:00 committed by GitHub
commit 35822f14d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 11 deletions

View File

@ -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:

View File

@ -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"];