Class yii\helpers\ReplaceArrayValue
Inheritance | yii\helpers\ReplaceArrayValue |
---|---|
Available since version | 2.0.10 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/helpers/ReplaceArrayValue.php |
Object that represents the replacement of array value while performing yii\helpers\ArrayHelper::merge().
Usage example:
$array1 = [
'ids' => [
1,
],
'validDomains' => [
'example.com',
'www.example.com',
],
];
$array2 = [
'ids' => [
2,
],
'validDomains' => new \yii\helpers\ReplaceArrayValue([
'yiiframework.com',
'www.yiiframework.com',
]),
];
$result = \yii\helpers\ArrayHelper::merge($array1, $array2);
The result will be
[
'ids' => [
1,
2,
],
'validDomains' => [
'yiiframework.com',
'www.yiiframework.com',
],
]
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$value | mixed | Value used as replacement. | yii\helpers\ReplaceArrayValue |
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | Constructor. | yii\helpers\ReplaceArrayValue |
__set_state() | Restores class state after using var_export() . |
yii\helpers\ReplaceArrayValue |
Property Details
Method Details
Constructor.
public void __construct ( $value ) | ||
$value | mixed |
Value used as replacement. |
public function __construct($value)
{
$this->value = $value;
}
Restores class state after using var_export()
.
See also https://www.php.net/manual/en/function.var-export.php.
public static yii\helpers\ReplaceArrayValue __set_state ( $state ) | ||
$state | array | |
throws | yii\base\InvalidConfigException |
when $state property does not contain |
---|
public static function __set_state($state)
{
if (!isset($state['value'])) {
throw new InvalidConfigException('Failed to instantiate class "ReplaceArrayValue". Required parameter "value" is missing');
}
return new self($state['value']);
}
Signup or Login in order to comment.