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
- 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)
#3
@
13 years ago
- Severity trivial → normal
- Type enhancement → 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.
#5
@
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
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.