Styl zápisu kódu

Formátování kódu

Způsob odsazení, zarovnání a závorkování kódu se shoduje se stylem BSD KNF style.

Odsazení a zarovnání kódu

V ukázkach je znak mezera vyjádřen tečkou, znak tabelátor dvěmi většítky ».

Závorkování

Pojmenování

Dokumentace

Všechny třídy, metody, funkce atd. budou dokumentovány pomocí PHPDoc.

Uvozovky

Shrnutí

<?php
/**
 * ActiveRecord_User
 * @author Daniel Milde <daniel@milde.cz>
 * @copyright Daniel Milde <daniel@milde.cz>
 * @license http://www.opensource.org/licenses/gpl-license.php
 * @package Core
 */

/**
 * ActiveRecord_User
 * @author Daniel Milde <daniel@milde.cz>
 * @package Core
 */
class ActiveRecord_User extends Core_ActiveRecord
{
    /**
     * Array of fields in table
     * @var string[] $fields
     */
    public $fields = array('id_user'  => array('visibility' => 0, 'type' => 'id'),
                           'name'     => array('visibility' => 1, 'type' => 'text'),
                           'password' => array('visibility' => 1, 'type' => 'password'));

    /**
     * Constructor
     * @param int $id_user ID of the user
     * @return Core_ActiveRecord_User
     */
    public function __construct($id_user = FALSE)
    {
        parent::__construct('user', $id_user);
    }

    /**
     * Saves the object to DB
     * @return Core_ActiveRecord_User
     */
    public function save()
    {
        if ($this->id_user != 0) {
            $this->update();
        } else {
            $this->insert();
        }
        return $this;
    }
    ...
}