Deprecated: Constant E_STRICT is deprecated in /home/normanv/www/annuairepro/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/normanv/www/annuairepro/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

vendor/symfony/messenger/Transport/Serialization/Normalizer/FlattenExceptionNormalizer.php line 65

Open in your IDE?
  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\Messenger\Transport\Serialization\Normalizer;
  11. use Symfony\Component\ErrorHandler\Exception\FlattenException;
  12. use Symfony\Component\Messenger\Transport\Serialization\Serializer;
  13. use Symfony\Component\Serializer\Exception\InvalidArgumentException;
  14. use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
  15. use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
  16. use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
  17. /**
  18.  * This normalizer is only used in Debug/Dev/Messenger contexts.
  19.  *
  20.  * @author Pascal Luna <skalpa@zetareticuli.org>
  21.  */
  22. final class FlattenExceptionNormalizer implements DenormalizerInterfaceContextAwareNormalizerInterface
  23. {
  24.     use NormalizerAwareTrait;
  25.     /**
  26.      * {@inheritdoc}
  27.      *
  28.      * @throws InvalidArgumentException
  29.      */
  30.     public function normalize($objectstring $format null, array $context = []): array
  31.     {
  32.         $normalized = [
  33.             'message' => $object->getMessage(),
  34.             'code' => $object->getCode(),
  35.             'headers' => $object->getHeaders(),
  36.             'class' => $object->getClass(),
  37.             'file' => $object->getFile(),
  38.             'line' => $object->getLine(),
  39.             'previous' => null === $object->getPrevious() ? null $this->normalize($object->getPrevious(), $format$context),
  40.             'status' => $object->getStatusCode(),
  41.             'status_text' => $object->getStatusText(),
  42.             'trace' => $object->getTrace(),
  43.             'trace_as_string' => $object->getTraceAsString(),
  44.         ];
  45.         return $normalized;
  46.     }
  47.     /**
  48.      * {@inheritdoc}
  49.      */
  50.     public function supportsNormalization($datastring $format null, array $context = []): bool
  51.     {
  52.         return $data instanceof FlattenException && ($context[Serializer::MESSENGER_SERIALIZATION_CONTEXT] ?? false);
  53.     }
  54.     /**
  55.      * {@inheritdoc}
  56.      */
  57.     public function denormalize($datastring $typestring $format null, array $context = []): FlattenException
  58.     {
  59.         $object = new FlattenException();
  60.         $object->setMessage($data['message']);
  61.         $object->setCode($data['code']);
  62.         $object->setStatusCode($data['status'] ?? 500);
  63.         $object->setClass($data['class']);
  64.         $object->setFile($data['file']);
  65.         $object->setLine($data['line']);
  66.         $object->setStatusText($data['status_text']);
  67.         $object->setHeaders((array) $data['headers']);
  68.         if (isset($data['previous'])) {
  69.             $object->setPrevious($this->denormalize($data['previous'], $type$format$context));
  70.         }
  71.         $property = new \ReflectionProperty(FlattenException::class, 'trace');
  72.         $property->setAccessible(true);
  73.         $property->setValue($object, (array) $data['trace']);
  74.         $property = new \ReflectionProperty(FlattenException::class, 'traceAsString');
  75.         $property->setAccessible(true);
  76.         $property->setValue($object$data['trace_as_string']);
  77.         return $object;
  78.     }
  79.     /**
  80.      * {@inheritdoc}
  81.      */
  82.     public function supportsDenormalization($datastring $typestring $format null, array $context = []): bool
  83.     {
  84.         return FlattenException::class === $type && ($context[Serializer::MESSENGER_SERIALIZATION_CONTEXT] ?? false);
  85.     }
  86. }