Skip to content

Commit 26ea27c

Browse files
committed
Fixed PHPStan issue
1 parent e699752 commit 26ea27c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

rules/DowngradePhp84/Rector/FuncCall/DowngradeRoundingModeEnumRector.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpParser\Node;
88
use PhpParser\Node\Expr\ClassConstFetch;
99
use PhpParser\Node\Expr\MethodCall;
10+
use PhpParser\Node\Name;
1011
use Rector\Rector\AbstractRector;
1112
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1213
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -46,7 +47,7 @@ public function getRuleDefinition(): RuleDefinition
4647
*/
4748
public function refactor(Node $node): ?Node
4849
{
49-
if (!$this->isName($node, 'round')) {
50+
if (! $this->isName($node, 'round')) {
5051
return null;
5152
}
5253

@@ -60,14 +61,17 @@ public function refactor(Node $node): ?Node
6061
return null;
6162
}
6263

63-
if (!isset($args[2])) {
64+
if (! isset($args[2])) {
6465
return null;
6566
}
6667

6768
$modeArg = $args[2]->value;
6869
$hasChanged = false;
6970
if ($modeArg instanceof ClassConstFetch) {
70-
if ($modeArg->class->name === 'RoundingMode') {
71+
if ($modeArg->class instanceof Name && $modeArg->class->name === 'RoundingMode') {
72+
if (!($modeArg->name instanceof Node\Identifier)) {
73+
return null;
74+
}
7175
$constantName = match ($modeArg->name->name) {
7276
'HalfAwayFromZero' => 'PHP_ROUND_HALF_UP',
7377
'HalfTowardsZero' => 'PHP_ROUND_HALF_DOWN',

0 commit comments

Comments
 (0)