Skip to content

Commit

Permalink
Refactor to invalidate args inside processArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 5, 2023
1 parent 205928f commit 52eb6f8
Showing 1 changed file with 4 additions and 27 deletions.
31 changes: 4 additions & 27 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2132,15 +2132,6 @@ static function (): void {
$scope = $scope->afterOpenSslCall($functionReflection->getName());
}

if (
$functionReflection !== null
&& $functionReflection->hasSideEffects()->yes()
) {
foreach ($expr->getArgs() as $arg) {
$scope = $scope->invalidateExpression($arg->value, true);
}
}

} elseif ($expr instanceof MethodCall) {
$originalScope = $scope;
if (
Expand Down Expand Up @@ -2196,11 +2187,7 @@ static function (): void {
$hasSideEffects = $methodReflection->hasSideEffects();
if ($hasSideEffects->yes() || $methodReflection->getName() === '__construct') {
$scope = $scope->invalidateExpression($expr->var, true);
foreach ($expr->getArgs() as $arg) {
$scope = $scope->invalidateExpression($arg->value, true);
}
}

if ($parametersAcceptor !== null) {
$selfOutType = $methodReflection->getSelfOutType();
if ($selfOutType !== null) {
Expand Down Expand Up @@ -2373,14 +2360,6 @@ static function (): void {
$scope = $scope->invalidateExpression(new Variable('this'), true);
}

if ($methodReflection !== null) {
if ($methodReflection->hasSideEffects()->yes() || $methodReflection->getName() === '__construct') {
foreach ($expr->getArgs() as $arg) {
$scope = $scope->invalidateExpression($arg->value, true);
}
}
}

$hasYield = $hasYield || $result->hasYield();
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
} elseif ($expr instanceof PropertyFetch) {
Expand Down Expand Up @@ -2689,12 +2668,6 @@ static function (): void {
$expr->getArgs(),
$constructorReflection->getVariants(),
);
$hasSideEffects = $constructorReflection->hasSideEffects();
if ($hasSideEffects->yes()) {
foreach ($expr->getArgs() as $arg) {
$scope = $scope->invalidateExpression($arg->value, true);
}
}
$constructorThrowPoint = $this->getConstructorThrowPoint($constructorReflection, $parametersAcceptor, $classReflection, $expr, $expr->class, $expr->getArgs(), $scope);
if ($constructorThrowPoint !== null) {
$throwPoints[] = $constructorThrowPoint;
Expand Down Expand Up @@ -3623,7 +3596,11 @@ private function processArgs(
$argValue = $arg->value;
if ($argValue instanceof Variable && is_string($argValue->name)) {
$scope = $scope->assignVariable($argValue->name, $byRefType, new MixedType());
} else {
$scope = $scope->invalidateExpression($argValue);
}
} elseif ($calleeReflection !== null && $calleeReflection->hasSideEffects()->yes()) {
$scope = $scope->invalidateExpression($arg->value, true);
}
}

Expand Down

0 comments on commit 52eb6f8

Please sign in to comment.