-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
RemoveUnusedNonEmptyArrayBeforeForeachRector: skip array dim fetch #5166
Conversation
|
||
public static function getFootnotes($group = self::DEFAULT_GROUP): array | ||
{ | ||
if (! empty(self::$groups[$group])) { |
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.
since we already skip "regular" dim fetch, I think it makes sense to also skip it for this example
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.
is it possible to to check native ArrayDimFetch type for this case?
if ($foreachExpr instanceof Expr\ArrayDimFetch) {
$nativeType = $this->nodeTypeResolver-getNativeType(...
}
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.
Do you have a test case in mind which fails atm?
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.
something like assign in prev stmt:
self::$groups[$group] = ["foo"];
if (! empty(self::$groups[$group]))
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.
fixed with 0edaf2d
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.
could you fix phpstan notice? thank you.
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.
good catch :-). fixed.
Thank you @staabm |
closes rectorphp/rector#8264