Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"require-dev": {
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^2.1.30",
"phpstan/phpstan": "^2.1.32",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^11.5",
"rector/rector-src": "dev-main",
Expand Down
9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,12 @@ parameters:

- '#Asking about instanceof PHPStan\\.* is not covered by backward compatibility promise#'
- '#Method Rector\\(.*?)\\Rector\\FuncCall\\(.*?)::refactor\(\) never returns \d so it can be removed from the return type#'

# false positive intanceof in OR usage
-
identifier: instanceof.alwaysTrue
path: rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php

-
identifier: deadCode.unreachable
path: rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php
12 changes: 12 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Rector\CodingStyle\Rector\String_\UseClassKeywordForClassNameResolutionRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

Expand Down Expand Up @@ -37,6 +39,16 @@
__DIR__ . '/rules/DowngradePhp81/Rector/FuncCall/DowngradeFirstClassCallableSyntaxRector.php',
],

RemoveAlwaysTrueIfConditionRector::class => [
// false positive in or check usage
__DIR__ . '/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php',
],

RemoveDeadInstanceOfRector::class => [
// false positive in or check usage
__DIR__ . '/rules/DowngradePhp80/Rector/NullsafeMethodCall/DowngradeNullsafeToTernaryOperatorRector.php',
],

// test paths
'**/Fixture/*',
'**/Source/*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function refactor(Node $node)
$flagsExpr = $args[3]->value;

if ($flagsExpr instanceof BitwiseOr) {
$this->bitwiseFlagCleaner->cleanFuncCall($funcCall, $flagsExpr, self::UNMATCHED_NULL_FLAG, null);
$this->bitwiseFlagCleaner->cleanFuncCall($funcCall, $flagsExpr, self::UNMATCHED_NULL_FLAG);
if ($this->nodeComparator->areNodesEqual($flagsExpr, $args[3]->value)) {
return null;
}
Expand Down
6 changes: 2 additions & 4 deletions rules/DowngradePhp80/NodeAnalyzer/NamedToUnnamedArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public function fillFromNamedArgs(
$currentArg->value,
$currentArg->byRef,
$currentArg->unpack,
[],
null
[]
);
}
}
Expand Down Expand Up @@ -108,8 +107,7 @@ public function fillFromJumpedNamedArgs(
$parameterReflection->passedByReference()
->yes(),
$parameterReflection->isVariadic(),
[],
null
[]
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function resolveFromReflection(

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

continue;
}
Expand Down