-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Make global usage of use in header of files #78
Comments
I agree. Do you know a tool that could do that ? |
Hmm, it might be possible to automatically change this, or include it in PHP-CS. |
There is a sniff that checks all referenced names are imported via the |
Yes, that is true. Okay, so only manually doing this is possible. So this will change a lot files. How should I proceed to make this lesser painful [to reviewers]? For each "package" (namespace) a separate PR? Or per folder a separate PR (to keep them small)? |
@Quix0r I just examined the sniff I posted and I think I can make it auto-fixable for non-conflicting cases during this or next weekend if you are willing to wait :-) |
@jankonas sure, will wait here. |
Sorry for the delay, I don't have the time to do this right now. But Slevomat released v2.0 of their coding standard which now has the SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly sniff auto-fixable. So I suggest using it and keeping it in the project so it checks usage of uses in the future. Of course, many of the other sniffs have to be excluded to pass the checks. |
As mentioned in PR #75 it is better to use
use
in header. Then you only need to change that header and not all references in many lines.A very tiny example:
Now just imagine the world without
use
, you have to update many lines. Withuse
, you only need to touch the header of the file, nothing more.The text was updated successfully, but these errors were encountered: