MarshallerInterface.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Cache\Marshaller;
  11. /**
  12. * Serializes/unserializes PHP values.
  13. *
  14. * Implementations of this interface MUST deal with errors carefully. They MUST
  15. * also deal with forward and backward compatibility at the storage format level.
  16. *
  17. * @author Nicolas Grekas <p@tchwork.com>
  18. */
  19. interface MarshallerInterface
  20. {
  21. /**
  22. * Serializes a list of values.
  23. *
  24. * When serialization fails for a specific value, no exception should be
  25. * thrown. Instead, its key should be listed in $failed.
  26. */
  27. public function marshall(array $values, ?array &$failed): array;
  28. /**
  29. * Unserializes a single value and throws an exception if anything goes wrong.
  30. *
  31. * @return mixed
  32. *
  33. * @throws \Exception Whenever unserialization fails
  34. */
  35. public function unmarshall(string $value);
  36. }