Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (35 sloc) 1.25 KB

010 - Code Style

Code formatting used in Yii 3 packages is based on PSR-12 with additional rules added on top of it.

Property placement

Properties are placement at the beginning of the class after constants but before methods.


Inline comments are to be avoided except when code could not be understood without them. A good example is a workaround for a bug in a certain PHP version.

Method comment is necessary except it adds nothing to what method name and signature already has.

Class comment should describe the purpose of the class.

No alignment

Property, variable and constant value assignments should not be aligned. Same applies to phpdoc tags. The reason is that aligned statements often cause larger diff and even conflicts.

class X
    const A = 'test';
    const BBB = 'test';
    private $property = 42;
    private $test = 123;
     * @param int $number just a number
     * @param array $options well... options!
    public function doit(int $number, array $options)
        $test = 123;
        $a = 123;

Additional conventions

You can’t perform that action at this time.