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/serializer/Normalizer/ObjectToPopulateTrait.php line 24

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\Serializer\Normalizer;
  11. trait ObjectToPopulateTrait
  12. {
  13.     /**
  14.      * Extract the `object_to_populate` field from the context if it exists
  15.      * and is an instance of the provided $class.
  16.      *
  17.      * @param string      $class The class the object should be
  18.      * @param string|null $key   They in which to look for the object to populate.
  19.      *                           Keeps backwards compatibility with `AbstractNormalizer`.
  20.      */
  21.     protected function extractObjectToPopulate(string $class, array $contextstring $key null): ?object
  22.     {
  23.         $key $key ?? AbstractNormalizer::OBJECT_TO_POPULATE;
  24.         if (isset($context[$key]) && \is_object($context[$key]) && $context[$key] instanceof $class) {
  25.             return $context[$key];
  26.         }
  27.         return null;
  28.     }
  29. }