original_string: public static function fromMethod(
          string $method,
          string $class = null,
          bool $withParents = false
      ): array
      {
          if ($class) {
  
              try {
  
                  $refMethod = new \ReflectionMethod($class, $method);
              }
              catch (\ReflectionException $e) {
  
                  throw new Exception(
                      "Method '{$class}::{$method}' not found.",
                      Exception::METHOD_NOT_FOUND
                  );
              }
          }
          else {
  
              try {
  
                  $refMethod = new \ReflectionMethod($method);
              }
              catch (\ReflectionException $e) {
  
                  throw new Exception(
                      "Method '{$method}' not found.",
                      Exception::METHOD_NOT_FOUND
                  );
              }
          }
  
          $docComment = $refMethod->getDocComment();
  
          if ($withParents) {
  
              $refClass = $refMethod->getDeclaringClass();
  
              while (1) {
  
                  if ($refClass = $refClass->getParentClass()) {
  
                      try {
  
                          $refMethod = $refClass->getMethod($method);
                      }
                      catch (\ReflectionException $e) {
  
                          break;
                      }
  
                      if (!$refMethod) {
  
                          continue;
                      }
  
                      if ($parentDoc = $refMethod->getDocComment()) {
  
                          $docComment = $docComment === false ?
                              $parentDoc :
                              "{$parentDoc}{$docComment}";
                      }
                  }
                  else {
  
                      break;
                  }
              }
          }
  
          unset($refMethod, $refClass);
  
          if ($docComment === false) {
  
              return [];
          }
  
          return Parser::parseDocComment($docComment);
      }
code: public static function fromMethod(
          string $method,
          string $class = null,
          bool $withParents = false
      ): array
      {
          if ($class) {
  
              try {
  
                  $refMethod = new \ReflectionMethod($class, $method);
              }
              catch (\ReflectionException $e) {
  
                  throw new Exception(
                      "Method '{$class}::{$method}' not found.",
                      Exception::METHOD_NOT_FOUND
                  );
              }
          }
          else {
  
              try {
  
                  $refMethod = new \ReflectionMethod($method);
              }
              catch (\ReflectionException $e) {
  
                  throw new Exception(
                      "Method '{$method}' not found.",
                      Exception::METHOD_NOT_FOUND
                  );
              }
          }
  
          $docComment = $refMethod->getDocComment();
  
          if ($withParents) {
  
              $refClass = $refMethod->getDeclaringClass();
  
              while (1) {
  
                  if ($refClass = $refClass->getParentClass()) {
  
                      try {
  
                          $refMethod = $refClass->getMethod($method);
                      }
                      catch (\ReflectionException $e) {
  
                          break;
                      }
  
                      if (!$refMethod) {
  
                          continue;
                      }
  
                      if ($parentDoc = $refMethod->getDocComment()) {
  
                          $docComment = $docComment === false ?
                              $parentDoc :
                              "{$parentDoc}{$docComment}";
                      }
                  }
                  else {
  
                      break;
                  }
              }
          }
  
          unset($refMethod, $refClass);
  
          if ($docComment === false) {
  
              return [];
          }
  
          return Parser::parseDocComment($docComment);
      }
code_tokens: public static function fromMethod ( string $ method , string $ class = null , bool $ withParents = false ) : array { if ( $ class ) { try { $ refMethod = new \ ReflectionMethod ( $ class , $ method ) ; } catch ( \ ReflectionException $ e ) { throw new Exception ( "Method '{$class}::{$method}' not found." , Exception :: METHOD_NOT_FOUND ) ; } } else { try { $ refMethod = new \ ReflectionMethod ( $ method ) ; } catch ( \ ReflectionException $ e ) { throw new Exception ( "Method '{$method}' not found." , Exception :: METHOD_NOT_FOUND ) ; } } $ docComment = $ refMethod -> getDocComment ( ) ; if ( $ withParents ) { $ refClass = $ refMethod -> getDeclaringClass ( ) ; while ( 1 ) { if ( $ refClass = $ refClass -> getParentClass ( ) ) { try { $ refMethod = $ refClass -> getMethod ( $ method ) ; } catch ( \ ReflectionException $ e ) { break ; } if ( ! $ refMethod ) { continue ; } if ( $ parentDoc = $ refMethod -> getDocComment ( ) ) { $ docComment = $ docComment === false ? $ parentDoc : "{$parentDoc}{$docComment}" ; } } else { break ; } } } unset ( $ refMethod , $ refClass ) ; if ( $ docComment === false ) { return [ ] ; } return Parser :: parseDocComment ( $ docComment ) ; }
docstring: Extract the annotations from a method.
  
  @param string $method
  @param string|null $class
  @param bool $withParents
  
  @throws \L\Annotation\Exception
  
  @return array
docstring_tokens: Extract the annotations from a method .