I dont think that now exists a file to do coding standard for Yii. I hope in Yii2.0 exists.
Now I am creating a project on github. I want to write in yii coding standard. But … I have to define all yii standard by hand!!! I dont know if you use PHP_CodeSniffer. It can control al your code and tell you if your application is written in a specific standard. Symfony2 and Zend has this feature. Yii has not?
As I remember from past discussions there is no strict coding standard for yii so it would not be possible to run a PHP_CodeSniffer on the code since not everything is defined in detail.
Well, we’re sticking to some kind of silent agreement on coding standard. At least for core so it’s possible even for Yii 1.1. The bad part is that you have to write definition file yourself. I can help answering questions about how Yii core is formatted.
Does these "coding standards" include number of spaces inside different expressions? Yii developers prefer "spaceless" (sorry, dunno how to call it right) style:
public function save($runValidation=true,$attributes=null)
{
if(!$runValidation || $this->validate($attributes))
return $this->getIsNewRecord() ? $this->insert($attributes) : $this->update($attributes);
else
return false;
}
I would write (and I think many people too):
public function save($runValidation = true, $attributes = null)
{
if (!$runValidation || $this->validate($attributes))
return $this->getIsNewRecord() ? $this->insert($attributes) : $this->update($attributes);
else
return false;
}
Yes, I think that’s possible. Since we don’t care about Gii performance much, I think there’s no problem making it feature rich and configurable. Once Yii2 code will be at GitHub you’ll have an opportunity to help us implement all these useful features.
I agree to, if it’s not necessary to fix everythings, but just some rule to make the code more readable. If in 2 or 3 year I should get an old application with no rule, I whant not must be say; “put your work at trash and restart on another framework”.
In same time if i get the same project but from Symfony2 and is writted on the same way, I can’t say same and that just because Symfony2 have set writting rules and if the developper don’t follow and if the code isn’t readable, that mean the project manager is null and I put him in trash.
example of few rule:
no braces for single line statements (braces exist in order to group multiple lines, no multiple lines no braces)
space after conditions (they are not functions like f(x) )
private menber start by _ and not static member start in minus
indentation (space or tab, not problem but indent)
presence of doc generated automaticly (@param and @return minimum)