diff --git a/composer.json b/composer.json index b3c2f13dda1..7acdf27f15e 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^7.4 || ~8.0.0 || ~8.1.0", + "php": "^8.1", "ext-SimpleXML": "*", "ext-ctype": "*", "ext-dom": "*", diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php index 619ccd2d755..24a78800d25 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php @@ -295,7 +295,7 @@ private static function updateTypeWithKeyValues( $has_matching_objectlike_property = false; $has_matching_string = false; - $child_stmt_type = clone $child_stmt_type; + $child_stmt_type = $child_stmt_type->getBuilder(); foreach ($child_stmt_type->getAtomicTypes() as $type) { if ($type instanceof TTemplateParam) { @@ -351,7 +351,7 @@ private static function updateTypeWithKeyValues( } } - $child_stmt_type->bustCache(); + $child_stmt_type = $child_stmt_type->freeze(); if (!$has_matching_objectlike_property && !$has_matching_string) { if (count($key_values) === 1) { diff --git a/src/Psalm/Type/UnionTrait.php b/src/Psalm/Type/UnionTrait.php index 3aa2e52199b..feea2ce8b44 100644 --- a/src/Psalm/Type/UnionTrait.php +++ b/src/Psalm/Type/UnionTrait.php @@ -344,6 +344,12 @@ public function getKey(): string return implode('|', $types); } + public function bustCache(): void + { + $this->id = null; + $this->exact_id = null; + } + public function getId(bool $exact = true): string { if ($exact && $this->exact_id) {