Skip to content

Commit c03373a

Browse files
Bump to PHPStan ^2.1.32 and ignore false positive instanceof in OR usage (#344)
* Bump to PHPStan ^2.1.32 and ignore false positive instanceof in OR usage * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <[email protected]>
1 parent c2349bd commit c03373a

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"require-dev": {
1010
"phpstan/extension-installer": "^1.3",
11-
"phpstan/phpstan": "^2.1.30",
11+
"phpstan/phpstan": "^2.1.32",
1212
"phpstan/phpstan-webmozart-assert": "^2.0",
1313
"phpunit/phpunit": "^11.5",
1414
"rector/rector-src": "dev-main",

phpstan.neon

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,12 @@ parameters:
6767

6868
- '#Asking about instanceof PHPStan\\.* is not covered by backward compatibility promise#'
6969
- '#Method Rector\\(.*?)\\Rector\\FuncCall\\(.*?)::refactor\(\) never returns \d so it can be removed from the return type#'
70+
71+
# false positive intanceof in OR usage
72+
-
73+
identifier: instanceof.alwaysTrue
74+
path: rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php
75+
76+
-
77+
identifier: deadCode.unreachable
78+
path: rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php

rector.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Rector\CodingStyle\Rector\String_\UseClassKeywordForClassNameResolutionRector;
66
use Rector\Config\RectorConfig;
7+
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
8+
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
79
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
810
use Rector\PHPUnit\Set\PHPUnitSetList;
911

@@ -37,6 +39,16 @@
3739
__DIR__ . '/rules/DowngradePhp81/Rector/FuncCall/DowngradeFirstClassCallableSyntaxRector.php',
3840
],
3941

42+
RemoveAlwaysTrueIfConditionRector::class => [
43+
// false positive in or check usage
44+
__DIR__ . '/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php',
45+
],
46+
47+
RemoveDeadInstanceOfRector::class => [
48+
// false positive in or check usage
49+
__DIR__ . '/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php',
50+
],
51+
4052
// test paths
4153
'**/Fixture/*',
4254
'**/Source/*',

rules/DowngradePhp72/Rector/FuncCall/DowngradePregUnmatchedAsNullConstantRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function refactor(Node $node)
8282
$flagsExpr = $args[3]->value;
8383

8484
if ($flagsExpr instanceof BitwiseOr) {
85-
$this->bitwiseFlagCleaner->cleanFuncCall($funcCall, $flagsExpr, self::UNMATCHED_NULL_FLAG, null);
85+
$this->bitwiseFlagCleaner->cleanFuncCall($funcCall, $flagsExpr, self::UNMATCHED_NULL_FLAG);
8686
if ($this->nodeComparator->areNodesEqual($flagsExpr, $args[3]->value)) {
8787
return null;
8888
}

rules/DowngradePhp80/NodeAnalyzer/NamedToUnnamedArgs.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public function fillFromNamedArgs(
5656
$currentArg->value,
5757
$currentArg->byRef,
5858
$currentArg->unpack,
59-
[],
60-
null
59+
[]
6160
);
6261
}
6362
}
@@ -108,8 +107,7 @@ public function fillFromJumpedNamedArgs(
108107
$parameterReflection->passedByReference()
109108
->yes(),
110109
$parameterReflection->isVariadic(),
111-
[],
112-
null
110+
[]
113111
);
114112
}
115113

rules/DowngradePhp80/NodeAnalyzer/UnnamedArgumentResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function resolveFromReflection(
4545

4646
foreach ($currentArgs as $key => $arg) {
4747
if (! $arg->name instanceof Identifier) {
48-
$unnamedArgs[$key] = new Arg($arg->value, $arg->byRef, $arg->unpack, [], null);
48+
$unnamedArgs[$key] = new Arg($arg->value, $arg->byRef, $arg->unpack, []);
4949

5050
continue;
5151
}

0 commit comments

Comments
 (0)