Skip to content

Commit

Permalink
[CodeQuality] Skip different array_filter value on SimplifyEmptyArray…
Browse files Browse the repository at this point in the history
…CheckRector (#3000)

* [CodeQuality] Skip different array_filter value on SimplifyEmptyArrayCheckRector

* Fixed 🎉

* cs fix
  • Loading branch information
samsonasik committed Oct 17, 2022
1 parent 63976bc commit 56620a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector\Fixture;

final class SkipDifferentArrayFilterValue
{
public function functionCallInsideEmpty($a, $values): bool
{
return is_array($a) && empty(array_filter($values));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public function refactor(Node $node): ?Node
/** @var Empty_ $emptyOrNotIdenticalNode */
$emptyOrNotIdenticalNode = $twoNodeMatch->getSecondExpr();

if ($emptyOrNotIdenticalNode->expr instanceof FuncCall) {
if ($emptyOrNotIdenticalNode->expr instanceof FuncCall && $this->nodeComparator->areNodesEqual(
$emptyOrNotIdenticalNode->expr->args[0]->value,
$firstArgValue
)) {
return new Identical($emptyOrNotIdenticalNode->expr, new Array_());
}

Expand Down

0 comments on commit 56620a9

Please sign in to comment.