Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#24582 closed enhancement (invalid)

Why WordPress PHP spacing standards aren't compatible with PHP standards?

Reported by: looimaster's profile Looimaster Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

I'm wondering why WordPress PHP guide requires that files have spaces after each bracket and before/after single quotes and in other places that they aren't used by most of the PHP developers (including PHP creators): http://make.wordpress.org/core/handbook/coding-standards/php/#php

Is this something that is likely to change in the future?

Change History (7)

#1 @chriscct7
10 years ago

Mostly readability, but given its been that way since the project start I highly doubt a change is coming.

WordPress follows an interpretation of the PEAR style which is used by several other large projects like Drupal for instance.

PEAR's guide clearly states spaces before and after braces.

Last edited 10 years ago by chriscct7 (previous) (diff)

#2 @chriscct7
10 years ago

  • Cc chriscct7@… added
  • Severity changed from normal to trivial
  • Type changed from defect (bug) to enhancement

#3 @Looimaster
10 years ago

  • Severity changed from trivial to normal
  • Type changed from enhancement to defect (bug)

Yes, I agree that spaces should be used but like this:

if ((condition1) || (condition2)) {

and they are used like this now:

if ( ( condition1 ) || ( condition2 ) ) {

That's the only thing that is puzzling me because 95% of PHP libraries that I download use the first convention. I can read both but the second one mixes if() statement with conditions inside visually.

Last edited 10 years ago by Looimaster (previous) (diff)

#4 @Looimaster
10 years ago

  • Severity changed from normal to trivial
  • Type changed from defect (bug) to enhancement

#5 @chriscct7
10 years ago

It's just for readability. However, I'm not sure exactly what you want with this Trac ticket. Trac is used for fixing bugs and doing patches to the core. Questions about how WordPress works or why WordPress does something belong in the WordPress.org forums, or you can ask them (if you prefer a StackOverflow layout) at wordpress.stackexchange.com

#6 @rmccue
10 years ago

  • Keywords close added

As much as I hate this rule (and boy, do I hate it), it's not going to change.

#7 @ocean90
10 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Severity changed from trivial to normal
  • Status changed from new to closed

Is this something that is likely to change in the future?

Not really. It's our coding standard. I like spaces, because it lets the code breathe.

Note: See TracTickets for help on using tickets.