Skip to content

Conversation

rajyan
Copy link
Contributor

@rajyan rajyan commented Oct 29, 2022

…ous functions

Refactor anonymous function scope to use invalidate logic of assignVariable instead of the duplication.
This makes the logic consistent with
#1934

@rajyan rajyan force-pushed the arrow-function-scope-refactor branch from 38f01d3 to a59c5f9 Compare October 29, 2022 01:20
@rajyan
Copy link
Contributor Author

rajyan commented Oct 29, 2022

My thinking is that, conditionalExpressionTypes should be only handled in two places.
Specified in specifyExpressionType and invalidated in assignVariable.
This can make the merge of conditionalExpressionTypes and ExpressionTypes much easier.

@ondrejmirtes
Copy link
Member

Does this change anything in type inference? Should there be a test?

continue;
}

$conditionalExpressions[$conditionalExprString] = $newHolders;
Copy link
Contributor Author

@rajyan rajyan Oct 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was never called because of the above foreach in line 3028.

}
}

$newHolders[] = $holder;
Copy link
Contributor Author

@rajyan rajyan Oct 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is always newHolders === holders because of the continue 3

Comment on lines -3098 to -3100
foreach ($parameterVariableExpressions as $expr) {
$scope = $scope->invalidateExpression($expr, true);
}
Copy link
Contributor Author

@rajyan rajyan Oct 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is handled in assignVariable's invalidateExpression

@rajyan
Copy link
Contributor Author

rajyan commented Oct 29, 2022

@ondrejmirtes

Does this change anything in type inference? Should there be a test?

From the investigations above, I believe using assignVarible is equal to the code before.

@ondrejmirtes
Copy link
Member

Alright, great, thank you :)

@ondrejmirtes ondrejmirtes merged commit 649c251 into phpstan:1.9.x Oct 29, 2022
@rajyan rajyan deleted the arrow-function-scope-refactor branch October 29, 2022 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants