diff --git a/rules/Php80/Rector/NotIdentical/StrContainsRector.php b/rules/Php80/Rector/NotIdentical/StrContainsRector.php index 3d3f3710bf6..e226fb15d7e 100644 --- a/rules/Php80/Rector/NotIdentical/StrContainsRector.php +++ b/rules/Php80/Rector/NotIdentical/StrContainsRector.php @@ -16,7 +16,6 @@ use PhpParser\Node\Name; use PhpParser\Node\Scalar\Int_; use Rector\Php80\NodeResolver\StrFalseComparisonResolver; -use Rector\PhpParser\Node\Value\ValueResolver; use Rector\Rector\AbstractRector; use Rector\ValueObject\PhpVersionFeature; use Rector\ValueObject\PolyfillPackage; diff --git a/rules/Php83/Rector/BooleanAnd/JsonValidateRector.php b/rules/Php83/Rector/BooleanAnd/JsonValidateRector.php index eea87297052..b31db24c211 100644 --- a/rules/Php83/Rector/BooleanAnd/JsonValidateRector.php +++ b/rules/Php83/Rector/BooleanAnd/JsonValidateRector.php @@ -34,7 +34,7 @@ final class JsonValidateRector extends AbstractRector implements MinPhpVersionIn public function __construct( private readonly BinaryOpManipulator $binaryOpManipulator, - private ValueResolver $valueResolver, + private readonly ValueResolver $valueResolver, ) { } @@ -57,7 +57,7 @@ public function getRuleDefinition(): RuleDefinition , <<<'CODE_SAMPLE' if (json_validate($json)) { -} +} CODE_SAMPLE ), ] @@ -89,13 +89,14 @@ public function refactor(Node $node): ?Node $args = $funcCall->getArgs(); - if (count($args) < 1 ){ + if (count($args) < 1) { return null; } if (! $this->validateArgs($funcCall)) { return null; } + $funcCall->name = new Name('json_validate'); $funcCall->args = $args; @@ -116,8 +117,8 @@ public function matchJsonValidateArg(BooleanAnd $booleanAnd): ?FuncCall $decodeMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode( $booleanAnd->left, - fn ($node) => $node instanceof FuncCall && $this->isName($node->name, 'json_decode'), - fn ($node) => $node instanceof ConstFetch && $this->isName($node->name, 'null') + fn (Node $node): bool => $node instanceof FuncCall && $this->isName($node->name, 'json_decode'), + fn (Node $node): bool => $node instanceof ConstFetch && $this->isName($node->name, 'null') ); if (! $decodeMatch instanceof TwoNodeMatch) { @@ -131,8 +132,8 @@ public function matchJsonValidateArg(BooleanAnd $booleanAnd): ?FuncCall $errorMatch = $this->binaryOpManipulator->matchFirstAndSecondConditionNode( $booleanAnd->right, - fn ($node) => $node instanceof FuncCall && $this->isName($node->name, 'json_last_error'), - fn ($node) => $node instanceof ConstFetch && $this->isName($node->name, 'JSON_ERROR_NONE') + fn (Node $node): bool => $node instanceof FuncCall && $this->isName($node->name, 'json_last_error'), + fn (Node $node): bool => $node instanceof ConstFetch && $this->isName($node->name, 'JSON_ERROR_NONE') ); if (! $errorMatch instanceof TwoNodeMatch) { @@ -140,14 +141,15 @@ public function matchJsonValidateArg(BooleanAnd $booleanAnd): ?FuncCall } // always return the json_decode(...) call - $funcCall = $decodeMatch->getFirstExpr(); - if (! $funcCall instanceof FuncCall) { + $expr = $decodeMatch->getFirstExpr(); + if (! $expr instanceof FuncCall) { return null; } - return $funcCall; + + return $expr; } - protected function validateArgs(FuncCall $funcCall): bool + private function validateArgs(FuncCall $funcCall): bool { $depth = $funcCall->getArg('depth', 2); $flags = $funcCall->getArg('flags', 3); diff --git a/src/ValueObject/PolyfillPackage.php b/src/ValueObject/PolyfillPackage.php index dd9c1e0d8a1..a3772b256ab 100644 --- a/src/ValueObject/PolyfillPackage.php +++ b/src/ValueObject/PolyfillPackage.php @@ -13,7 +13,7 @@ final class PolyfillPackage * @var string */ public const PHP_83 = 'symfony/polyfill-php83'; - + /** * @var string */