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: |
|
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
- The proper PHP standard (and the most readable to the most of the population) is this: http://pl1.php.net/manual/en/function.function-exists.php
- Or this can be a reference as well: http://pear.php.net/manual/en/standards.funcdef.php
- Or in the worst case Google's coding standards should be used (although I don't like some of their decisions): http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml
Is this something that is likely to change in the future?
Change History (7)
#2
@
10 years ago
- Cc chriscct7@… added
- Severity changed from normal to trivial
- Type changed from defect (bug) to enhancement
#3
@
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.
#4
@
10 years ago
- Severity changed from normal to trivial
- Type changed from defect (bug) to enhancement
#5
@
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
@
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
@
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.
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.