use statements are supposed to be ordered alphabetically

Comments

vegantriathlete created an issue. See original summary.

vegantriathlete’s picture

Assigned: vegantriathlete » Unassigned
Status: Active » Needs review
StatusFileSize
new6.68 KB
cilefen’s picture

Title: Follow coding standards » Sort use statements
Category: Bug report » Task
Parent issue: » #2571965: [meta] Fix PHP coding standards in core, stage 1
Related issues: +#1791928: [policy] Coding standards for "use" statements

Hi @vegantriathlete:

Thanks for suggesting this improvement. Check out the parent issue—standards fixes are done for all of core and also must come with a phpcs rule. I think in this case there may be no such rule yet.

chi’s picture

use statements are supposed to be ordered alphabetically

Could you please add a reference on documentation about this. Do we have officially approved coding standard for this?

vegantriathlete’s picture

@Chi: As it turns out I don't think there is an official standard about how to order use statements. I think that I got the idea that there was one when I submitted a patch for a different module and the maintainer told me to sort my use statements alphabetically.

chi’s picture

Component: aggregator.module » other
Status: Needs review » Closed (won't fix)

@vegantriathlete That means there is notihng to fix here.

The documetnation says:

If there are multiple use declarations in a file, we do not currently have a standard about what order they should be in. However, consider code readability and do something sensible, especially if there are many use declarations.

Feel free to submit a proposal for this subject.
https://www.drupal.org/project/coding_standards

cilefen’s picture

jonathan1055’s picture

Version: 8.4.x-dev » 11.x-dev
Status: Closed (won't fix) » Active

Re-opening this now that the work is nearing completion in #1624564: Coding standards for "use" statements and the modification #3470716: Configure use-statement sniff to be case sensitive is in Coder 8.3.25, released on 22 Sept.

As of 5 October Core 11.x is still running Coder 8.3.24, but when it uses Coder 8.3.25 work can be started on fixing the files.

longwave’s picture

We should upgrade Coder in this issue and fix the use statements at the same time, in both 11.x and 10.4.x. This might be disruptive enough to existing patches to wait for the beta window, but we can certainly start now.

damienmckenna’s picture

Status: Active » Postponed

Let's postpone this issue until the coding standards issue is completed.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.