chore: remove useless static variables for const content#8836
Merged
keradus merged 18 commits intoPHP-CS-Fixer:masterfrom Jul 15, 2025
Merged
chore: remove useless static variables for const content#8836keradus merged 18 commits intoPHP-CS-Fixer:masterfrom
keradus merged 18 commits intoPHP-CS-Fixer:masterfrom
Conversation
gharlan
commented
Jul 12, 2025
keradus
reviewed
Jul 12, 2025
keradus
reviewed
Jul 12, 2025
keradus
reviewed
Jul 12, 2025
# Conflicts: # src/Fixer/AbstractShortOperatorFixer.php
This comment was marked as outdated.
This comment was marked as outdated.
keradus
reviewed
Jul 14, 2025
keradus
reviewed
Jul 15, 2025
Member
keradus
left a comment
There was a problem hiding this comment.
(partial review, just to give some direction)
keradus
reviewed
Jul 15, 2025
keradus
reviewed
Jul 15, 2025
keradus
reviewed
Jul 15, 2025
keradus
reviewed
Jul 15, 2025
keradus
reviewed
Jul 15, 2025
keradus
approved these changes
Jul 15, 2025
Member
|
good job @gharlan , thank you |
gharlan
commented
Jul 15, 2025
| 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]; |
Member
Author
There was a problem hiding this comment.
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)
Member
There was a problem hiding this comment.
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]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.