Skip to content

Commit

Permalink
Merge pull request #8814 from weirdan/fix-8377
Browse files Browse the repository at this point in the history
Fixes #8377
  • Loading branch information
weirdan committed Dec 3, 2022
2 parents 4defa17 + 7364988 commit 35822f1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
Expand Up @@ -685,18 +685,22 @@ private static function handleInvalidClass(
}
}

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:
Expand Down
15 changes: 15 additions & 0 deletions tests/ClosureTest.php
Expand Up @@ -872,6 +872,21 @@ private function handler(): void {
'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"];
Expand Down

0 comments on commit 35822f1

Please sign in to comment.