diff --git a/rules-tests/Php80/Rector/NotIdentical/StrContainsRector/Fixture/skip_empty_needle_strpos.php.inc b/rules-tests/Php80/Rector/NotIdentical/StrContainsRector/Fixture/skip_empty_needle_strpos.php.inc new file mode 100644 index 00000000000..479799cdccd --- /dev/null +++ b/rules-tests/Php80/Rector/NotIdentical/StrContainsRector/Fixture/skip_empty_needle_strpos.php.inc @@ -0,0 +1,11 @@ +getArgs(); + if (isset($args[1]) && $this->isEmptyStringNeedle($args[1]->value)) { + return null; + } + if (isset($funcCall->getArgs()[2])) { $secondArg = $funcCall->getArgs()[2]; @@ -132,4 +138,13 @@ private function isIntegerZero(Expr $expr): bool return $expr->value === 0; } + + private function isEmptyStringNeedle(Expr $expr): bool + { + if (! $expr instanceof String_) { + return false; + } + + return $expr->value === ''; + } }