| 1 | <?php |
||
| 11 | trait ValidateTrait |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var array |
||
| 15 | */ |
||
| 16 | protected $errors = array(); |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Returns a listing of error messages. |
||
| 20 | * |
||
| 21 | * @return array |
||
| 22 | */ |
||
| 23 | 3 | public function errors() |
|
| 27 | |||
| 28 | /** |
||
| 29 | * Validates the specified data based on the validation rules. |
||
| 30 | * |
||
| 31 | * @param array $data |
||
| 32 | * @return boolean |
||
| 33 | */ |
||
| 34 | 3 | public function validate(array $data = array()) |
|
| 48 | |||
| 49 | /** |
||
| 50 | * Returns a listing of error messages. |
||
| 51 | * NOTE: To be removed in v1.0.0. Use $this->errors instead. |
||
| 52 | * |
||
| 53 | * @return array |
||
| 54 | */ |
||
| 55 | 3 | public function validation_errors() |
|
| 59 | } |
||
| 60 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: