Skip to content

Commit ddf64ef

Browse files
staabmondrejmirtes
authored andcommitted
Cleanup NodeScopeResolver
1 parent 35b18c4 commit ddf64ef

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

src/Analyser/NodeScopeResolver.php

+26-11
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
19361936
$hasYield = $result->hasYield();
19371937
$throwPoints = array_merge($throwPoints, $result->getThrowPoints());
19381938

1939-
if (isset($functionReflection)) {
1939+
if ($functionReflection !== null) {
19401940
$functionThrowPoint = $this->getFunctionThrowPoint($functionReflection, $parametersAcceptor, $expr, $scope);
19411941
if ($functionThrowPoint !== null) {
19421942
$throwPoints[] = $functionThrowPoint;
@@ -1946,7 +1946,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
19461946
}
19471947

19481948
if (
1949-
isset($functionReflection)
1949+
$functionReflection !== null
19501950
&& in_array($functionReflection->getName(), ['json_encode', 'json_decode'], true)
19511951
) {
19521952
$scope = $scope->invalidateExpression(new FuncCall(new Name('json_last_error'), []))
@@ -1956,7 +1956,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
19561956
}
19571957

19581958
if (
1959-
isset($functionReflection)
1959+
$functionReflection !== null
19601960
&& in_array($functionReflection->getName(), ['array_pop', 'array_shift'], true)
19611961
&& count($expr->getArgs()) >= 1
19621962
) {
@@ -1974,7 +1974,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
19741974
}
19751975

19761976
if (
1977-
isset($functionReflection)
1977+
$functionReflection !== null
19781978
&& in_array($functionReflection->getName(), ['array_push', 'array_unshift'], true)
19791979
&& count($expr->getArgs()) >= 2
19801980
) {
@@ -1986,13 +1986,16 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
19861986
}
19871987

19881988
if (
1989-
isset($functionReflection)
1989+
$functionReflection !== null
19901990
&& in_array($functionReflection->getName(), ['fopen', 'file_get_contents'], true)
19911991
) {
19921992
$scope = $scope->assignVariable('http_response_header', new ArrayType(new IntegerType(), new StringType()), new ArrayType(new IntegerType(), new StringType()));
19931993
}
19941994

1995-
if (isset($functionReflection) && $functionReflection->getName() === 'shuffle') {
1995+
if (
1996+
$functionReflection !== null
1997+
&& $functionReflection->getName() === 'shuffle'
1998+
) {
19961999
$arrayArg = $expr->getArgs()[0]->value;
19972000
$scope = $scope->assignExpression(
19982001
$arrayArg,
@@ -2002,7 +2005,7 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
20022005
}
20032006

20042007
if (
2005-
isset($functionReflection)
2008+
$functionReflection !== null
20062009
&& $functionReflection->getName() === 'array_splice'
20072010
&& count($expr->getArgs()) >= 1
20082011
) {
@@ -2020,7 +2023,10 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
20202023
);
20212024
}
20222025

2023-
if (isset($functionReflection) && $functionReflection->getName() === 'extract') {
2026+
if (
2027+
$functionReflection !== null
2028+
&& $functionReflection->getName() === 'extract'
2029+
) {
20242030
$extractedArg = $expr->getArgs()[0]->value;
20252031
$extractedType = $scope->getType($extractedArg);
20262032
if (count($extractedType->getConstantArrays()) > 0) {
@@ -2057,15 +2063,24 @@ function (MutatingScope $scope) use ($expr, $nodeCallback, $context): Expression
20572063
}
20582064
}
20592065

2060-
if (isset($functionReflection) && ($functionReflection->getName() === 'clearstatcache' || $functionReflection->getName() === 'unlink')) {
2066+
if (
2067+
$functionReflection !== null
2068+
&& ($functionReflection->getName() === 'clearstatcache' || $functionReflection->getName() === 'unlink')
2069+
) {
20612070
$scope = $scope->afterClearstatcacheCall();
20622071
}
20632072

2064-
if (isset($functionReflection) && str_starts_with($functionReflection->getName(), 'openssl')) {
2073+
if (
2074+
$functionReflection !== null
2075+
&& str_starts_with($functionReflection->getName(), 'openssl')
2076+
) {
20652077
$scope = $scope->afterOpenSslCall($functionReflection->getName());
20662078
}
20672079

2068-
if (isset($functionReflection) && $functionReflection->hasSideEffects()->yes()) {
2080+
if (
2081+
$functionReflection !== null
2082+
&& $functionReflection->hasSideEffects()->yes()
2083+
) {
20692084
foreach ($expr->getArgs() as $arg) {
20702085
$scope = $scope->invalidateExpression($arg->value, true);
20712086
}

0 commit comments

Comments
 (0)