PHP CODING STANDARDS (not official - draft)
...
Total 20 comments:
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.
You know I wrote out this long comment detailing the craziness of this document. But I decided against posting it.
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.
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 :)
But i am sure who read it understands what's written even if the example has some bugs and glitches
Open any framework source file and you'll see coding standarts.
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?
Yii coding standards should somewhat resemble java conventions..
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
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.
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.
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.
Its a good ideia however I think it should be placed in Yii online docs.
Another point: Its not so readable
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?
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
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.
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
Java conventions are fine
http://java.sun.com/docs/codeconv/CodeConventions.pdf
@ 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.
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.

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