1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix get_class-inferred templating

This commit is contained in:
Brown 2020-08-25 17:25:05 -04:00
parent 6ab3e732fb
commit 59e7f69d7b
2 changed files with 22 additions and 0 deletions

View File

@ -829,6 +829,8 @@ class UnionTemplateHandler
} else {
$valid_input_atomic_types[] = new Atomic\TObject();
}
} elseif ($input_atomic_type instanceof Atomic\GetClassT) {
$valid_input_atomic_types[] = new Atomic\TObject();
}
}

View File

@ -791,6 +791,26 @@ class FunctionClassStringTemplateTest extends TestCase
f(C::class);',
'error_message' => 'InvalidArgument',
],
'bindToClassString' => [
'<?php
/**
* @template TClass as object
*
* @param class-string<TClass> $className
* @param TClass $realInstance
*
* @return Closure(TClass) : void
* @psalm-suppress InvalidReturnType
*/
function createInitializer(string $className, object $realInstance) : Closure {}
function foo(object $realInstance) : void {
$className = get_class($realInstance);
/** @psalm-trace $i */
$i = createInitializer($className, $realInstance);
}',
'error_message' => 'Trace - src/somefile.php:16:25 - $i: Closure(object):void'
],
];
}
}