UnsetArrayValue.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\helpers;
  8. /**
  9. * Object that represents the removal of array value while performing [[ArrayHelper::merge()]].
  10. *
  11. * Usage example:
  12. *
  13. * ```php
  14. * $array1 = [
  15. * 'ids' => [
  16. * 1,
  17. * ],
  18. * 'validDomains' => [
  19. * 'example.com',
  20. * 'www.example.com',
  21. * ],
  22. * ];
  23. *
  24. * $array2 = [
  25. * 'ids' => [
  26. * 2,
  27. * ],
  28. * 'validDomains' => new \yii\helpers\UnsetArrayValue(),
  29. * ];
  30. *
  31. * $result = \yii\helpers\ArrayHelper::merge($array1, $array2);
  32. * ```
  33. *
  34. * The result will be
  35. *
  36. * ```php
  37. * [
  38. * 'ids' => [
  39. * 1,
  40. * 2,
  41. * ],
  42. * ]
  43. * ```
  44. *
  45. * @author Robert Korulczyk <robert@korulczyk.pl>
  46. * @since 2.0.10
  47. */
  48. class UnsetArrayValue
  49. {
  50. /**
  51. * Restores class state after using `var_export()`.
  52. *
  53. * @param array $state
  54. * @return UnsetArrayValue
  55. * @see var_export()
  56. * @since 2.0.16
  57. */
  58. public static function __set_state($state)
  59. {
  60. return new self();
  61. }
  62. }