mirror of
https://github.com/yiisoft/yii2.git
synced 2025-10-27 20:06:19 +08:00
Fix #20513: Fix code examples in PHPDoc
This commit is contained in:
@ -29,7 +29,7 @@ class BaseArrayHelper
|
||||
* @param array $properties a mapping from object class names to the properties that need to put into the resulting arrays.
|
||||
* The properties specified for each class is an array of the following format:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* 'app\models\Post' => [
|
||||
* 'id',
|
||||
@ -46,7 +46,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* The result of `ArrayHelper::toArray($post, $properties)` could be like the following:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* 'id' => 123,
|
||||
* 'title' => 'test',
|
||||
@ -169,7 +169,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* Below are some usage examples,
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* // working with array
|
||||
* $username = \yii\helpers\ArrayHelper::getValue($_POST, 'username');
|
||||
* // working with object
|
||||
@ -244,7 +244,7 @@ class BaseArrayHelper
|
||||
* If there is no such key path yet, it will be created recursively.
|
||||
* If the key exists, it will be overwritten.
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $array = [
|
||||
* 'key' => [
|
||||
* 'in' => [
|
||||
@ -257,7 +257,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* The result of `ArrayHelper::setValue($array, 'key.in.0', ['arr' => 'val']);` will be the following:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* 'key' => [
|
||||
* 'in' => [
|
||||
@ -274,7 +274,7 @@ class BaseArrayHelper
|
||||
* `ArrayHelper::setValue($array, ['key', 'in'], ['arr' => 'val']);`
|
||||
* will be the following:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* 'key' => [
|
||||
* 'in' => [
|
||||
@ -321,7 +321,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* Usage examples,
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* // $array = ['type' => 'A', 'options' => [1, 2]];
|
||||
* // working with array
|
||||
* $type = \yii\helpers\ArrayHelper::remove($array, 'type');
|
||||
@ -356,7 +356,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* Example,
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $array = ['Bob' => 'Dylan', 'Michael' => 'Jackson', 'Mick' => 'Jagger', 'Janet' => 'Jackson'];
|
||||
* $removed = \yii\helpers\ArrayHelper::removeValue($array, 'Jackson');
|
||||
* // result:
|
||||
@ -399,7 +399,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $array = [
|
||||
* ['id' => '123', 'data' => 'abc', 'device' => 'laptop'],
|
||||
* ['id' => '345', 'data' => 'def', 'device' => 'tablet'],
|
||||
@ -410,7 +410,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* The result will be an associative array, where the key is the value of `id` attribute
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* '123' => ['id' => '123', 'data' => 'abc', 'device' => 'laptop'],
|
||||
* '345' => ['id' => '345', 'data' => 'hgi', 'device' => 'smartphone']
|
||||
@ -420,7 +420,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* An anonymous function can be used in the grouping array as well.
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $result = ArrayHelper::index($array, function ($element) {
|
||||
* return $element['id'];
|
||||
* });
|
||||
@ -428,13 +428,13 @@ class BaseArrayHelper
|
||||
*
|
||||
* Passing `id` as a third argument will group `$array` by `id`:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $result = ArrayHelper::index($array, null, 'id');
|
||||
* ```
|
||||
*
|
||||
* The result will be a multidimensional array grouped by `id`:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* '123' => [
|
||||
* ['id' => '123', 'data' => 'abc', 'device' => 'laptop']
|
||||
@ -448,7 +448,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* The anonymous function can be used in the array of grouping keys as well:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $result = ArrayHelper::index($array, 'data', [function ($element) {
|
||||
* return $element['id'];
|
||||
* }, 'device']);
|
||||
@ -457,7 +457,7 @@ class BaseArrayHelper
|
||||
* The result will be a multidimensional array grouped by `id` on the first level, by the `device` on the second one
|
||||
* and indexed by the `data` on the third level:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* [
|
||||
* '123' => [
|
||||
* 'laptop' => [
|
||||
@ -524,7 +524,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* For example,
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $array = [
|
||||
* ['id' => '123', 'data' => 'abc'],
|
||||
* ['id' => '345', 'data' => 'def'],
|
||||
@ -567,7 +567,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* For example,
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $array = [
|
||||
* ['id' => '123', 'name' => 'aaa', 'class' => 'x'],
|
||||
* ['id' => '124', 'name' => 'bbb', 'class' => 'x'],
|
||||
@ -932,7 +932,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $array = [
|
||||
* 'A' => [1, 2],
|
||||
* 'B' => [
|
||||
@ -1060,7 +1060,7 @@ class BaseArrayHelper
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```php
|
||||
* ```
|
||||
* $array = [
|
||||
* 'A' => [1, 2],
|
||||
* 'B' => [
|
||||
|
||||
Reference in New Issue
Block a user