You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
767 B

Yii2 core code style
====================
13 years ago
Proposals
---------
### Brackets
13 years ago
It's better to be consistent with brackets not to remember where should we use
newline and where not:
~~~
class MyClass
{
public function myClassMethod()
{
13 years ago
if($x) {
// do it
13 years ago
} else {
// some code
}
}
}
~~~
13 years ago
Use brackets even for one line `if`s.
13 years ago
> I chose to use the style as shown in Component.php because I want to make the
> curly brackets consistent with array brackets regarding newlines. Similar coding
> style is also used in Symfony 2.
### Use type hinting like
~~~
public function __construct(CDbConnection $connection)
{
$this->connection = $connection;
}
~~~
instead of
~~~
public function __construct($connection)
{
$this->connection = $connection;
}
~~~