1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Fix get_class-inferred templating

This commit is contained in:
Brown 2020-08-25 17:25:05 -04:00 committed by Daniil Gentili
parent a0a9c9b7bc
commit 4735ca39e2
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
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'
],
];
}
}