Skip to content

Commit 59576e4

Browse files
committed
fixup! fixup! fixup! add MakeUseOfContaintsStmtsRector
1 parent 766e9e1 commit 59576e4

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

utils/Rector/MakeUseOfContaintsStmtsRector.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,7 @@ public function getNodeTypes(): array
4141
public function refactor(Node $node): MethodCall|Identical|null
4242
{
4343
if ($node instanceof Identical) {
44-
if (! $this->valueResolver->isNull($node->right)) {
45-
return null;
46-
}
47-
48-
if ($this->isStmtsPropertyFetch($node->left)) {
49-
/** @var PropertyFetch $propertyFetch */
50-
$propertyFetch = $node->left;
51-
52-
$node->left = new MethodCall($propertyFetch->var, 'getStmts');
53-
$node->right = new Array_([]);
54-
55-
return $node;
56-
}
44+
return $this->refactorIdentical($node);
5745
}
5846

5947
if (! $this->isName($node->name, 'stmts')) {
@@ -75,4 +63,23 @@ private function isStmtsPropertyFetch(Expr $expr): bool
7563

7664
return $this->isName($expr->name, 'stmts');
7765
}
66+
67+
private function refactorIdentical(Identical $node): ?Identical
68+
{
69+
if (!$this->valueResolver->isNull($node->right)) {
70+
return null;
71+
}
72+
73+
if ($this->isStmtsPropertyFetch($node->left)) {
74+
/** @var PropertyFetch $propertyFetch */
75+
$propertyFetch = $node->left;
76+
77+
$node->left = new MethodCall($propertyFetch->var, 'getStmts');
78+
$node->right = new Array_([]);
79+
80+
return $node;
81+
}
82+
83+
return null;
84+
}
7885
}

0 commit comments

Comments
 (0)