1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 12:24:49 +01:00

Update to more specific example

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

View File

@ -128,10 +128,14 @@ function instantiator(string $class) {
return new $class();
}
/** @psalm-consistent-constructor */
class Foo {}
class Foo {
public final function __construct() {}
}
$_a = instantiator(Foo::class); // Psalm knows the result is an object of type Foo
class FooChild extends Foo {}
$r = instantiator(FooChild::class);
// Psalm knows $r is an object of type FooChild
```
## Template inheritance