From ddf74919f62bc2c9536ac641be8d4a0ca84fe738 Mon Sep 17 00:00:00 2001 From: orklah Date: Sun, 26 Sep 2021 22:32:00 +0200 Subject: [PATCH] if with common parts --- .../PhpVisitor/Reflector/AttributeResolver.php | 9 +++------ .../ArrayReduceReturnTypeProvider.php | 12 ++---------- src/Psalm/Internal/Type/ParseTreeCreator.php | 4 +--- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php index e297ef9f0..5b7dad78a 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php @@ -26,16 +26,13 @@ class AttributeResolver ) : AttributeStorage { if ($stmt->name instanceof PhpParser\Node\Name\FullyQualified) { $fq_type_string = (string)$stmt->name; - - $codebase->scanner->queueClassLikeForScanning($fq_type_string); - $file_storage->referenced_classlikes[strtolower($fq_type_string)] = $fq_type_string; } else { $fq_type_string = ClassLikeAnalyzer::getFQCLNFromNameObject($stmt->name, $aliases); - - $codebase->scanner->queueClassLikeForScanning($fq_type_string); - $file_storage->referenced_classlikes[strtolower($fq_type_string)] = $fq_type_string; } + $codebase->scanner->queueClassLikeForScanning($fq_type_string); + $file_storage->referenced_classlikes[strtolower($fq_type_string)] = $fq_type_string; + $args = []; foreach ($stmt->args as $arg_node) { diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php index 3b38a8bf6..3530237f1 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php @@ -258,11 +258,6 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\EventHandler\Functi $method_id, $self_class ) ?: Type::getMixed(); - - $reduce_return_type = Type::combineUnionTypes( - $reduce_return_type, - $return_type - ); } else { if (!$codebase->functions->functionExists( $statements_source, @@ -280,12 +275,9 @@ class ArrayReduceReturnTypeProvider implements \Psalm\Plugin\EventHandler\Functi ); $return_type = $function_storage->return_type ?: Type::getMixed(); - - $reduce_return_type = Type::combineUnionTypes( - $reduce_return_type, - $return_type - ); } + + $reduce_return_type = Type::combineUnionTypes($reduce_return_type, $return_type); } } diff --git a/src/Psalm/Internal/Type/ParseTreeCreator.php b/src/Psalm/Internal/Type/ParseTreeCreator.php index eb0e680a7..95b812274 100644 --- a/src/Psalm/Internal/Type/ParseTreeCreator.php +++ b/src/Psalm/Internal/Type/ParseTreeCreator.php @@ -402,10 +402,8 @@ class ParseTreeCreator $this->current_leaf->parent = $new_leaf; array_pop($current_parent->children); - $current_parent->children[] = $new_leaf; - } else { - $current_parent->children[] = $new_leaf; } + $current_parent->children[] = $new_leaf; $this->current_leaf = $new_leaf; }