Skip to content

Commit

Permalink
Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Jan 15, 2024
1 parent 3f82312 commit c9fe76c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ private static function handleByRefReadonlyArg(
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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Psalm\Internal\Provider\ReturnTypeProvider;

use Psalm\Internal\Analyzer\Statements\Expression\Fetch\VariableFetchAnalyzer;
Expand Down
39 changes: 17 additions & 22 deletions src/Psalm/Internal/Provider/ReturnTypeProvider/FilterUtils.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Psalm\Internal\Provider\ReturnTypeProvider;

use PhpParser\Node\Arg;
Expand Down Expand Up @@ -108,12 +110,11 @@ public static function missingFirstArg(Codebase $codebase): Union
return Type::getNull();
}

/** @return int|Union|null */
public static function getFilterArgValueOrError(
Arg $filter_arg,
StatementsAnalyzer $statements_analyzer,
Codebase $codebase
) {
Codebase $codebase,
): int|Union|null {
$filter_arg_type = $statements_analyzer->node_data->getType($filter_arg->value);
if (!$filter_arg_type) {
return null;
Expand Down Expand Up @@ -154,8 +155,8 @@ public static function getOptionsArgValueOrError(
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;
Expand Down Expand Up @@ -339,7 +340,7 @@ public static function missingFilterCallbackCallable(
string $function_id,
CodeLocation $code_location,
StatementsAnalyzer $statements_analyzer,
Codebase $codebase
Codebase $codebase,
): Union {
IssueBuffer::maybeAdd(
new InvalidArgument(
Expand Down Expand Up @@ -397,7 +398,7 @@ public static function checkRedundantFlags(
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;
Expand Down Expand Up @@ -500,7 +501,7 @@ public static function getOptions(
StatementsAnalyzer $statements_analyzer,
CodeLocation $code_location,
Codebase $codebase,
string $function_id
string $function_id,
): array {
$default = null;
$min_range = null;
Expand Down Expand Up @@ -605,16 +606,12 @@ public static function getOptions(
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(
Expand All @@ -637,8 +634,6 @@ protected static function isRangeValid(
*
* @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(
Expand All @@ -652,10 +647,10 @@ public static function getReturnType(
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<never, never>
// it will never fail or change the type, so we can immediately return
Expand Down Expand Up @@ -1472,7 +1467,7 @@ private static function addReturnTaint(
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())
Expand Down
2 changes: 2 additions & 0 deletions src/Psalm/Issue/RedundantFlag.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Psalm\Issue;

final class RedundantFlag extends CodeIssue
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Issue/TaintedXpath.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

final class TaintedXpath extends TaintedInput
{
public const SHORTCODE = 322;
public const SHORTCODE = 328;
}
2 changes: 2 additions & 0 deletions src/Psalm/Storage/UnserializeMemoryUsageSuppressionTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Psalm\Storage;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class A {
'magicObjProp2',

'magicObjMethod',
'magicStaticMethod',
//'magicStaticMethod',

'publicObjProp',
'protectedObjProp',
Expand Down Expand Up @@ -362,7 +362,7 @@ abstract class A {
'magicObjProp2',

'magicObjMethod',
'magicStaticMethod',
//'magicStaticMethod',

'publicObjProp',
'protectedObjProp',
Expand Down Expand Up @@ -440,7 +440,7 @@ class A extends C {
'magicObjProp2',

'magicObjMethod',
'magicStaticMethod',
//'magicStaticMethod',

'publicObjProp',
'protectedObjProp',
Expand Down

0 comments on commit c9fe76c

Please sign in to comment.