From 4be59d134c1a69ac1676d0c6df2ea020ef3cec0f Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Tue, 20 Dec 2022 21:59:35 -0600 Subject: [PATCH] Remove occurrences --- psalm-baseline.xml | 233 ++++++++++++++++++------------------ src/Psalm/ErrorBaseline.php | 41 +++---- 2 files changed, 132 insertions(+), 142 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 227420cf7b7..4e28bc73e20 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,19 +1,19 @@ - + - + $comment_block->tags['variablesfrom'][0] $matches[1] - + $comment_block->tags['variablesfrom'][0] $matches[1] - + $const_name $const_name $matches[0] @@ -23,19 +23,19 @@ - + explode('::', $method_id)[1] - + $matches[1] $matches[2] $matches[3] - + $comments[0] $property_name $stmt->props[0] @@ -43,12 +43,12 @@ - + $property_name - + $destination_parts[1] $destination_parts[1] $destination_parts[1] @@ -57,30 +57,30 @@ - + $stmt->cond - + if (AtomicTypeComparator::isContainedBy( if (AtomicTypeComparator::isContainedBy( - + $context->assigned_var_ids += $switch_scope->new_assigned_var_ids - + $new_case_equality_expr->getArgs()[1] $switch_scope->leftover_statements[0] $traverser->traverse([$switch_condition])[0] - + $assertion->rule[0] $assertion->rule[0] $assertion->rule[0] @@ -112,28 +112,28 @@ - + $new_property_name - + $invalid_left_messages[0] $invalid_right_messages[0] - + verifyType - + $method_name $parts[1] explode('::', $cased_method_id)[1] - + $args[0] $args[0] $args[1] @@ -142,20 +142,20 @@ - + $stmt->getArgs()[0] - + $parts[1] - + $method - + $result->invalid_method_call_types[0] $result->non_existent_class_method_ids[0] $result->non_existent_class_method_ids[0] @@ -165,59 +165,56 @@ - + $new_method_name - + $callable_arg->items[0] $callable_arg->items[1] - + $new_const_name $new_const_name - - $properties[0] - - + $stmt_type $stmt_type $stmt_type - + $stmt_type - + $invalid_fetch_types[0] - + $new_property_name - + $atomic_return_type->type_params[2] - + $method_name - + $token_list[$iter] $token_list[$iter] $token_list[$iter] @@ -227,30 +224,30 @@ - + $stmt->expr->getArgs()[0] - + $check_type_string - + $options['tcp'] ?? null - + $identifier_name - + $trait - + $destination_name $destination_name $destination_name @@ -259,23 +256,23 @@ - + $stub - + $callables[0] $callables[0] - + $function_callables[0] - + $property_name $property_name $property_name @@ -285,7 +282,7 @@ - + $a->props[0] $a->stmts[0] $a_stmt_comments[0] @@ -295,44 +292,44 @@ - + $b[$y] - + $stmt->props[0] - + $type < 1 $type < 1 || $type > 4 $type > 4 - + $pair[1] - + $parts[1] - + $contentChanges[0] - + $method_id_parts[1] - + $cs[0] $match[0] $match[1] @@ -344,7 +341,7 @@ - + $doc_line_parts[1] $matches[0] $method_tree->children[0] @@ -352,77 +349,77 @@ - + $l[4] $r[4] - + $node->getArgs()[0] $node->getArgs()[1] - + $since_parts[1] - + count($line_parts) > 0 - + $fixed_type_tokens[$i - 1] - + $source_param_string - + $stmt->stmts[0] - + $cs[0] - + $callable_method_name - + $class_strings ?: null - + $method_name - + isContainedBy - + $array->properties[0] $array->properties[0] - + $callable - + TCallable|TClosure|null - + $array_atomic_type->properties[0] $properties[0] $properties[0] @@ -430,13 +427,13 @@ - + getClassTemplateTypes has - + $combination->array_type_params[1] $combination->array_type_params[1] $combination->array_type_params[1] @@ -447,12 +444,12 @@ - + $fallback_params - + $const_name $const_name $intersection_types[0] @@ -466,7 +463,7 @@ - + $type_tokens[$i - 1] $type_tokens[$i - 1] $type_tokens[$i - 1] @@ -474,12 +471,12 @@ - + CustomMetadataTrait - + traverse traverse traverse @@ -487,12 +484,12 @@ - + self::$listKey - + classExtendsOrImplements classExtendsOrImplements classExtendsOrImplements @@ -506,15 +503,15 @@ traverse traverse - + array_keys($template_type_map[$value])[0] - + $value - + replace replace replace @@ -522,62 +519,62 @@ - + getMappedGenericTypeParams replace replace - + TTypeParams|null TTypeParams|null - + $this->type_params[1] - + getMostSpecificTypeFromBounds - + TNonEmptyList - + replace - + getString getString replace replace - + $cloned->value_param - + replace - + __construct - + TList new TList($this->getGenericValueType()) new TNonEmptyList($this->getGenericValueType()) - + combine combine combineUnionTypes @@ -592,58 +589,58 @@ replace replace - + $key_type->possibly_undefined - + $this->properties[0] $this->properties[0] $this->properties[0] - + getList - + replace replace - + $cloned->type_param - + TList - + setCount - + replace replace - + replace - + replace - + replace - + $allow_mutations $by_ref $failed_reconciliation @@ -654,52 +651,52 @@ - + $const_name $type[0] $type[0][0] - + $node - + visit - + $ignore_isset - + traverse traverse traverseArray traverseArray - + TArray|TKeyedArray|TClassStringMap - + $this->types['array'] - + allFloatLiterals allFloatLiterals - + UndefinedMethod - + $subNodes['expr'] diff --git a/src/Psalm/ErrorBaseline.php b/src/Psalm/ErrorBaseline.php index 75c383e5a4f..ab088b4886b 100644 --- a/src/Psalm/ErrorBaseline.php +++ b/src/Psalm/ErrorBaseline.php @@ -22,8 +22,8 @@ use function phpversion; use function preg_replace_callback; use function sort; +use function sprintf; use function str_replace; -use function strpos; use function trim; use function usort; @@ -112,15 +112,19 @@ public static function read(FileProvider $fileProvider, string $baselineFile): a $issueType = $issue->tagName; - $files[$fileName][$issueType] = [ - 'o' => (int)$issue->getAttribute('occurrences'), - 's' => [], - ]; + $files[$fileName][$issueType] = ['o' => 0, 's' => []]; $codeSamples = $issue->getElementsByTagName('code'); foreach ($codeSamples as $codeSample) { + $files[$fileName][$issueType]['o'] += 1; $files[$fileName][$issueType]['s'][] = trim($codeSample->textContent); } + + // TODO: Remove in v6.0.0 + $occurrencesAttr = $issue->getAttribute('occurrences'); + if ($occurrencesAttr !== '') { + $files[$fileName][$issueType]['o'] = (int) $occurrencesAttr; + } } } @@ -206,10 +210,7 @@ static function (array $carry, IssueData $issue): array { } ++$carry[$fileName][$issueType]['o']; - - if (!strpos($issue->selected_text, "\n")) { - $carry[$fileName][$issueType]['s'][] = $issue->selected_text; - } + $carry[$fileName][$issueType]['s'][] = $issue->selected_text; return $carry; }, @@ -261,8 +262,6 @@ private static function writeToFile( foreach ($issueTypes as $issueType => $existingIssueType) { $issueNode = $baselineDoc->createElement($issueType); - $issueNode->setAttribute('occurrences', (string)$existingIssueType['o']); - sort($existingIssueType['s']); foreach ($existingIssueType['s'] as $selection) { @@ -280,22 +279,16 @@ private static function writeToFile( $baselineDoc->formatOutput = true; $xml = preg_replace_callback( - '/)\n)/', + '/)\n/', /** * @param string[] $matches */ - static fn(array $matches): string => ' sprintf( + "saveXML(), );