From e3cb887cb25df8a7ede94da8f1b9aff72320df09 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 15 Apr 2012 12:01:01 +0200 Subject: [PATCH] more todos, code style --- docs/code_style.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- todo.md | 3 ++- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/docs/code_style.md b/docs/code_style.md index d8a247e..219502b 100644 --- a/docs/code_style.md +++ b/docs/code_style.md @@ -1,9 +1,37 @@ -Yii2 core code style -==================== +Yii2 code standard +================== + +This code standard is used for all the Yii2 core classes and can be applied to +your application in order to achieve consistency among your team. Also it will +help in case you want to opensource code. + + +PHP file formatting +------------------- + +### General + +- Do not use `?>` for files containing PHP code only. +- Files should be encoded in UTF-8. + +### Indentation + +All major PHP frameworks and libraries are using spaces. Common number is four: + +- Symfony 2: four spaces +- Zend Framework 1: four spaces +- Zend Framework 2: four spaces +- Pear: four spaces + + +### Maximum Line Length + +We're not strictly limiting maximum line length but sticking to 80 characters +where possible. + +### Line Termination -Proposals ---------- ### Brackets @@ -46,4 +74,20 @@ public function __construct($connection) { $this->connection = $connection; } -~~~ \ No newline at end of file +~~~ + +### Other library and framework standards + +It's good to be consistent with other frameworks and libraries whose components +will be possibly used with Yii2. That's why when there are no objective reasons +to use different style we should use one that's common among most of the popular +libraries and frameworks. + +That's not only about PHP but about JavaScript as well. Since we're using jQuery +a lot it's better to be consistent with its style as well. + +- [Symfony 2](http://symfony.com/doc/current/contributing/code/standards.html) +- [Zend Framework 1](http://framework.zend.com/manual/en/coding-standard.coding-style.html) +- [Zend Framework 2](http://framework.zend.com/wiki/display/ZFDEV2/Coding+Standards) +- [Pear](http://pear.php.net/manual/en/standards.php) +- [jQuery](http://docs.jquery.com/JQuery_Core_Style_Guidelines) \ No newline at end of file diff --git a/todo.md b/todo.md index 13ced6a..935b053 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,8 @@ * type conversion rules * CompareValidator::clientValidateAttribute(): search for "CHtml::activeId" * FileValidator, UniqueValidator, ExistValidator, DateValidator: TBD - * consider merging UniqueValidator and ExistValidator and using a NOT property. + * consider merging UniqueValidator and ExistValidator and using a NOT property: array('!exist', …) + * when getting errors from getErrors it will be good to have which validator (at least type) failed exactly. - console command support [DONE] - built-in console commands + api doc builder