Finnassa käytetään PEAR-koodausstandardia.
Koodin automaattinen tarkistus
phpcs --standard=PEAR <filename.php>
Tuloste on jotain tämän tyylistä:
FILE: .../admin_panel/AdminInterface/application/controllers/ErrorController.php -------------------------------------------------------------------------------- FOUND 2 ERROR(S) AND 2 WARNING(S) AFFECTING 4 LINE(S) -------------------------------------------------------------------------------- 31 | ERROR | Spaces must be used to indent lines; tabs are not allowed 41 | WARNING | Line exceeds 80 characters; contains 98 characters 58 | WARNING | Line exceeds 80 characters; contains 102 characters 70 | ERROR | Spaces must be used to indent lines; tabs are not allowed -------------------------------------------------------------------------------- |
Tiedostojen alkuun (esimerkki):
/** * Implements File Controller * * This controller handles file explorer requests. * * PHP version 5 * * @category Controller * @package Application_Controller * @author Finna <[email protected]> * @copyright 2012 National Library of Finland * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://github.com/KDK-Alli/AdminInterface */ /** * FeedbackController * * @category AdminInterface * @package AdminInterface_Controllers * @author Finna <[email protected]> * @copyright 2012 National Library of Finland * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://github.com/KDK-Alli/AdminInterface */ |
Funktioiden kommentointi (esimerkki):
/** * Checks if user has permission to perform action * * @param string $actionType Type of the action * @param array $post Request parameters * @param boolean $skipRedirect If failed request should be * redirected to the main page * * @return boolean */ |
Luokkien jäsenmuuttujien kommentointi (esimerkki):
/** * * User model * @var Application_Model_User */ $this->_model = new Application_Model_User(); |