From c1e866eedb5706cda5fb9226c9f652fc145e6e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= <5175937+theofidry@users.noreply.github.com> Date: Sun, 5 May 2024 20:13:31 +0200 Subject: [PATCH] fix: Do not prefix excluded functions used in `call_user_func_array()` (#1028) --- .../func-arg-call-user-func.php | 2 ++ .../NodeVisitor/StringScalarPrefixer.php | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/specs/string-literal/func-arg-call-user-func.php b/specs/string-literal/func-arg-call-user-func.php index 2d7087dd..c0b7db4f 100644 --- a/specs/string-literal/func-arg-call-user-func.php +++ b/specs/string-literal/func-arg-call-user-func.php @@ -23,6 +23,7 @@ 'FQCN string argument' => <<<'PHP' belongsToTheGlobalNamespace($string) - ) { - return $string; - } - - return $this->enrichedReflector->isClassExcluded($normalizedValue) + if ($isConstantNode) { + return $this->enrichedReflector->isExposedConstant($normalizedValue) ? $string : $this->createPrefixedString($string); } - return $this->enrichedReflector->isExposedConstant($normalizedValue) + if ('define' === $functionName + && $this->belongsToTheGlobalNamespace($string) + ) { + return $string; + } + + return $this->enrichedReflector->isClassExcluded($normalizedValue) + || $this->enrichedReflector->isFunctionExcluded($normalizedValue) ? $string : $this->createPrefixedString($string); }