Browse Source

ReplaceArrayValue, UnsetArrayValue can be restored after `var_export()`

tags/3.0.0-alpha1
SilverFire - Dmitry Naumenko 7 years ago
parent
commit
41aa5d07ba
No known key found for this signature in database
GPG Key ID: 39DD917A92B270A
  1. 1
      framework/CHANGELOG.md
  2. 18
      framework/helpers/ReplaceArrayValue.php
  3. 12
      framework/helpers/UnsetArrayValue.php

1
framework/CHANGELOG.md

@ -22,6 +22,7 @@ Yii Framework 2 Change Log
- Enh #13702: Added support for PSR-3 'Logger' (klimov-paul)
- Enh #13706: 'Profiler' layer extracted (klimov-paul)
- Enh #15410: Added serialization abstraction layer under `yii\serialize\*` namespace (klimov-paul)
- Enh: Objects `yii\helpers\ReplaceArrayValue`, `yii\helpers\UnsetArrayValue` now support restoring after being exported with `var_export()` function (silverfire)
- Chg: Removed methods marked as deprecated in 2.0.x (samdark)
- Chg #14784: Signature of `yii\web\RequestParserInterface::parse()` changed to accept `yii\web\Request` instance as a sole argument (klimov-paul)
- Chg #10771: Consistent behavior of `run()` method in all framework widgets. All return the result now for better extensibility (pkirill99, cebe)

18
framework/helpers/ReplaceArrayValue.php

@ -61,7 +61,6 @@ class ReplaceArrayValue
*/
public $value;
/**
* Constructor.
* @param mixed $value value used as replacement.
@ -70,4 +69,21 @@ class ReplaceArrayValue
{
$this->value = $value;
}
/**
* Restores class state after using `var_export()`.
*
* @param array $state
* @return self
* @see var_export()
* @since 2.1.0
*/
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']);
}
}

12
framework/helpers/UnsetArrayValue.php

@ -49,4 +49,16 @@ namespace yii\helpers;
*/
class UnsetArrayValue
{
/**
* Restores class state after using `var_export()`.
*
* @param array $state
* @return self
* @see var_export()
* @since 2.1.0
*/
public static function __set_state($state)
{
return new self();
}
}

Loading…
Cancel
Save