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:
parent
271e0d86be
commit
1f84b23f2a
@ -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