-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Description
Bug report
If a child class does not override the parent contructor, usage of new static() will always generate an 'Unsafe usage of new static().' error, even if the @phpstan-consistent-constructor annotation is present:
<?php declare(strict_types = 1);
class BaseClass {
public function __construct(
protected string $value
) {
}
}
/**
* @phpstan-consistent-constructor
*/
class ChildClass extends BaseClass {
public static function fromString(
string $value,
): static {
return new static($value);
}
}Code snippet that reproduces the problem
https://phpstan.org/r/8ba3836a-a0af-4623-b1a0-5d7b42a16a42
Expected output
Should not find an error, but does.
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable