-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
Since I cannot type new Set<string>() in php, it was handy that when assigning new instance that accepts generic arguments into a property, it would infer property's type.
The following used to work:
use Ds\Set;
use stdClass;
final class A
{
/** @var Set<stdClass> */
public Set $a;
public function __construct()
{
$this->a = new Set();
}
}which avoided a lot of boilerplate code:
- $this->a = new Set();
+ /** @var Set<string> $set */
+ $set = new Set();
+ $this->a = $set;but now gives
Property My\App\A::$a (Ds\Set) does not accept Ds\Set.
Code snippet that reproduces the problem
I tried to reproduce in playground but without success. Created reproducible example here
https://github.com/simPod/phpstan-reproduce https://phpstan.org/r/a33d1182-7157-463a-a2c5-9ff4fafe0ab8
Expected output
No errors
This behaviour is since v1.4.7
Did PHPStan help you today? Did it make you happy in any way?
Reactions are currently unavailable