Browse Source

Updated code style recommendataions - PHPDoc blocks

tags/2.0.10
SilverFire - Dmitry Naumenko 8 years ago
parent
commit
f9177d20a2
  1. 10
      docs/internals/core-code-style.md

10
docs/internals/core-code-style.md

@ -147,17 +147,23 @@ class Foo
- `@param`, `@var`, `@property` and `@return` must declare types as `boolean`, `integer`, `string`, `array` or `null`. - `@param`, `@var`, `@property` and `@return` must declare types as `boolean`, `integer`, `string`, `array` or `null`.
You can use a class names as well such as `Model` or `ActiveRecord`. You can use a class names as well such as `Model` or `ActiveRecord`.
- For a typed arrays use `ClassName[]`. - For a typed arrays use `ClassName[]`.
- `@return` should explicitly describe what exactly will be returned - The first line of the PHPDoc must describe the purpose of the method.
- If method checks something (`isActive`, `hasClass`, etc) the first line should start with `Checks whether`.
- `@return` should explicitly describe what exactly will be returned.
```php ```php
/** /**
* Returns a boolean whether the IP is in subnet range * Checkes whether the IP is in subnet range
* *
* @param string $ip an IPv4 or IPv6 address * @param string $ip an IPv4 or IPv6 address
* @param integer $cidr the CIDR lendth * @param integer $cidr the CIDR lendth
* @param string $range subnet in CIDR format e.g. `10.0.0.0/8` or `2001:af::/64` * @param string $range subnet in CIDR format e.g. `10.0.0.0/8` or `2001:af::/64`
* @return boolean whether the IP is in subnet range * @return boolean whether the IP is in subnet range
*/ */
private function inRange($ip, $cidr, $range)
{
// ...
}
``` ```
### 4.5 Constructors ### 4.5 Constructors

Loading…
Cancel
Save