From c9fe76cadc102d1e7eeaf03bbf17daf6bb1f4931 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 15 Jan 2024 13:16:41 +0100 Subject: [PATCH] Patch --- .../Expression/Call/ArgumentsAnalyzer.php | 2 +- .../FilterInputReturnTypeProvider.php | 2 + .../ReturnTypeProvider/FilterUtils.php | 39 ++++++++----------- src/Psalm/Issue/RedundantFlag.php | 2 + src/Psalm/Issue/TaintedXpath.php | 2 +- ...UnserializeMemoryUsageSuppressionTrait.php | 2 + ...GetCompletionItemsForClassishThingTest.php | 6 +-- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php index 970f3cad6..d8174c717 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php @@ -1260,7 +1260,7 @@ final class ArgumentsAnalyzer Context $context, PhpParser\Node\Expr\PropertyFetch $stmt, string $fq_class_name, - string $prop_name + string $prop_name, ): void { $property_id = $fq_class_name . '::$' . $prop_name; diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterInputReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterInputReturnTypeProvider.php index 09b32b2aa..b3bc3ad48 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterInputReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterInputReturnTypeProvider.php @@ -1,5 +1,7 @@ node_data->getType($filter_arg->value); if (!$filter_arg_type) { return null; @@ -154,8 +155,8 @@ final class FilterUtils Codebase $codebase, CodeLocation $code_location, string $function_id, - int $filter_int_used - ) { + int $filter_int_used, + ): array|Union|null { $options_arg_type = $statements_analyzer->node_data->getType($options_arg->value); if (!$options_arg_type) { return null; @@ -339,7 +340,7 @@ final class FilterUtils string $function_id, CodeLocation $code_location, StatementsAnalyzer $statements_analyzer, - Codebase $codebase + Codebase $codebase, ): Union { IssueBuffer::maybeAdd( new InvalidArgument( @@ -397,7 +398,7 @@ final class FilterUtils Union $fails_type, StatementsAnalyzer $statements_analyzer, CodeLocation $code_location, - Codebase $codebase + Codebase $codebase, ): ?Union { $all_filters = self::getFilters($codebase); $flags_int_used_rest = $flags_int_used; @@ -500,7 +501,7 @@ final class FilterUtils StatementsAnalyzer $statements_analyzer, CodeLocation $code_location, Codebase $codebase, - string $function_id + string $function_id, ): array { $default = null; $min_range = null; @@ -605,16 +606,12 @@ final class FilterUtils return [$default, $min_range, $max_range, $has_range, $regexp]; } - /** - * @param float|int|null $min_range - * @param float|int|null $max_range - */ protected static function isRangeValid( - $min_range, - $max_range, + float|int|null $min_range, + float|int|null $max_range, StatementsAnalyzer $statements_analyzer, CodeLocation $code_location, - string $function_id + string $function_id, ): bool { if ($min_range !== null && $max_range !== null && $min_range > $max_range) { IssueBuffer::maybeAdd( @@ -637,8 +634,6 @@ final class FilterUtils * * @psalm-suppress ComplexMethod * @param Union|null $not_set_type null if undefined filtered variable will return $fails_type - * @param float|int|null $min_range - * @param float|int|null $max_range * @param non-falsy-string|true|null $regexp */ public static function getReturnType( @@ -652,10 +647,10 @@ final class FilterUtils Codebase $codebase, string $function_id, bool $has_range, - $min_range, - $max_range, - $regexp, - bool $in_array_recursion = false + float|int|null $min_range, + float|int|null $max_range, + string|bool|null $regexp, + bool $in_array_recursion = false, ): Union { // if we are inside a recursion of e.g. array // it will never fail or change the type, so we can immediately return @@ -1472,7 +1467,7 @@ final class FilterUtils StatementsAnalyzer $statements_analyzer, CodeLocation $code_location, Union $return_type, - string $function_id + string $function_id, ): Union { if ($statements_analyzer->data_flow_graph && !in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) diff --git a/src/Psalm/Issue/RedundantFlag.php b/src/Psalm/Issue/RedundantFlag.php index d3f042963..7734803ac 100644 --- a/src/Psalm/Issue/RedundantFlag.php +++ b/src/Psalm/Issue/RedundantFlag.php @@ -1,5 +1,7 @@