functions.php 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /* ===========================================================================
  3. * Copyright (c) 2018-2021 Zindex Software
  4. *
  5. * Licensed under the MIT License
  6. * =========================================================================== */
  7. namespace Opis\Closure;
  8. /**
  9. * Serialize
  10. *
  11. * @param mixed $data
  12. * @return string
  13. */
  14. function serialize($data)
  15. {
  16. SerializableClosure::enterContext();
  17. SerializableClosure::wrapClosures($data);
  18. $data = \serialize($data);
  19. SerializableClosure::exitContext();
  20. return $data;
  21. }
  22. /**
  23. * Unserialize
  24. *
  25. * @param string $data
  26. * @param array|null $options
  27. * @return mixed
  28. */
  29. function unserialize($data, array $options = null)
  30. {
  31. SerializableClosure::enterContext();
  32. $data = ($options === null || \PHP_MAJOR_VERSION < 7)
  33. ? \unserialize($data)
  34. : \unserialize($data, $options);
  35. SerializableClosure::unwrapClosures($data);
  36. SerializableClosure::exitContext();
  37. return $data;
  38. }