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

Add @weirdan's fix

This commit is contained in:
Matthew Brown 2020-11-06 17:53:39 -05:00 committed by GitHub
parent 271e0d86be
commit 1f84b23f2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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