예제 #1
0
 /**
  * @param \ReflectionClass $class
  * @param ApiObject|null $object
  * @return ObjectMetadata
  */
 private function loadObjectMetadata(\ReflectionClass $class, ApiObject $object = null)
 {
     $metadata = new ObjectMetadata($class->name);
     $properties = $class->getProperties();
     foreach ($properties as $property) {
         if ($property->getDeclaringClass()->name !== $class->name) {
             continue;
         }
         $annotation = $this->reader->getPropertyAnnotation($property, Property::class);
         if (null !== $annotation) {
             $metadata->addProperty($this->loadPropertyMetadata($annotation, $property));
         }
     }
     if (null !== $object) {
         $this->loadDiscriminatorMetadata($object, $metadata);
     }
     return $metadata;
 }
예제 #2
0
 /**
  * @test
  * @expectedException \RuntimeException
  */
 public function shouldThrowOnInvalidMetadataDuringMerge()
 {
     $objMetadata = new ObjectMetadata('MyObject');
     $resMetadata = new ResourceMetadata('MyResource');
     $objMetadata->mergeMetadata($resMetadata);
 }