Skip to content
Permalink
Browse files

Fix #1970 - allow comparison to templated param class

  • Loading branch information...
muglug committed Jul 25, 2019
1 parent 352f18b commit 5a4a133f50468efcf096faed4406189b1e74be8e
@@ -1943,6 +1943,8 @@ protected static function getInstanceOfTypes(
foreach ($stmt->class->inferredType->getTypes() as $atomic_type) {
if ($atomic_type instanceof Type\Atomic\TLiteralClassString) {
$literal_class_strings[] = $atomic_type->value;
} elseif ($atomic_type instanceof Type\Atomic\TTemplateParamClass) {
$literal_class_strings[] = $atomic_type->param_name;
}
}
@@ -550,6 +550,24 @@ function cast($value, string $typeName) {
throw new RuntimeException();
}',
],
'instanceofTemplatedClassString' => [
'<?php
interface Foo {}
/**
* @template T as Foo
* @param class-string<T> $fooClass
* @param mixed $foo
* @return T
*/
function get($fooClass, $foo) {
if ($foo instanceof $fooClass) {
return $foo;
}
throw new \Exception();
}',
],
];
}

0 comments on commit 5a4a133

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