Skip to content

Commit

Permalink
Revert reorder of getting method return type and checking args
Browse files Browse the repository at this point in the history
Skipping checking args for first-class callables, but fixes handling of other methods.
  • Loading branch information
trowski committed Dec 10, 2021
1 parent d5519fc commit 3c5e99e
Showing 1 changed file with 14 additions and 12 deletions.
Expand Up @@ -196,6 +196,19 @@ public static function analyze(
);
}

$is_first_class_callable = $stmt->isFirstClassCallable();

if (!$is_first_class_callable && self::checkMethodArgs(
$method_id,
$args,
$template_result,
$context,
new CodeLocation($source, $stmt_name),
$statements_analyzer
) === false) {
return Type::getMixed();
}

$declaring_method_id = $codebase->methods->getDeclaringMethodId($method_id);

$return_type_candidate = MethodCallReturnTypeFetcher::fetch(
Expand All @@ -214,21 +227,10 @@ public static function analyze(
$template_result
);

if ($stmt->isFirstClassCallable()) {
if ($is_first_class_callable) {
return $return_type_candidate;
}

if (self::checkMethodArgs(
$method_id,
$args,
$template_result,
$context,
new CodeLocation($source, $stmt_name),
$statements_analyzer
) === false) {
return Type::getMixed();
}

$in_call_map = InternalCallMapHandler::inCallMap((string) ($declaring_method_id ?? $method_id));

if (!$in_call_map) {
Expand Down

0 comments on commit 3c5e99e

Please sign in to comment.