diff --git a/rules-tests/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector/Fixture/skip_inside_define_check.php.inc b/rules-tests/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector/Fixture/skip_inside_define_check.php.inc new file mode 100644 index 00000000000..700515b4414 --- /dev/null +++ b/rules-tests/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector/Fixture/skip_inside_define_check.php.inc @@ -0,0 +1,15 @@ +betterNodeFinder->findFirstPreviousOfNode( + $node, + function (Node $subNode) use ($constants): bool { + if (! $subNode instanceof FuncCall) { + return false; + } + + if (! $this->nodeNameResolver->isName($subNode, 'defined')) { + return false; + } + + $args = $subNode->getArgs(); + if (! isset($args[0])) { + return false; + } + + if (! $args[0]->value instanceof String_) { + return false; + } + + return in_array($args[0]->value->value, $constants, true); + } + ); + + if ($defined) { + return null; + } + if ($node instanceof ConstFetch) { return $this->cleanByConstFetch($node, $constants); }