From 8b71f8cad35a95395713c7f0051c1f00a22ef7cb Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 20 Dec 2021 15:51:34 +0700 Subject: [PATCH] phpstan --- .../Rector/MethodCall/DowngradeReflectionGetTypeRector.php | 6 +++++- .../MethodCall/DowngradeReflectionGetAttributesRector.php | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rules/DowngradePhp74/Rector/MethodCall/DowngradeReflectionGetTypeRector.php b/rules/DowngradePhp74/Rector/MethodCall/DowngradeReflectionGetTypeRector.php index c71e7226563..041640e7e05 100644 --- a/rules/DowngradePhp74/Rector/MethodCall/DowngradeReflectionGetTypeRector.php +++ b/rules/DowngradePhp74/Rector/MethodCall/DowngradeReflectionGetTypeRector.php @@ -5,9 +5,11 @@ namespace Rector\DowngradePhp74\Rector\MethodCall; use PhpParser\Node; +use PhpParser\Node\Arg; use PhpParser\Node\Expr\Instanceof_; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Ternary; +use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; @@ -88,8 +90,10 @@ public function refactor(Node $node): ?Node } $node->setAttribute(AttributeKey::CREATED_BY_RULE, self::class); + $args = [new Arg($node->var), new Arg(new String_('getType'))]; + return new Ternary( - $this->nodeFactory->createFuncCall('method_exists', [$node->var, 'getType']), + $this->nodeFactory->createFuncCall('method_exists', $args), $node, $this->nodeFactory->createNull() ); diff --git a/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php b/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php index 6c4fd8f653c..261bcc27262 100644 --- a/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php +++ b/rules/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector.php @@ -5,9 +5,11 @@ namespace Rector\DowngradePhp80\Rector\MethodCall; use PhpParser\Node; +use PhpParser\Node\Arg; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\Ternary; +use PhpParser\Node\Scalar\String_; use PHPStan\Type\ObjectType; use Rector\Core\Rector\AbstractRector; use Rector\NodeTypeResolver\Node\AttributeKey; @@ -83,8 +85,10 @@ public function refactor(Node $node): ?Node } $node->setAttribute(AttributeKey::CREATED_BY_RULE, self::class); + $args = [new Arg($node->var), new Arg(new String_('getAttributes'))]; + return new Ternary( - $this->nodeFactory->createFuncCall('method_exists', [$node->var, 'getAttributes']), + $this->nodeFactory->createFuncCall('method_exists', $args), $node, new Array_([]) );