Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#24582 closed enhancement (invalid)

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

Reported by: Looimaster Owned by:
Priority: normal Milestone:
Component: General Version:
Severity: normal Keywords:
Cc: Focuses:

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
13 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 13 years ago by chriscct7 (previous) (diff)

#2 @chriscct7
13 years ago

  • Cc chriscct7@… added
  • Severity normaltrivial
  • Type defect (bug)enhancement

#3 @Looimaster
13 years ago

  • Severity trivialnormal
  • Type enhancementdefect (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 13 years ago by Looimaster (previous) (diff)

#4 @Looimaster
13 years ago

  • Severity normaltrivial
  • Type defect (bug)enhancement

#5 @chriscct7
13 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
13 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
13 years ago

  • Keywords close removed
  • Milestone Awaiting Review
  • Resolutioninvalid
  • Severity trivialnormal
  • Status newclosed

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.