public function loadMetadataForClass(ReflectionClass $reflection)
 {
     $metadata = new ClassMetadata($reflection);
     foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED) as $method) {
         // check if the method was defined on this class
         if ($method->getDeclaringClass()->getName() !== $reflection->getName()) {
             continue;
         }
         $annotations = $this->reader->getMethodAnnotations($method);
         if (count($annotations) > 0) {
             $methodMetadata = $this->converter->convertMethodAnnotations($method, $annotations);
             $metadata->addMethod($method->getName(), $methodMetadata);
         }
     }
     return $metadata;
 }
 private function collectServiceMetadata()
 {
     $this->metadata = new ServiceMetadata();
     $classMetadata = null;
     foreach ($this->hierarchy as $reflectionClass) {
         if (null === $classMetadata) {
             $classMetadata = new ClassMetadata($reflectionClass);
         }
         if (null !== ($aMetadata = $this->driver->loadMetadataForClass($reflectionClass))) {
             if ($reflectionClass->isInterface()) {
                 $classMetadata->merge($aMetadata);
             } else {
                 $this->metadata->addMetadata($classMetadata);
                 $classMetadata = $aMetadata;
             }
         }
     }
     $this->metadata->addMetadata($classMetadata);
 }