diff --git a/tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php b/tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php index 229949d119..2c35052e2e 100644 --- a/tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php +++ b/tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php @@ -433,4 +433,10 @@ public function testBug4526(): void $this->analyse([__DIR__ . '/data/bug-4526.php'], []); } + public function testBug7200(): void + { + $this->checkExplicitMixed = true; + $this->analyse([__DIR__ . '/data/bug-7200.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Properties/data/bug-7200.php b/tests/PHPStan/Rules/Properties/data/bug-7200.php new file mode 100644 index 0000000000..f71944de3d --- /dev/null +++ b/tests/PHPStan/Rules/Properties/data/bug-7200.php @@ -0,0 +1,21 @@ +|null $class + */ + public function __construct(public ?Model $model = null, public ?string $class = null) + { + if ($model instanceof One && $model instanceof Two && $model instanceof Three) { + $this->class ??= $model::class; + } + } +} + +class Model {} +interface One {} +interface Two {} +interface Three {}