@param MethodDoc $method

@return string|null
434523
private function getResponseDescription(MethodDoc $method) : ?string
    {
        if (count($method->getCustomErrorList())) {
            $self = $this;
            // Better to use raw string instead of \t
            $indentString = <<<STRING

    -
STRING;

            return sprintf(
                "Could throw custom errors : %s%s",
                $indentString,
                implode(
                    $indentString,
                    array_map(
                        function (ErrorDoc $errorDoc) use ($self) {
                            return $self->formatErrorForDescription($errorDoc);
                        },
                        $method->getCustomErrorList()
                    )
                )
            );
        }

        return null;
    }
1142848
protected function getMethodOutputDocblock(MethodDescriptorProto $method)
    {
        $refType   = $method->getOutputType();
        $refEntity = $this->getEntity($refType);
        $refClass  = $this->getMethodOutputTypeHint($method);

        if ($method->getServerStreaming()) {
            return sprintf('\Iterator<%s>', $refEntity->getNamespacedName());
        }

        return $refClass;
    }
1066979
private function getMethodReturnType(\ReflectionMethod $method)
    {
        if ( ! $method->hasReturnType()) {
            return '';
        }

        return ': ' . $this->formatType($method->getReturnType(), $method);
    }
1166197
protected function getExtraMethodConfig($method)
    {
        // Lazy define methods
        if (!isset(self::$extra_methods[static::class])) {
            $this->defineMethods();
        }

        if (isset(self::$extra_methods[static::class][strtolower($method)])) {
            return self::$extra_methods[static::class][strtolower($method)];
        }
        return null;
    }
398689
public function generateMethod(Method $method): string
    {
        return $this->twig->render('method.html', [
            'method' => $method,
            'namespace' => $this->getNamespace(),
            'full_namespace' => $this->getFullNamespace()
        ]);
    }
575738
protected function getMethodExternalSchemaList(MethodDoc $method) : array
    {
        $list = [];
        // Create request params schema if provided
        $list = $this->appendAndNormalizeIfNotNull(
            $this->definitionRefResolver->getMethodDefinitionId(
                $method,
                DefinitionRefResolver::METHOD_PARAMS_DEFINITION_TYPE
            ),
            $method->getParamsDoc(),
            $list
        );

        // Create custom result schema if provided
        $list = $this->appendAndNormalizeIfNotNull(
            $this->definitionRefResolver->getMethodDefinitionId(
                $method,
                DefinitionRefResolver::METHOD_RESULT_DEFINITION_TYPE
            ),
            $method->getResultDoc(),
            $list
        );

        return $list;
    }
658552
private function getMethodSignature($method)
    {
        $validMethod = isset($this->methods[$method])
            && is_array($this->methods[$method])
            && count($this->methods[$method]) >= 2;

        if ($validMethod) {
            return $this->methods[$method];
        }

        return null;
    }
435264
public function getMethodData(ReflectionMethod $method, $prefix)
    {
        $verb = $this->getVerb($name = $method->name);
        $uri = $this->addUriWildcards($plain = $this->getPlainUri($name, $prefix));
        return compact('verb', 'plain', 'uri');
    }
129070
private static function detectReturnType(\ReflectionMethod $method): ?string
    {
        if ($method->hasReturnType()) {
            return (string) $method->getReturnType();
        }

        $docComment = $method->getDocComment();
        if (false === $docComment) {
            return null;
        }

        $returnPart = strstr($docComment, '@return');
        if (false === $returnPart) {
            return null;
        }

        $returnParts = explode(' ', trim(str_replace('@return', '', $returnPart)));
        $returnType  = ltrim(trim($returnParts[0]), '\\');
        if (empty($returnType) || strpos($returnType, '*') !== false) {
            return null;
        }

        return $returnType;
    }
479666
private function isGetMethod(\ReflectionMethod $method)
    {
        return (
            0 === strpos($method->name, 'get') &&
            3 < strlen($method->name) &&
            0 === $method->getNumberOfRequiredParameters()
        );
    }
