Skip to content
Permalink
Browse files

Fix #2437 - don’t worry about mixed templated param types

  • Loading branch information
muglug committed Dec 10, 2019
1 parent 9d22f56 commit 20049eb0b53913d9af113fdb90d209e59a408d61
@@ -2414,6 +2414,7 @@ public static function checkFunctionArgumentType(
if ($codebase->infer_types_from_usage
&& !$input_type->hasMixed()
&& !$param_type->from_docblock
&& !$param_type->had_template
&& $cased_method_id
&& strpos($cased_method_id, '::')
&& !strpos($cased_method_id, '__')
@@ -31,6 +31,8 @@ public static function replaceTemplateTypesWithStandins(

$original_atomic_types = $union_type->getTypes();

$had_template = false;

foreach ($original_atomic_types as $key => $atomic_type) {
$atomic_types = array_merge(
$atomic_types,
@@ -45,7 +47,8 @@ public static function replaceTemplateTypesWithStandins(
$add_upper_bound,
$depth,
count($original_atomic_types) === 1,
$union_type->isNullable()
$union_type->isNullable(),
$had_template
)
);
}
@@ -64,6 +67,10 @@ public static function replaceTemplateTypesWithStandins(
$new_union_type->ignore_falsable_issues = $union_type->ignore_falsable_issues;
$new_union_type->possibly_undefined = $union_type->possibly_undefined;

if ($had_template) {
$new_union_type->had_template = true;
}

return $new_union_type;
}

@@ -84,7 +91,8 @@ private static function handleAtomicStandin(
bool $add_upper_bound,
int $depth,
bool $was_single,
bool $was_nullable
bool $was_nullable,
bool &$had_template
) : array {
if ($bracket_pos = strpos($key, '<')) {
$key = substr($key, 0, $bracket_pos);
@@ -103,7 +111,8 @@ private static function handleAtomicStandin(
$replace,
$add_upper_bound,
$depth,
$was_nullable
$was_nullable,
$had_template
);

return $a;
@@ -363,7 +372,8 @@ private static function handleTemplateParamStandin(
bool $replace,
bool $add_upper_bound,
int $depth,
bool $was_nullable
bool $was_nullable,
bool &$had_template
) : array {
$template_type = $template_result->template_types[$key][$atomic_type->defining_class ?: ''][0];

@@ -432,6 +442,8 @@ private static function handleTemplateParamStandin(
if (!$replacements_found) {
$atomic_types[] = clone $replacement_atomic_type;
}

$had_template = true;
}
}

0 comments on commit 20049eb

Please sign in to comment.
You can’t perform that action at this time.