/** * {@inheritDoc} */ public function loadMetadata($class) { // Try get object annotation from class $objectAnnotation = null; $classAnnotations = Reflection::loadClassAnnotations($this->reader, $class, true); foreach ($classAnnotations as $classAnnotation) { if ($classAnnotation instanceof ObjectAnnotation) { if ($objectAnnotation) { throw new \RuntimeException(sprintf('Many @Transformer\\Object annotation in class "%s".', $class)); } $objectAnnotation = $classAnnotation; } } if (!$objectAnnotation) { throw new TransformAnnotationNotFoundException(sprintf('Not found @Object annotations in class "%s".', $class)); } // Try get properties annotations $properties = []; $classProperties = Reflection::getClassProperties($class, true); foreach ($classProperties as $classProperty) { $propertyAnnotations = $this->reader->getPropertyAnnotations($classProperty); foreach ($propertyAnnotations as $propertyAnnotation) { if ($propertyAnnotation instanceof PropertyAnnotation) { $property = new PropertyMetadata($propertyAnnotation->propertyName ?: $classProperty->getName(), $propertyAnnotation->groups, $propertyAnnotation->shouldTransform, $propertyAnnotation->expressionValue); $properties[$classProperty->getName()] = $property; } } } return new ObjectMetadata($objectAnnotation->transformedClass, $objectAnnotation->evaluateConstructor, $properties); }