http://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP
Using assignment as expression looks like a mistake
<span>//</span><span> No</span> <span>if</span> ( <span>$a</span> =<span> foo() ) { bar(); }</span>
<span>//</span><span> Yes</span> <span>$a</span> =<span> foo(); </span><span>if</span> ( <span>$a</span><span> ) { bar(); }</span>
To improve code readability, Mediawiki uses a lot of spaces
Binary operator
<span>//</span><span> No</span> <span>$a</span>=<span>$b</span>+<span>$c</span><span>; </span><span>//</span><span> Yes</span> <span>$a</span> = <span>$b</span> + <span>$c</span>;
Follow the function name directly with parentheses; if there are parameters within the parentheses, add spaces on both sides
<span>//</span><span> Yes</span> <span>$a</span> = getFoo( <span>$b</span><span> ); </span><span>$c</span> = getBar();
Control structure if while for foreach switch, keyword catch, followed by spaces
<span>//</span><span> Yes</span> <span>if</span><span> ( isFoo() ) { </span><span>$a</span> = 'foo'<span>; } </span><span>//</span><span> No</span> <span>if</span><span>( isFoo() ) { </span><span>$a</span> = 'foo'<span>; }</span>
Forced type conversion
<span>//</span><span> Yes</span> (int)<span>$foo</span><span>; </span><span>//</span><span> No</span> (int) <span>$bar</span><span>; ( int )</span><span>$bar</span><span>; ( int ) </span><span>$bar</span>;
Comments
<span>//</span><span> Yes: Proper inline comment //No: Missing space</span>
Ternary operator
Use If unless the expression is very short. Remember it’s all about code readability.
"if" is English; ?: is not.