public function visitObject(ClassMetadata $metadata, $data, Type $type, Context $context, ObjectConstructorInterface $objectConstructor = null)
 {
     $this->data = [];
     /** @var PropertyMetadata $propertyMetadata */
     foreach ($context->getNonSkippedProperties($metadata) as $propertyMetadata) {
         $context->getMetadataStack()->push($propertyMetadata);
         $this->visitProperty($propertyMetadata, $data, $context);
         $context->getMetadataStack()->pop();
     }
     return $this->data;
 }
 private function isTooDeep(Context $context)
 {
     $depth = $context->getDepth();
     $metadataStack = $context->getMetadataStack();
     $nthProperty = 1;
     foreach ($metadataStack as $metadata) {
         $relativeDepth = $depth - ++$nthProperty;
         if (null !== $metadata->maxDepth && $relativeDepth > $metadata->maxDepth) {
             return true;
         }
     }
     return false;
 }
 private function getGroupsFor(Context $navigatorContext)
 {
     $groups = $this->groups;
     foreach ($navigatorContext->getMetadataStack()->getPath() as $index => $path) {
         if (!array_key_exists($path, $groups)) {
             if ($index > 0) {
                 return [self::DEFAULT_GROUP];
             }
             break;
         }
         $groups = $groups[$path];
     }
     return $groups;
 }
 public function visitArray($data, Type $type, Context $context)
 {
     $currentMetadata = $context->getMetadataStack()->getCurrent();
     $entryName = null !== $currentMetadata && $currentMetadata->xmlEntryName ? $currentMetadata->xmlEntryName : 'entry';
     $namespace = null !== $currentMetadata && $currentMetadata->xmlEntryNamespace ? $currentMetadata->xmlEntryNamespace : null;
     $result = [];
     $nodes = null !== $namespace ? $data->children($namespace)->{$entryName} : $data->{$entryName};
     switch ($type->countParams()) {
         case 0:
             throw new RuntimeException(sprintf('The array type must be specified either as "array<T>", or "array<K,V>".'));
         case 1:
             foreach ($nodes as $v) {
                 if ($this->isNullNode($v)) {
                     $result[] = $this->visitNull(null, Type::null(), $context);
                 } else {
                     $result[] = $context->accept($v, $type->getParam(0));
                 }
             }
             break;
         case 2:
             if (null === $currentMetadata) {
                 throw new RuntimeException('Maps are not supported on top-level without metadata.');
             }
             $keyType = $type->getParam(0);
             $entryType = $type->getParam(1);
             foreach ($nodes as $v) {
                 $attrs = $v->attributes();
                 if (!isset($attrs[$currentMetadata->xmlKeyAttribute])) {
                     throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $currentMetadata->xmlKeyAttribute));
                 }
                 $k = $context->accept($attrs[$currentMetadata->xmlKeyAttribute], $keyType);
                 if ($this->isNullNode($v)) {
                     $result[$k] = $this->visitNull(null, Type::null(), $context);
                 } else {
                     $result[$k] = $context->accept($v, $entryType);
                 }
             }
             break;
         default:
             throw new LogicException(sprintf('The array type does not support more than 2 parameters, but got %s.', json_encode($type['params'])));
     }
     $this->setData($result);
     return $result;
 }
 public function visitArray($data, Type $type, Context $context)
 {
     if ($this->nodeStack->count() === 1 && $this->document->documentElement === null) {
         $this->createRootNode();
     }
     /** @var PropertyMetadata $metadata */
     $nodeName = 'entry';
     if (($metadata = $context->getMetadataStack()->getCurrent()) && !empty($metadata->xmlEntryName)) {
         $nodeName = $metadata->xmlEntryName;
     }
     $attributeName = null !== $metadata ? $metadata->xmlKeyAttribute : null;
     $namespace = null !== $metadata ? $metadata->xmlEntryNamespace : null;
     /** @var \DOMNode[] $nodes */
     $nodes = [];
     $elementType = $this->getElementType($type);
     foreach ($data as $k => $v) {
         $elementName = null !== $metadata && $metadata->xmlKeyValuePairs && $this->isElementNameValid($k) ? (string) $k : $nodeName;
         $this->currentNodes = $this->createElement($namespace, $elementName);
         $context->accept($v, $elementType);
         if (null !== $attributeName) {
             $this->currentNodes->setAttribute($attributeName, (string) $k);
         }
         $nodes[] = $this->currentNodes;
     }
     return $this->currentNodes = $nodes;
 }