On Tue, Apr 15, 2008 at 9:51 AM, Roan Kattouw <roan.kattouw(a)home.nl> wrote:
It should be noted
that brace and parenthesis styles are somewhat mixed in the MW code
(especially in the API), but those are minor differences such as not
putting an extra space after a ( or putting a { on a separate line.
The "official" brace style, as stated in docs/design.txt, in K&R:
opening braces go on the same line. This is followed pretty carefully
throughout the entire core code base:
aryeh@aryeh-desktop:/var/www/trunk/phase3$ find -iregex
'^.*\.\(php\|inc\)$' -exec grep '^\s*{' {} + | grep -v
languages/messages | wc -l
510
aryeh@aryeh-desktop:/var/www/trunk/phase3$ find -iregex
'^.*\.\(php\|inc\)$' -exec grep '^.*[^\s].*{' {} + | grep -v
languages/messages | wc -l
22440
(Some spot-checking makes it seem like those hits are all legit --
with a few weird outliers like "blah {$varname}".) Parenthesis
spacing is more spotty:
aryeh@aryeh-desktop:/var/www/trunk/phase3$ find -iregex
'^.*\.\(php\|inc\)$' -exec grep '\(if\|while\|for\|foreach\) ( ' {} +
| wc -l
5861
aryeh@aryeh-desktop:/var/www/trunk/phase3$ find -iregex
'^.*\.\(php\|inc\)$' -exec grep '\(if\|while\|for\|foreach\)([^ ]' {}
+ | wc -l
858
aryeh@aryeh-desktop:/var/www/trunk/phase3$ find -iregex
'^.*\.\(php\|inc\)$' -exec grep '\(if\|while\|for\|foreach\) ([^ ]' {}
+ | wc -l
2024
aryeh@aryeh-desktop:/var/www/trunk/phase3$ find -iregex
'^.*\.\(php\|inc\)$' -exec grep '\(if\|while\|for\|foreach\)( ' {} + |
wc -l
4198
Personally I like the last of those, like if( condition ) {. But the
first, like if ( condition ), seems to be about as common. Maybe we
should adopt a convention. :)