Code Duplication    Length = 11-12 lines in 4 locations

src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php 1 location

@@ 168-178 (lines=11) @@
165
166
        $t_if_context->inside_isset = false;
167
168
        foreach ($t_if_context->vars_in_scope as $var_id => $type) {
169
            if (isset($context->vars_in_scope[$var_id])) {
170
                $context->vars_in_scope[$var_id] = Type::combineUnionTypes(
171
                    $context->vars_in_scope[$var_id],
172
                    $type,
173
                    $codebase
174
                );
175
            } else {
176
                $context->vars_in_scope[$var_id] = $type;
177
            }
178
        }
179
180
        $context->referenced_var_ids = array_merge(
181
            $context->referenced_var_ids,

src/Psalm/Internal/Type/TypeCombination.php 3 locations

@@ 753-764 (lines=12) @@
750
                return;
751
            }
752
753
            foreach ($type->type_params as $i => $type_param) {
754
                if (isset($combination->array_type_params[$i])) {
755
                    $combination->array_type_params[$i] = Type::combineUnionTypes(
756
                        $combination->array_type_params[$i],
757
                        $type_param,
758
                        $codebase,
759
                        $overwrite_empty_array
760
                    );
761
                } else {
762
                    $combination->array_type_params[$i] = $type_param;
763
                }
764
            }
765
766
            if ($type instanceof TNonEmptyArray) {
767
                if ($combination->array_counts !== null) {
@@ 797-808 (lines=12) @@
794
        }
795
796
        if ($type instanceof TList) {
797
            foreach ([Type::getInt(), $type->type_param] as $i => $type_param) {
798
                if (isset($combination->array_type_params[$i])) {
799
                    $combination->array_type_params[$i] = Type::combineUnionTypes(
800
                        $combination->array_type_params[$i],
801
                        $type_param,
802
                        $codebase,
803
                        $overwrite_empty_array
804
                    );
805
                } else {
806
                    $combination->array_type_params[$i] = $type_param;
807
                }
808
            }
809
810
            if ($type instanceof TNonEmptyList) {
811
                if ($combination->array_counts !== null) {
@@ 835-846 (lines=12) @@
832
        }
833
834
        if ($type instanceof Atomic\TClassStringMap) {
835
            foreach ([$type->getStandinKeyParam(), $type->value_param] as $i => $type_param) {
836
                if (isset($combination->array_type_params[$i])) {
837
                    $combination->array_type_params[$i] = Type::combineUnionTypes(
838
                        $combination->array_type_params[$i],
839
                        $type_param,
840
                        $codebase,
841
                        $overwrite_empty_array
842
                    );
843
                } else {
844
                    $combination->array_type_params[$i] = $type_param;
845
                }
846
            }
847
848
            $combination->array_always_filled = false;
849