From 255b056582847c5db351080e0366a0bc24518b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=95=83=E5=B7=A1=E6=B4=8B=E8=89=A6=E3=8A=A3?= Date: Mon, 2 Feb 2015 18:16:58 +0800 Subject: [PATCH] core-code-style --- docs/internals-zh-CN/core-code-style.md | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/internals-zh-CN/core-code-style.md b/docs/internals-zh-CN/core-code-style.md index 6997a82..da1bc76 100644 --- a/docs/internals-zh-CN/core-code-style.md +++ b/docs/internals-zh-CN/core-code-style.md @@ -50,13 +50,13 @@ Class names MUST be declared in `StudlyCaps`. For example, `Controller`, `Model` The term "class" refers to all classes and interfaces here. -- Classes should be named using `CamelCase`. +- 类应该使用 `CamelCase` 命名。 - The brace should always be written on the line underneath the class name. - Every class must have a documentation block that conforms to the PHPDoc. - All code in a class must be indented with a single tab. -- There should be only one class in a single PHP file. -- All classes should be namespaced. -- Class name should match file name. Class namespace should match directory structure. +- 一个单一的 PHP 文件只能有一个类。 +- 所有的类应该有命名空间。 +- 类名应该匹配文件名。类的命名空间应该匹配目录结构。 ```php /** @@ -71,7 +71,7 @@ class MyClass extends \yii\Object implements MyInterface ### 4.1. 常量 Class constants MUST be declared in all upper case with underscore separators. -For example: +例如: ```php phpType) { @@ -296,7 +296,7 @@ doIt('a', [ ]); ``` -### 5.6 Anonymous functions (lambda) declarations +### 5.6 匿名函数 (lambda) 的声明 Note space between `function`/`use` tokens and open parenthesis: @@ -322,10 +322,10 @@ $mul = array_reduce($numbers, function($r, $x) use($n) { ------------- - Refer to [phpDoc](http://phpdoc.org/) for documentation syntax. -- Code without documentation is not allowed. +- 不含文档的代码是不允许的。 - All class files must contain a "file-level" docblock at the top of each file and a "class-level" docblock immediately above each class. -- There is no need to use `@return` if method does return nothing. +- 如果方法不返回任何结果没必要使用 `@return` 。 - All virtual properties in classes that extend from `yii\base\Object` are documented with an `@property` tag in the class doc block. These annotations are automatically generated from the `@return` or `@param`