-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
chore: remove useless static variables for const content #8836
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
Conversation
# Conflicts: # src/Fixer/AbstractShortOperatorFixer.php
This comment was marked as outdated.
This comment was marked as outdated.
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.
(partial review, just to give some direction)
good job @gharlan , thank you |
static $castTokens = [\T_ARRAY_CAST, \T_BOOL_CAST, \T_DOUBLE_CAST, \T_INT_CAST, \T_OBJECT_CAST, \T_STRING_CAST, \T_UNSET_CAST]; | ||
|
||
return $castTokens; | ||
return [\T_ARRAY_CAST, \T_BOOL_CAST, \T_DOUBLE_CAST, \T_INT_CAST, \T_OBJECT_CAST, \T_STRING_CAST, \T_UNSET_CAST]; |
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.
What do you think, should we deprecate the methods getCastTokenKinds, getClassyTokenKinds and getObjectOperatorKinds and introduce public constants instead?
(if yes, I would do this in a new pull request)
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.
tbh - no.
ie, deprecating sounds OKish, but new way doesn't sound good out of the blue.
I believe Token class is cluttered and I want to avoid introducing new elements to it without high-overview plan how to clean the class in total. [ie, avoid multiple migration steps]
Static variables with static content (e.g., static string or static array) appear to be slower than non-static variables or without any variables.
Also note that code without static variables is better for static analysis. That's why we get two new entries for phpstan baseline where phpstan knows for sure now how the array is structured.