mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-29 09:28:37 +08:00
Fix #20513: Fix code examples in PHPDoc
This commit is contained in:
@ -40,7 +40,7 @@ use yii\validators\Validator;
|
||||
* @property-read array $errors Errors for all attributes. This is a two-dimensional
|
||||
* array of errors for all attributes, similar to the following:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* 'username' => [
|
||||
* 'Username is required.',
|
||||
@ -116,7 +116,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
*
|
||||
* Each rule is an array with the following structure:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* ['attribute1', 'attribute2'],
|
||||
* 'validator type',
|
||||
@ -138,7 +138,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
* A validator can be either an object of a class extending [[Validator]], or a model class method
|
||||
* (called *inline validator*) that has the following signature:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* // $params refers to validation parameters given in the rule
|
||||
* function validatorName($attribute, $params)
|
||||
* ```
|
||||
@ -153,7 +153,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
*
|
||||
* Below are some examples:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* // built-in "required" validator
|
||||
* [['username', 'password'], 'required'],
|
||||
@ -188,7 +188,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
* An active attribute is one that is subject to validation in the current scenario.
|
||||
* The returned array should be in the following format:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* 'scenario1' => ['attribute11', 'attribute12', ...],
|
||||
* 'scenario2' => ['attribute21', 'attribute22', ...],
|
||||
@ -443,7 +443,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
* manipulate it by inserting or removing validators (useful in model behaviors).
|
||||
* For example,
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $model->validators[] = $newValidator;
|
||||
* ```
|
||||
*
|
||||
@ -599,7 +599,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
* @return array errors for all attributes or the specified attribute. Empty array is returned if no error.
|
||||
* Note that when returning errors for all attributes, the result is a two-dimensional array, like the following:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* 'username' => [
|
||||
* 'Username is required.',
|
||||
@ -882,7 +882,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
*
|
||||
* This method provides a convenient shortcut for:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* if (isset($_POST['FormName'])) {
|
||||
* $model->attributes = $_POST['FormName'];
|
||||
* if ($model->save()) {
|
||||
@ -893,7 +893,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
*
|
||||
* which, with `load()` can be written as:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* if ($model->load($_POST) && $model->save()) {
|
||||
* // handle success
|
||||
* }
|
||||
@ -1000,7 +1000,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
* the corresponding field definition which can be either an object property name or a PHP callable
|
||||
* returning the corresponding field value. The signature of the callable should be:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* function ($model, $field) {
|
||||
* // return field value
|
||||
* }
|
||||
@ -1014,7 +1014,7 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
|
||||
* - `fullName`: the field name is `fullName`. Its value is obtained by concatenating `first_name`
|
||||
* and `last_name`.
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* return [
|
||||
* 'email',
|
||||
* 'firstName' => 'first_name',
|
||||
|
||||
Reference in New Issue
Block a user