-
-
Notifications
You must be signed in to change notification settings - Fork 223
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
TASK: Optimise php imports in Neos 9 code #4747
TASK: Optimise php imports in Neos 9 code #4747
Conversation
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.
👍 by 👀
Hmm I just had a change of mind. To be kind to our existing Mammut prs ill delay this cosmetic cleanup as it can be run at any point automatically ;) |
Thanks for your reviews though ;) |
515ca31
to
7977bac
Compare
With all the elephants merged a change like this can now be more safely carried out ;) (we wont hurt any other big pr) |
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.
Works for me, but ordering imports by name is useless if we don't have any rule to keep this also in future.
Shall we add https://cs.symfony.com/doc/rules/import/ordered_imports.html ? |
Hmm seeing that we have already php cs (im not using it locally really ...) thats not a bad idea. |
Especially because it is enforced by our CI ( Related: #4580 |
@bwaidelich i stand completely on the schlauch i dont know how to set this up and it might be that i confused php cs and the fixer 😅 in the end we want a linter and not a fixer, or at least first a linter and then a fixer on top. But i couldnt find a sniff in php code sniffer that does this. I tried extending your new xml somehow but there seems to sniff? |
PHP_CodeSniffer is pretty confusing.. In our case: And then there is PHP-CS-Fixer that is a different, unrelated, tool that also provides a linter & fixer. But we don't use that (yet). Unfortunately, detecting unused import statements is not yet available for PHPCS and seems to be a very complex task. |
A little PHP-CS-Fixer experiment: #4949 |
@mhsdesign I ran my experiment with your PR and it reduces the violating files from 237 to 29. But after applying the fixer, I still get a diff: edit: ..which is to be expected, those are just the remaining |
Wow thanks @bwaidelich for explaining. it really seems that they choose unwise namings ^^ I would propose to merge this now, and create a separate pr to fix violations in 8.3 Also linting in ci seems more complex and not a one liner so let’s merge this first and keep #4949 as a follow-up That way we can continue with other mamut prs right now (e.g. node identity) |
Related: #4580
Phpstorm supports to optimise imports via
Optimise Imports [ctrl+alt+O]
This will not only remove outdated imports but also sort them.
In the past when removing a usage i deleted the line manually without sorting to prevent merge conflicts,
but i would like to use the key stroke generally and know that others do as well.
So with care that we do want to upmerge things from 8.3 i ran the import optimisation across the whole repository but only committed newer neos 9 code.
New neos code lies in
Neos.ContentRepository*
,Neos.ContentGraph*
,Neos.TimeableNodeVisibility
and partially in selected subdirectories and files ofNeos.Neos
(my strategy was if the file was already touched for a neos 9 refactoring (e.g. we import the contentRepository) its fine to cleanup here).After this change optimising imports can be carried out safely (at least in new code) as the imports are now tidied.
This will prevent needless mergeconflicts across prs in the future and should improve our workflow.
Upgrade instructions
Review instructions
This change should not make upmerging harder than before as the classes in
Neos.ContentRepository*
didnt exist in 8.3 and the few classes modified inNeos.Neos
have been adjusted in general for Neos 9.Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions