Coding Standard tools Help to develop yii standard application
#1
Posted 08 February 2012 - 08:51 PM
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?
#2
Posted 09 February 2012 - 04:22 AM
#3
Posted 09 February 2012 - 08:59 AM
#5
Posted 09 February 2012 - 03:21 PM
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;
}
#6
Posted 09 February 2012 - 03:25 PM
public function save($runValidation = true, $attributes = null)
{
if (!$runValidation || $this->validate($attributes)) {
return $this->getIsNewRecord() ? $this->insert($attributes) : $this->update($attributes);
} else {
return false;
}
}
#7
Posted 09 February 2012 - 06:31 PM
#8
Posted 09 February 2012 - 06:40 PM
No, the team is not willing to write a coding standard. That was the very clear message we got back then.
However, I prefer spaces between operators, like Andy_s, and braces - even for a line line code block - as Mbi.
I also prefer 4 spaces instead of a tab (spaces instead of tabs).
#9
Posted 09 February 2012 - 06:42 PM
Could the Gii tool have a configuration option for tabs versus spaces, please?
Basically, what to insert: a tab (\t) or 2-4 spaces.
My editor of choice would be grateful.
That goes for the migration tool as well.
A configurable option would be great.
#10
Posted 10 February 2012 - 04:11 AM
#11
Posted 10 February 2012 - 04:24 AM
sensorario, on 09 February 2012 - 06:31 PM, said:
I agree.
Still I prefer
- 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) )
#12
Posted 10 February 2012 - 04:50 AM
#13
Posted 10 February 2012 - 03:41 PM
samdark, on 10 February 2012 - 04:50 AM, said:
http://www.thefreedictionary.com/joke
#14
Posted 10 February 2012 - 04:04 PM
mdomba, on 10 February 2012 - 04:11 AM, said:
That's what I have to do now: each time I use the migration tool or the gii generator I have to convert it.
A configurable option would be far better.
Could default to a tab character or 4 spaces, as long as I can configure it.
#15
Posted 11 February 2012 - 06:19 AM
#16
Posted 11 February 2012 - 06:43 AM
#18
Posted 11 February 2012 - 10:42 AM
I was planning to have a repository of user-submitted templates for giix. Had no time to work on it yet.
Combining this (or the new approach for this in Gii) with Yii 2.0 packages can be very useful.
Check my extension
giix: a code generator for Yii.

The complete beginner's study guide for the Yii Framework
#19
Posted 01 March 2012 - 12:59 PM
ekerazha, on 10 February 2012 - 04:24 AM, said:
Still I prefer
- 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) )
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)
and that all (and i think that the minimum)
#20
Posted 01 March 2012 - 01:06 PM
As long as the def file is approved (and maintained by) the Yii team, it would simply remove any further need to discuss braces, spaces and whatever.
Just run the tool, and that's it.

Help
This topic is locked
















