From d4b720dd7d847a7abaf3761ae0f1cfeffc69a5e9 Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Thu, 22 Sep 2022 13:52:11 +0200 Subject: [PATCH] Regression test --- .../TypesAssignedToPropertiesRuleTest.php | 6 ++++++ .../Rules/Properties/data/bug-7200.php | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/PHPStan/Rules/Properties/data/bug-7200.php 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 {}