1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Add @weirdan's fix

This commit is contained in:
Matthew Brown 2020-11-06 17:53:39 -05:00 committed by Daniil Gentili
parent 2f10ad0c24
commit 5d1dd3ca65
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -120,7 +120,7 @@ Psalm also allows you to parameterize class types
```php
<?php
/**
* @template T
* @template T of Foo
* @psalm-param class-string<T> $class
* @return T
*/
@ -128,9 +128,10 @@ function instantiator(string $class) {
return new $class();
}
/** @psalm-consistent-constructor */
class Foo {}
$a = instantiator(Foo::class); // Psalm knows the result is an object of type Foo
$_a = instantiator(Foo::class); // Psalm knows the result is an object of type Foo
```
## Template inheritance