PHP CODING STANDARDS (not official - draft)

...

Total 20 comments:

#469
?
by jonah at 7:46pm on July 13, 2009.

is this official? doesn't seem like it...

#470
I don't get it.
by pestaa at 7:16pm on July 13, 2009.

If this is not official, how can you name this as "standard"? I think it'd be better if you contact any admin before putting this all together and release it to public.

#471
Uhm...
by xx666xx at 7:50pm on July 13, 2009.

You know I wrote out this long comment detailing the craziness of this document. But I decided against posting it.

#473
I said it was not official
by Vince at 7:59pm on July 13, 2009.

And i did contact the admin first, And he suggested to post this here. It's just a recommendation for coding standards not a "must do" coding standards. As zend have theirs coding standards i thought Yii developers should have one too. No one forced anyone to use them or even read it, Who ever feels like he could improve them can go ahead and read it and acknowledge, The others that have nothing good to say just spare your comments.

#474
Nice
by Q-efx at 7:10pm on July 14, 2009.

good work. But when you write: Use 4 spaces to indent content. The source code should it. Like this:

The opening brace is written on the same line as the conditional statement. The closing brace is always written on its own line. Any content within the braces must be indented four spaces.

if ($a != 2) {

$a = 2;

}

If you copy and paste. You create sometimes false content :)

#475
Yea i know
by Vince at 7:19am on July 15, 2009.

But i am sure who read it understands what's written even if the example has some bugs and glitches

#480
Bullshit
by creocoder at 7:16pm on July 18, 2009.

Open any framework source file and you'll see coding standarts.

#481
Good work!
by skippy at 7:26am on July 19, 2009.

This is exactly what Yii is missing!

I would suggest to polish it a bit and than include it as a part of official documentation. What do you think Qiang?

#507
That link is terrible
by DarkNSF at 7:05pm on July 27, 2009.

Yii coding standards should somewhat resemble java conventions..

http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html

#519
IF and SWITCH identation
by Mirco at 7:20pm on July 31, 2009.

In the if and switch construct there is a tradeoff to readability. Maybe it is just me, but I don't like to read these constructs: if (a!==b) { //do this } else { // do that }

I prefer indenting like this: if (a!==b) { //do this } else { // do that }

The same goes for the switch: switch (somevalue) { case 1: //do this break; case 2: //do that break; }

For me this improves readability, but on the other hand you must type more and it takes more lines.

#520
IF and SWITCH identation (corrected)
by Mirco at 7:25pm on July 31, 2009.

In the if and switch construct there is a tradeoff to readability. Maybe it is just me, but I don't like to read these constructs:
if (a!==b)
//do this
} else {
// do that
}

I prefer indenting like this:

if (a!==b) 
{
//do this
}
else
{
// do that
}

The same goes for the switch:
switch (somevalue)
{
case 1:
//do this
break;
case 2:
//do that
break;
}

For me this improves readability, but on the other hand you must type more and it takes more lines.

#521
IF and SWITCH again
by Mirco at 7:28pm on July 31, 2009.

I'm sorry for the inconvenience. I pressed submit by mistake.

For the third time, I'll try to make my statement:

In the if and switch construct there is a tradeoff to readability. Maybe it is just me, but I don't like to read these constructs:

if (a!==b) 
//do this 
} else { 
// do that 
} 

I prefer indenting like this:

if (a!==b) 
    { 
        //do this 
    } 
else 
    { 
        // do that 
    } 

The same goes for the switch:

switch (somevalue) 
{ 
    case 1: 
        //do this 
        break; 
    case 2: 
        //do that 
        break; 
}
For me this improves readability, but on the other hand you must type more and it takes more lines.
#565
Its a good idea
by Polydoro.cardozo at 8:34pm on August 10, 2009.

Its a good ideia however I think it should be placed in Yii online docs.

Another point: Its not so readable

#586
..
by jonah at 8:34pm on August 14, 2009.

Don't framework coding standards refer to the standard of writing code for the core framework? Isn't Qiang really the only core developer right now? What's the point of this?

#590
I think
by Q-efx at 8:54pm on August 15, 2009.

It target extension developers also...

But it is down :p

Parse error: syntax error, unexpected '>' in /home/vadim/domains/vadimg.co.il/public_html/index.php on line 4

#655
Bad
by KJedi at 9:00am on September 13, 2009.

1) Using spaces instead of tabs is bad idea - takes more time to navigate with arrows. Any good editor or IDE easily converts spaces to tabs and adjusts tab width. So people use tabs! 2) I hate writing opening brace on the same line. I like it to be one under another so when you see the code, you see both opening and close brace on the same vertical. 3) Coding standards SHOULD FOLLOW THE CORE CODE STYLE!!! Nobody will change core just because you posted this document. Describing the style used in core by Qiang is a good idea while developing new standards is a bad one.

#784
bad
by Yada at 11:37pm on November 2, 2009.

I'll stick to the way the Yii framework core is coded and it doesn't use the non indenting style.

if () { thismakes me cringe. }

Examples of good standards: Google Web Toolkit http://code.google.com/webtoolkit/makinggwtbetter.html#codestyle

Java http://java.sun.com/docs/codeconv/CodeConventions.pdf

#1171
I agree with Yada
by DarkNSF at 2:10am on February 25, 2010.

Java conventions are fine

http://java.sun.com/docs/codeconv/CodeConventions.pdf

#1172
more
by DarkNSF at 2:13am on February 25, 2010.

@ KJedi:

According to your logic, spaces are fine too then. A good IDE should be able to navigate over spaces just like tabs (ex. eclipse).

Tabs are a terrible idea if you are working on a team where no one is locked in to a specific IDE.

#1529
Don't reinvent the wheel
by Sheldmandu at 5:51pm on May 28, 2010.

There's no point re-inventing the wheel. Java or Zend coding standards are perfectly fine and work well. I havn't seen pros do stuff like: if(a==b) { //Code }

usually everyone does: if(a==b) { //Code }

sometimes there is no space before curly brace or it may be on the next line, but indenting braces is stupid.

Your Comment:

You may enter comment using Markdown syntax.

Please login with your forum account.
Note: you must have at least ONE forum post with your account.