diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index 39ab04a148..d57e8271a7 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -37,6 +37,7 @@ use PhpParser\Node\Expr\StaticPropertyFetch; use PhpParser\Node\Expr\Ternary; use PhpParser\Node\Expr\Variable; +use PhpParser\Node\FunctionLike; use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\Stmt\Break_; @@ -5563,6 +5564,15 @@ private function processArgs( } $args = $callLike->getArgs(); + $hasAttributeGroups = ( + ($stmt instanceof FunctionLike && count($stmt->getAttrGroups()) > 0) + || (( + $stmt instanceof Node\Stmt\ClassLike + || $stmt instanceof Node\Stmt\ClassConst + || $stmt instanceof Node\Stmt\Property + || $stmt instanceof Node\Stmt\EnumCase + ) + && count($stmt->attrGroups) > 0)); $parameters = null; if ($parametersAcceptor !== null) { @@ -5574,6 +5584,24 @@ private function processArgs( $impurePoints = []; $isAlwaysTerminating = false; foreach ($args as $i => $arg) { + if (!$hasAttributeGroups) { + if ($arg->value instanceof ConstFetch) { + $loweredConstName = strtolower($arg->value->name->toString()); + if (in_array($loweredConstName, ['true', 'false', 'null'], true)) { + continue; + } + } + + if ( + $arg->value instanceof Node\Scalar\Int_ + || $arg->value instanceof Node\Scalar\Float_ + || ($arg->value instanceof Expr\UnaryMinus && $arg->value->expr instanceof Node\Scalar) + // don't skip strings and arrays as these might be callable references + ) { + continue; + } + } + $assignByReference = false; $parameter = null; $parameterType = null;