8000 Changed private static array-properties to const by simonberger · Pull Request #39959 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Changed private static array-properties to const #39959

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

Merged

Conversation

simonberger
Copy link
Contributor
@simonberger simonberger commented Jan 24, 2021
Q A
Branch? 4.4
Bug fix? no
New feature? no
Deprecations? no
License MIT

This changes all private static properties (just screened arrays) to private const. I left out those which have write access obviously and also those with static:: access.

It is a new implementation of #38213. Based on 4.4 this time.
If merging it up creates several conflicts, you could ignore all changes of 4.4 and I create a new branch for 5.1 or 5.2. I'll do this anyway if any new private static arrays are existing there.

@carsonbot carsonbot added this to the 4.4 milestone Jan 24, 2021
@simonberger simonberger force-pushed the private-static-array-to-const branch 4 times, most recently from a2cf584 to 7cd6f49 Compare January 24, 2021 23:42
@simonberger simonberger force-pushed the private-static-array-to-const branch from 7cd6f49 to aa79381 Compare January 24, 2021 23:44
@nicolas-grekas
Copy link
Member

Can this change be automated? If not, then I'm likely 👎
merging in 5.1 or higher won't reduce merge conflicts - it will increase them actually.

@simonberger
Copy link
Contributor Author

@nicolas-grekas

Can this change be automated? If not, then I'm likely 👎

I don't know of any tool providing this as an automation.

merging in 5.1 or higher won't reduce merge conflicts - it will increase them actually.

What do you exactly mean? Because of merge conflicts I offered to redo all the work on the next branches. I can prepare them already in advance. In a merge you can ignore all conflicts this branch creates. Similar to how fabpot did it with this PR #39775 (comment)

In the previous PR everyone was generally 👍 for the change. As some time has passed and no one of the team did it I repeated the work (It's not that costly; took around 1,5 hours).

@stof
Copy link
Member
stof commented Jan 25, 2021

Well, this can probably not be automated, because we cannot forbid using private static in the project. We might have valid use cases for it. But this should be a one-time conversion anyway.
Our new code is already using private constant when possible instead of private static arrays.

Copy link
Member
@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I forgot about this previous discussion.
Let's go.

@nicolas-grekas
Copy link
Member

Thank you @simonberger.

@nicolas-grekas nicolas-grekas merged commit 4181c43 into symfony:4.4 Jan 25, 2021
@simonberger simonberger deleted the private-static-array-to-const branch January 25, 2021 14:05
@nicolas-grekas
Copy link
Member

Now merged up to 5.x. PR welcome for 5.1+

@simonberger
Copy link
Contributor Author

Looks like you solved all conflicts. Thank you. :)
I'll add a PR later.

nicolas-grekas added a commit that referenced this pull request Jan 25, 2021
…simonberger)

This PR was merged into the 5.1 branch.

Discussion
----------

Changed private static array-properties to const (5.1)

| Q             | A
| ------------- | ---
| Branch?       | 5.1
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| License       | MIT

This continues #39959 for 5.1
Just a few newly introduced readonly static array-properties.

/cc @nicolas-grekas

Commits
-------

f891fb2 Changed private static array-properties to const static properties newly introduced in 5.1
nicolas-grekas added a commit that referenced this pull request Jan 25, 2021
…simonberger)

This PR was merged into the 5.2 branch.

Discussion
----------

Changed private static array-properties to const (5.2)

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| License       | MIT

This continues #39959 for 5.2
Just two array-properties and a string property in one class newly added.

/cc @nicolas-grekas

Commits
-------

a5fd0c4 Changed private static array-properties to const static properties newly introduced in 5.2
@TomasVotruba
Copy link
Contributor

Can this change be automated? If not, then I'm likely -1

It can :)
https://github.com/rectorphp/rector/blob/master/docs/rector_rules_overview.md#changereadonlyvariablewithdefaultvaluetoconstantrector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0