Skip to content

refactor(rector): Run rector php74 upgrade #391

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
merged 7 commits into from
Apr 10, 2020

Conversation

olivernybroe
Copy link
Collaborator

Q A
Bug fix? no
New feature? yes

This PR upgrades our code to php74 with an auto upgrade from rector.

I have fixed some errors introduced from this auto upgrade and everything should be working now. 😄

This might be a hard one to look through as there are soo many small changes, sorry! 👍

@olivernybroe olivernybroe requested a review from Jibbarth April 10, 2020 12:52
@nunomaduro
Copy link
Owner

@olivernybroe Maybe this config:

# rector.yaml
parameters:
    sets:
        - 'action-injection-to-constructor-injection'
        - 'array-str-functions-to-static-call'
        - 'celebrity'
        - 'doctrine'
        - 'phpstan'
        - 'phpunit-code-quality'
        - 'solid'
        - 'early-return'
        - 'doctrine-code-quality'
        - 'dead-code'
        - 'code-quality'
        - 'php71'
        - 'php72'
        - 'php73'
        - 'php74'

@nunomaduro
Copy link
Owner

Can you also add rector as part of the composer lint command?

@olivernybroe
Copy link
Collaborator Author

@nunomaduro Cool, I'll try running with those sets and add it to composer command! :)

@TomasVotruba
Copy link

Let me know if you need any help ;)

@olivernybroe
Copy link
Collaborator Author

olivernybroe commented Apr 10, 2020

@TomasVotruba Thanks! 👍 Think I fixed all the errors in the code which caused problems.

The biggest problem I had was actually that rector removed a bunch of newlines between methods 😢 But phpcs fixed that.

Only needed to use the @noRector two places

@nunomaduro
Copy link
Owner

@olivernybroe Can we apply @noRector on the file we copied from phploc? The one that contains parses all the metrics?

@olivernybroe
Copy link
Collaborator Author

Alright this should be ready now 👍

@olivernybroe olivernybroe merged commit e96d56d into nunomaduro:master Apr 10, 2020
@olivernybroe olivernybroe deleted the rector-upgrade branch April 10, 2020 15:59
@olivernybroe olivernybroe linked an issue Apr 10, 2020 that may be closed by this pull request
@TomasVotruba
Copy link

TomasVotruba commented Apr 10, 2020

@olivernybroe Good job with using it! 👍

Yes, AST cannot handle spaces, only coding standards, see https://github.com/rectorphp/rector/blob/master/README.md#how-to-apply-coding-standards

Were there some false positives that should be fixed in core?

- 'php71'
- 'php72'
- 'php73'
- 'php74'

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh nice, totally something for us, thanks 😄

Just right up @nunomaduro alley.

@olivernybroe
Copy link
Collaborator Author

@TomasVotruba Ah right, makes sense as the lexer ofc. ignores white spaces.

Hmm there were one of the @noRector I think makes sense looking into. The other one was simply a library we used that does not define their type correctly. But looking at src/Domain/Kernel.php we have a constant called VERSION, it want' us to delete that one even though it actually is used in bin/phpinsights

I think this has something to do with rector prob. not scanning the file phpinsights as it does not have the file extension .php.

@TomasVotruba
Copy link

I see. That's actually correct, you need to include to bin to the paths, so Rector knows it's used.

@olivernybroe
Copy link
Collaborator Author

@TomasVotruba It is already included in paths 🤔

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

Successfully merging this pull request may close these issues.

Upgrade to PHP 7.4
3 participants