-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 10922: array type in foreach #3029
Conversation
src/Analyser/NodeScopeResolver.php
Outdated
@@ -951,7 +951,10 @@ private function processStmtNode( | |||
]), | |||
))); | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the purpose of
if ($this->polluteScopeWithAlwaysIterableForeach) {
$finalScope = $finalScope->mergeWith($scope->filterByTruthyValue(new BooleanOr(
new BinaryOp\Identical(
$stmt->expr,
new Array_([]),
),
new FuncCall(new Name\FullyQualified('is_object'), [
new Arg($stmt->expr),
]),
)));
} else {
$finalScope = $finalScope->mergeWith($scope);
}
But I soon as I make this change, the issue is solved.
I dunno
- if it has a bad impact (I can add tests if you had some in mind)
- if I should just remove the else part and the if condition.
This pull request has been marked as ready for review. |
public static function getAdditionalConfigFiles(): array | ||
{ | ||
return [ | ||
__DIR__ . '/../../../conf/bleedingEdge.neon', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging with parent would be better (I think bleedingEdge is there already)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parent is
/**
* @return string[]
*/
public static function getAdditionalConfigFiles(): array
{
return [];
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NodeScopeResolverTest use
public static function getAdditionalConfigFiles(): array
{
return [
__DIR__ . '/../../../conf/bleedingEdge.neon',
__DIR__ . '/typeAliases.neon',
];
}
I followed the same idea
Thank you. |
Closes phpstan/phpstan#10922