{"comment":{"created_at":"2011-10-16T12:29:17Z","body":"+1 for 4 spaces","updated_at":"2011-10-16T12:29:17Z","url":"https://api.github.com/repos/propelorm/Propel2/issues/comments/2420626","id":2420626,"user":{"gravatar_id":"b82d56bfd0ffdc47d8e8aa961c8f0c7e","avatar_url":"https://secure.gravatar.com/avatar/b82d56bfd0ffdc47d8e8aa961c8f0c7e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/garak","id":179866,"login":"garak"}},"action":"created","issue":{"number":2,"created_at":"2011-10-14T07:02:21Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"# Propel2 Coding Standards #\r\n\r\nWe use the Symfony2 convention, here is a short example (from http://symfony.com/doc/current/contributing/code/standards.html):\r\n\r\n``` php\r\n<?php\r\n\r\n/**\r\n * This file is part of the Propel package.\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n *\r\n * @license    MIT License\r\n */\r\n\r\nnamespace Propel;\r\n\r\nuse A\\Baz;\r\nuse B\\Bar;\r\n\r\nclass Foo\r\n{\r\n    const SOME_CONST = 42;\r\n\r\n    private $foo;\r\n\r\n    /**\r\n     * @param string $dummy Some argument description\r\n     */\r\n    public function __construct($dummy)\r\n    {\r\n        $this->foo = $this->transform($dummy);\r\n    }\r\n\r\n    /**\r\n     * @param string $dummy Some argument description\r\n     * @return string|null Transformed input\r\n     */\r\n    private function transform($dummy)\r\n    {\r\n        if (true === $dummy) {\r\n            return;\r\n        }\r\n        if ('string' === $dummy) {\r\n            $dummy = substr($dummy, 0, 5);\r\n        }\r\n\r\n        return $dummy;\r\n    }\r\n}\r\n```\r\n\r\nStructure\r\n------------\r\n\r\n* Never use short tags (`<?`);\r\n* Don't end class files with the usual `?>` closing tag;\r\n* Indentation is done by 4 spaces, don't use tabs;\r\n* Use the linefeed character (`0x0A`) to end lines;\r\n* Add a single space after each comma delimiter;\r\n* Don't put spaces after an opening parenthesis and before a closing one;\r\n* Add a single space around operators (`==`, `&&`, ...);\r\n* Add a single space before the opening parenthesis of a control keyword (`if`, `else`, `for`, `while`, ...);\r\n* Add a blank line before return statements, unless the return is alone inside a statement-group (like an if statement);\r\n* Don't add trailing spaces at the end of lines;\r\n* Use braces to indicate control structure body regardless of the number of statements it contains;\r\n* Put braces on their own line for classes, methods, and functions declaration;\r\n* Separate the conditional statements (`if`, `else`, ...) and the opening brace with a single space and no blank line;\r\n* Declare visibility explicitly for class, methods, and properties (usage of `var` is prohibited);\r\n* Use lowercase PHP native typed constants: `false`, `true`, and `null`. The same goes for `array()`;\r\n* Use uppercase strings for constants with words separated with underscores;\r\n* Define one class per file;\r\n* Declare class properties before methods;\r\n* Organize `use` alphabetically and group them by `Runtime`, `Generator`, and others. Each group will be separated by a new blank line.\r\n\r\n\r\n## Naming Conventions ##\r\n\r\n* Use camelCase, not underscores, for variable, function and method names;\r\n* Use namespaces for all classes;\r\n* Use Propel as the first namespace level;\r\n* Suffix interfaces with Interface;\r\n* Use alphanumeric characters and underscores for file names;\r\n* Don't forget to look at the more verbose Conventions document for more subjective naming considerations.\r\n\r\n\r\n## Documentation ##\r\n\r\n* Add PHPDoc blocks for all classes, methods, and functions;\r\n* Omit the `@return` tag if the method does not return anything;\r\n* The `@package` and `@subpackage` annotations are no more used.\r\n\r\n\r\n## License ##\r\n\r\nThe following license has to be included in all files:\r\n\r\n```\r\n/**\r\n * This file is part of the Propel package.\r\n * For the full copyright and license information, please view the LICENSE\r\n * file that was distributed with this source code.\r\n *\r\n * @license    MIT License\r\n */\r\n```","comments":18,"title":"Propel2 Coding Standards","updated_at":"2011-10-16T12:29:17Z","url":"https://api.github.com/repos/propelorm/Propel2/issues/2","id":1908139,"assignee":null,"milestone":null,"closed_at":null,"user":{"gravatar_id":"c44ab7aed2bd14539fafb9175fcf2085","avatar_url":"https://secure.gravatar.com/avatar/c44ab7aed2bd14539fafb9175fcf2085?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/willdurand","id":217628,"login":"willdurand"},"html_url":"https://github.com/propelorm/Propel2/issues/2","labels":[],"state":"open"},"legacy":{"issue_id":1908139,"comment_id":2420626}}