Deprecated: Return type of Google\Model::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Model.php on line 256

Deprecated: Return type of Google\Model::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Model.php on line 261

Deprecated: Return type of Google\Model::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Model.php on line 268

Deprecated: Return type of Google\Model::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Model.php on line 278

Deprecated: Return type of Google\Collection::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 22

Deprecated: Return type of Google\Collection::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 38

Deprecated: Return type of Google\Collection::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 30

Deprecated: Return type of Google\Collection::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 43

Deprecated: Return type of Google\Collection::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 14

Deprecated: Return type of Google\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/sanralsmme/vendor/google/apiclient/src/Collection.php on line 49
Symfony Profiler

vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php line 163

Open in your IDE?
  1. <?php
  2. /*
  3.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14.  *
  15.  * This software consists of voluntary contributions made by many individuals
  16.  * and is licensed under the MIT license. For more information, see
  17.  * <http://www.doctrine-project.org>.
  18.  */
  19. namespace Doctrine\ORM\Internal\Hydration;
  20. use Doctrine\ORM\Mapping\ClassMetadata;
  21. use Doctrine\ORM\Query;
  22. use Exception;
  23. use PDO;
  24. use RuntimeException;
  25. use function array_keys;
  26. use function array_search;
  27. use function count;
  28. use function in_array;
  29. use function key;
  30. use function reset;
  31. use function sprintf;
  32. class SimpleObjectHydrator extends AbstractHydrator
  33. {
  34.     /** @var ClassMetadata */
  35.     private $class;
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     protected function prepare()
  40.     {
  41.         if (count($this->_rsm->aliasMap) !== 1) {
  42.             throw new RuntimeException('Cannot use SimpleObjectHydrator with a ResultSetMapping that contains more than one object result.');
  43.         }
  44.         if ($this->_rsm->scalarMappings) {
  45.             throw new RuntimeException('Cannot use SimpleObjectHydrator with a ResultSetMapping that contains scalar mappings.');
  46.         }
  47.         $this->class $this->getClassMetadata(reset($this->_rsm->aliasMap));
  48.     }
  49.     /**
  50.      * {@inheritdoc}
  51.      */
  52.     protected function cleanup()
  53.     {
  54.         parent::cleanup();
  55.         $this->_uow->triggerEagerLoads();
  56.         $this->_uow->hydrationComplete();
  57.     }
  58.     /**
  59.      * {@inheritdoc}
  60.      */
  61.     protected function hydrateAllData()
  62.     {
  63.         $result = [];
  64.         while ($row $this->_stmt->fetch(PDO::FETCH_ASSOC)) {
  65.             $this->hydrateRowData($row$result);
  66.         }
  67.         $this->_em->getUnitOfWork()->triggerEagerLoads();
  68.         return $result;
  69.     }
  70.     /**
  71.      * {@inheritdoc}
  72.      */
  73.     protected function hydrateRowData(array $row, array &$result)
  74.     {
  75.         $entityName       $this->class->name;
  76.         $data             = [];
  77.         $discrColumnValue null;
  78.         // We need to find the correct entity class name if we have inheritance in resultset
  79.         if ($this->class->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) {
  80.             $discrColumnName $this->_platform->getSQLResultCasing($this->class->discriminatorColumn['name']);
  81.             // Find mapped discriminator column from the result set.
  82.             $metaMappingDiscrColumnName array_search($discrColumnName$this->_rsm->metaMappings);
  83.             if ($metaMappingDiscrColumnName) {
  84.                 $discrColumnName $metaMappingDiscrColumnName;
  85.             }
  86.             if (! isset($row[$discrColumnName])) {
  87.                 throw HydrationException::missingDiscriminatorColumn($entityName$discrColumnNamekey($this->_rsm->aliasMap));
  88.             }
  89.             if ($row[$discrColumnName] === '') {
  90.                 throw HydrationException::emptyDiscriminatorValue(key($this->_rsm->aliasMap));
  91.             }
  92.             $discrMap $this->class->discriminatorMap;
  93.             if (! isset($discrMap[$row[$discrColumnName]])) {
  94.                 throw HydrationException::invalidDiscriminatorValue($row[$discrColumnName], array_keys($discrMap));
  95.             }
  96.             $entityName       $discrMap[$row[$discrColumnName]];
  97.             $discrColumnValue $row[$discrColumnName];
  98.             unset($row[$discrColumnName]);
  99.         }
  100.         foreach ($row as $column => $value) {
  101.             // An ObjectHydrator should be used instead of SimpleObjectHydrator
  102.             if (isset($this->_rsm->relationMap[$column])) {
  103.                 throw new Exception(sprintf('Unable to retrieve association information for column "%s"'$column));
  104.             }
  105.             $cacheKeyInfo $this->hydrateColumnInfo($column);
  106.             if (! $cacheKeyInfo) {
  107.                 continue;
  108.             }
  109.             // If we have inheritance in resultset, make sure the field belongs to the correct class
  110.             if (isset($cacheKeyInfo['discriminatorValues']) && ! in_array((string) $discrColumnValue$cacheKeyInfo['discriminatorValues'], true)) {
  111.                 continue;
  112.             }
  113.             // Check if value is null before conversion (because some types convert null to something else)
  114.             $valueIsNull $value === null;
  115.             // Convert field to a valid PHP value
  116.             if (isset($cacheKeyInfo['type'])) {
  117.                 $type  $cacheKeyInfo['type'];
  118.                 $value $type->convertToPHPValue($value$this->_platform);
  119.             }
  120.             $fieldName $cacheKeyInfo['fieldName'];
  121.             // Prevent overwrite in case of inherit classes using same property name (See AbstractHydrator)
  122.             if (! isset($data[$fieldName]) || ! $valueIsNull) {
  123.                 $data[$fieldName] = $value;
  124.             }
  125.         }
  126.         if (isset($this->_hints[Query::HINT_REFRESH_ENTITY])) {
  127.             $this->registerManaged($this->class$this->_hints[Query::HINT_REFRESH_ENTITY], $data);
  128.         }
  129.         $uow    $this->_em->getUnitOfWork();
  130.         $entity $uow->createEntity($entityName$data$this->_hints);
  131.         $result[] = $entity;
  132.         if (isset($this->_hints[Query::HINT_INTERNAL_ITERATION]) && $this->_hints[Query::HINT_INTERNAL_ITERATION]) {
  133.             $this->_uow->hydrationComplete();
  134.         }
  135.     }
  136. }