Skip to content
Permalink
Browse files

Fix #1970 - make sure reconciled types are templated

  • Loading branch information...
muglug committed Jul 25, 2019
1 parent 5a4a133 commit 2c89a97f9119db4ef8fa54ab0cdd248be84143c6
@@ -286,7 +286,7 @@ function (Clause $c) use ($mixed_var_ids) {
$changed_var_ids,
$cond_referenced_var_ids,
$statements_analyzer,
[],
$statements_analyzer->getTemplateTypeMap() ?: [],
$if_context->inside_loop,
$context->check_variables
? new CodeLocation(
@@ -333,7 +333,7 @@ function (Clause $c) use ($mixed_var_ids) {
$changed_var_ids,
$stmt->else || $stmt->elseifs ? $cond_referenced_var_ids : [],
$statements_analyzer,
[],
$statements_analyzer->getTemplateTypeMap() ?: [],
$context->inside_loop,
$context->check_variables
? new CodeLocation(
@@ -691,7 +691,7 @@ protected static function analyzeIfBlock(
$changed_var_ids,
[],
$statements_analyzer,
[],
$statements_analyzer->getTemplateTypeMap() ?: [],
$outer_context->inside_loop,
new CodeLocation(
$statements_analyzer->getSource(),
@@ -1022,7 +1022,7 @@ function (Clause $c) use ($conditional_assigned_var_ids) {
$changed_var_ids,
$new_referenced_var_ids,
$statements_analyzer,
[],
$statements_analyzer->getTemplateTypeMap() ?: [],
$elseif_context->inside_loop,
new CodeLocation(
$statements_analyzer->getSource(),
@@ -1205,7 +1205,7 @@ function (Clause $c) use ($conditional_assigned_var_ids) {
$changed_var_ids,
[],
$statements_analyzer,
[],
$statements_analyzer->getTemplateTypeMap() ?: [],
$elseif_context->inside_loop,
new CodeLocation($statements_analyzer->getSource(), $elseif, $outer_context->include_location)
);
@@ -550,7 +550,7 @@ function cast($value, string $typeName) {
throw new RuntimeException();
}',
],
'instanceofTemplatedClassString' => [
'instanceofTemplatedClassStringOnMixed' => [
'<?php
interface Foo {}
@@ -565,6 +565,23 @@ function get($fooClass, $foo) {
return $foo;
}
throw new \Exception();
}',
],
'instanceofTemplatedClassStringOnObjectType' => [
'<?php
interface Foo {}
/**
* @template T as Foo
* @param class-string<T> $fooClass
* @return T
*/
function get($fooClass, Foo $foo) {
if ($foo instanceof $fooClass) {
return $foo;
}
throw new \Exception();
}',
],

0 comments on commit 2c89a97

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