diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php index a5f519f80..3a4d8da06 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php @@ -328,7 +328,7 @@ class ReturnTypeCollector $generator_type = new Atomic\TGenericObject( 'Generator', [ - $key_type ?: Type::getInt(), + $key_type ? clone $key_type : Type::getInt(), clone $value_type, Type::getMixed(), Type::getMixed() diff --git a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php index 9630d2c5f..61f9ab6b0 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php @@ -1933,7 +1933,7 @@ class ExpressionAnalyzer if ($expression_atomic_type instanceof Type\Atomic\TGenericObject) { $yield_type = PropertyFetchAnalyzer::localizePropertyType( $codebase, - $yield_type, + clone $yield_type, $expression_atomic_type, $classlike_storage, $classlike_storage