Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
Loading