Skip to content
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

NoNullPropertyInitializationFixer - fix static properties as well #5752

Merged
merged 1 commit into from
Jun 27, 2021

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented May 29, 2021

The NoNullPropertyInitializationFixer doesn't fix properties with a default null value if they are static. This PR fixes the issue.

I added some extra logic to check if the token is inside a class, but not a method to avoid modifying static variables:

class Foo
{
    static $bar = null; // This is fixed

    public function foo()
    {
        static $baz = null; // This is skipped
    }
}

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 91.569% when pulling f33e72f on HypeMC:static-property-with-null into 15ddc20 on FriendsOfPHP:2.19.

@julienfalque julienfalque added this to the 2.19.1 milestone Jun 7, 2021
@kubawerlos
Copy link
Contributor

@julienfalque
if this is enhancement ➡️ target branch is incorrect,
if this is a bug ➡️ label is incorrect.

@julienfalque
Copy link
Member

if this is enhancement -> target branch is incorrect

Is it? Until now I thought we considered enhancements as something in between bugs and new features, e.g. something a rule does not do yet but should have done from the beginning, like this PR.

@kubawerlos kubawerlos added the RTM Ready To Merge label Jun 21, 2021
@keradus keradus removed the RTM Ready To Merge label Jun 27, 2021
@keradus
Copy link
Member

keradus commented Jun 27, 2021

since a while i was move toward "enhancements === features". but yeah, we have no official, clear policy. I'm happy to merge to both lines.

@keradus
Copy link
Member

keradus commented Jun 27, 2021

Thank you @HypeMC.

@keradus keradus merged commit d76088f into PHP-CS-Fixer:2.19 Jun 27, 2021
@HypeMC HypeMC deleted the static-property-with-null branch June 27, 2021 13:07
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.

None yet

6 participants