protected function discoverAnnotations(array $classes) : array {
    AnnotationRegistry::reset();
    AnnotationRegistry::registerLoader('class_exists');

    $reader = $this->createReader();

    $annotations = [];
    foreach ($classes as $class) {
      $reflection = new \ReflectionClass($class);
      if (!$reflection->isSubclassOf($this->serviceInterface)) {
        continue;
      }

      /** @var \dpi\ak\Annotation\AvatarService $annotation */
      $annotation = $reader->getClassAnnotation($reflection, $this->annotationClass);
      if ($annotation) {
        $annotations[$class] = $annotation;
      }
    }

    AnnotationRegistry::reset();

    return $annotations;
  }