mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Add @weirdan's fix
This commit is contained in:
parent
2f10ad0c24
commit
5d1dd3ca65
@ -120,7 +120,7 @@ Psalm also allows you to parameterize class types
|
|||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template T of Foo
|
||||||
* @psalm-param class-string<T> $class
|
* @psalm-param class-string<T> $class
|
||||||
* @return T
|
* @return T
|
||||||
*/
|
*/
|
||||||
@ -128,9 +128,10 @@ function instantiator(string $class) {
|
|||||||
return new $class();
|
return new $class();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @psalm-consistent-constructor */
|
||||||
class Foo {}
|
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
|
## Template inheritance
|
||||||
|
Loading…
Reference in New Issue
Block a user