WordPress.org

Make WordPress Core

#24582 closed enhancement (invalid)

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

Reported by: 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)

comment:1 chriscct710 months 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 months ago by chriscct7 (previous) (diff)

comment:2 chriscct710 months ago

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

comment:3 Looimaster10 months 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 with conditions visually.

Version 1, edited 10 months ago by Looimaster (previous) (next) (diff)

comment:4 Looimaster10 months ago

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

comment:5 chriscct710 months 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

comment:6 rmccue10 months ago

  • Keywords close added

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

comment:7 ocean9010 months 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.