787910
protected function dumpMethod(Method $method)
    {
        $builder = new MethodBuilder();

        $documentation = $method->getDescription()."\n\n";
        $signature = array();

        foreach ($method->getParameters() as $parameter) {
            $builder->addParameter($parameter->getName());
            $documentation .= "@param string $".$parameter->getName()." ".$parameter->getDescription()."\n\n";
            $signature[] = '$'.$parameter->getName();
        }

        $signature = implode(', ', $signature);

        if ($method->isAction()) {
            $documentation .= '@return \Selenium\Browser Fluid interface';

            $body  = '$this->driver->action("'.$method->getName().'"'. ($signature ? ', '.$signature : '') . ');'."\n";
            $body .= "\n";
            $body .= "return \$this;";

        } else {
            $returnType = $method->getReturnType();

            if ($returnType === 'boolean') {
                $getMethod = 'getBoolean';
            } elseif ($returnType === 'string') {
                $getMethod = 'getString';
            } elseif ($returnType === 'string[]') {
                $getMethod = 'getStringArray';
            } elseif ($returnType === 'number') {
                $getMethod = 'getNumber';
                $returnType = 'integer';

                if (0 === strpos($method->getReturnDescription(), 'of ')) {
                    $returnType .= ' number';
                }
            }

            $documentation .= '@return '.$returnType.' '.$method->getReturnDescription();

            $body = 'return $this->driver->'.$getMethod.'("'.$method->getName().'"'.($signature ? ', '.$signature : '').');';
        }

        $builder->setName($method->getName());
        $builder->setBody($body);
        $builder->setDocumentation($documentation);

        return $builder->buildCode();
    }
732563
public function getMethodAnnotations($method)
    {
        $reflector = new ReflectionClass($this->className);
        $doc = $reflector->getMethod($method)->getDocComment();
        $annotations = [];
        foreach ($this->filteringList as $filter) {
            preg_match_all('#@' . $filter . '(.*?)\n#s', $doc, $annotation);
            if (!empty($annotation[1])) {
                $annotations[$filter] = $annotation[1];
            }
        }
        return $annotations;
    }
130971
public MethodDoc getMatchingMethod(MethodDoc method) {

        MethodDoc[] methods = getMethods();
        for (int i = 0; i < methods.length; i++) {

            if (method.getName().equals(methods[i].getName()) &&
                method.getSignature().equals(methods[i].getSignature())) {

                return methods[i];
            }
        }
        return null;
    }
1090769
public function methodDescription( $method )
    {
        return array_key_exists( $method, $this->FunctionList ) ? ( array_key_exists( $method, $this->FunctionDescription ) ? $this->FunctionDescription[$method] : '' ) : false;
    }
565652
private function getMethodCallbacks(ReflectionMethod $method)
    {
        $annotations = $this->getMethodAnnotations($method);
        $events      = [
            Events::prePersist  => Annotation\PrePersist::class,
            Events::postPersist => Annotation\PostPersist::class,
            Events::preUpdate   => Annotation\PreUpdate::class,
            Events::postUpdate  => Annotation\PostUpdate::class,
            Events::preRemove   => Annotation\PreRemove::class,
            Events::postRemove  => Annotation\PostRemove::class,
            Events::postLoad    => Annotation\PostLoad::class,
            Events::preFlush    => Annotation\PreFlush::class,
        ];

        // Check for callbacks
        $callbacks = [];

        foreach ($events as $eventName => $annotationClassName) {
            if (isset($annotations[$annotationClassName]) || $method->getName() === $eventName) {
                $callbacks[] = $eventName;
            }
        }

        return $callbacks;
    }
672139
protected function getMethodInputDocblock(MethodDescriptorProto $method)
    {
        $refType   = $method->getInputType();
        $refEntity = $this->getEntity($refType);
        $refClass  = $this->getMethodInputTypeHint($method);

        if ($method->getClientStreaming()) {
            return sprintf('\Iterator<%s>', $refEntity->getNamespacedName());
        }

        return $refClass;
    }
1018607
protected function isGetMethod(\ReflectionMethod $method)
    {
        return 'get' === substr($method->name, 0, 3) && strlen($method->name) > 3 &&
            0 === $method->getNumberOfRequiredParameters();
    }