[wp-trac] [WordPress Trac] #41057: Update PHP codebase per WordPress PHP Coding Standards

WordPress Trac noreply at wordpress.org
Tue Mar 13 16:02:36 UTC 2018


#41057: Update PHP codebase per WordPress PHP Coding Standards
----------------------------+-------------------------------
 Reporter:  netweb          |       Owner:  pento
     Type:  task (blessed)  |      Status:  closed
 Priority:  normal          |   Milestone:  5.0
Component:  General         |     Version:
 Severity:  normal          |  Resolution:  fixed
 Keywords:  early commit    |     Focuses:  coding-standards
----------------------------+-------------------------------

Comment (by mboynes):

 Replying to [comment:59 pento]:
 > Array elements aren't aligning at the `=>`. It's mentioned (and shown in
 the examples) in the [https://make.wordpress.org/core/handbook/best-
 practices/coding-standards/php/#indentation Handbook], but I can make that
 more explicit if necessary. More
 [https://wordpress.slack.com/archives/C5VCTJGH3/p1504491187000089?thread_ts=1504483321.000002&cid=C5VCTJGH3
 info in Slack], and [https://github.com/WordPress-Coding-Standards
 /WordPress-Coding-Standards/issues/1122 WPCS#1122].

 I'm late to the party, but didn't see this mentioned anywhere. One of the
 problems with vertical alignment is that future changes might require
 other lines get updated if the alignment changes. That is, if you add a
 new variable or array key which is longer than the others, you have to
 change the whitespace on the other lines to align them. This leads to
 "messy" diffs and more potential for merge conflicts, and contradicts the
 coding standard recommendation for trailing commas:

 > this is recommended because it... makes for cleaner diffs when new items
 are added

 It was discussed in this ticket that vertical alignment be made a
 requirement; I would recommend against that for this reason.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41057#comment:118>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list