diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php index e2190597bed..b788567553b 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php @@ -1259,6 +1259,7 @@ private static function handleNonExistentProperty( } /** + * @param string[] $ignore_mixins * @return array{TNamedObject, ClassLikeStorage, bool, bool, string, string} */ private static function handleRegularMixins( @@ -1271,10 +1272,14 @@ private static function handleRegularMixins( string $property_id, PhpParser\Node\Expr\PropertyFetch $stmt, StatementsAnalyzer $statements_analyzer, - string $fq_class_name + string $fq_class_name, + array $ignore_mixins = [] ): array { $property_exists = false; $naive_property_exists = false; + + $ignore_mixins[] = $fq_class_name; + foreach ($class_storage->namedMixins as $mixin) { $new_property_id = $mixin->value . '::$' . $prop_name; @@ -1317,6 +1322,9 @@ private static function handleRegularMixins( } $mixin_lhs_type_part = $mixin; $mixin_fq_class_name = $mixin_class_storage->name; + if (in_array($mixin_fq_class_name, $ignore_mixins)) { + continue; + } [ $new_lhs_type_part, @@ -1336,6 +1344,7 @@ private static function handleRegularMixins( $stmt, $statements_analyzer, $mixin_fq_class_name, + $ignore_mixins, ); if ($property_exists) { diff --git a/tests/MixinsDeepTest.php b/tests/MixinsDeepTest.php index 98c48ddb50b..55961d10171 100644 --- a/tests/MixinsDeepTest.php +++ b/tests/MixinsDeepTest.php @@ -442,6 +442,56 @@ public static function __callStatic(string $name, array $arguments) {} ], 'ignored_issues' => ['MixedAssignment'], ], + 'LowMixinCollision_WithProperties' => [ + 'code' => <<<'PHP' + notExistsProp; + PHP, + 'assertions' => [ + '$a' => 'mixed', + ], + 'ignored_issues' => ['MixedAssignment'], + ], + 'DeepMixinCollision_WithProperties' => [ + 'code' => <<<'PHP' + notExistsProp; + PHP, + 'assertions' => [ + '$a' => 'mixed', + ], + 'ignored_issues' => ['MixedAssignment'], + ], ]; } }