diff --git a/tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php b/tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php index 39c4948c24..a373608589 100644 --- a/tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php +++ b/tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php @@ -1068,6 +1068,14 @@ public function testTraitMixin(): void $this->analyse([__DIR__ . '/data/trait-mixin.php'], []); } + public function testBug9706(): void + { + $this->checkThisOnly = false; + $this->checkUnionTypes = true; + $this->checkDynamicProperties = true; + $this->analyse([__DIR__ . '/data/bug-9706.php'], []); + } + #[RequiresPhp('>= 8.4')] public function testAsymmetricVisibility(): void { diff --git a/tests/PHPStan/Rules/Properties/data/bug-9706.php b/tests/PHPStan/Rules/Properties/data/bug-9706.php new file mode 100644 index 0000000000..55e87a8992 --- /dev/null +++ b/tests/PHPStan/Rules/Properties/data/bug-9706.php @@ -0,0 +1,15 @@ +attributes; + // According to the php.net docs, $length should be a public read-only property. + // See https://www.php.net/manual/en/class.domnamednodemap.php + $length = $attributes->length; + } +}