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
Refactor: constant array type inference #6279
Refactor: constant array type inference #6279
Conversation
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.
Seems great. Could there be an opportunity to mutualize the code here with what's in ArrayAnalyzer?
); | ||
} | ||
|
||
// if this array looks like an object-like array, let's return that instead |
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.
Maybe a similar check could be done for inferring TList?
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.
You mean, for cases where it crossed the threshold for can_create_objectlike
?
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 saw multiple cases where can_create_objectlike can be false, so any of those I guess
); | ||
} | ||
} else { | ||
$array_creation_info->item_key_atomic_types[] = new Type\Atomic\TInt(); |
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.
We could probably directly put a TLiteralInt with $int_offset in here I think
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.
Perhaps. That wouldn't be a refactoring in its strict sense though 😄
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.
fair enough :)
To share? I thought so, e.g. |
This brings constant array type inference closer to non-constant analysis, and is a step toward fixing #6263