@param RequestDescriptor $descriptor

@return RequestInterface
187673
protected function post(RequestDescriptor $descriptor)
    {
        if (!array_key_exists('Content-Type', $descriptor->getHeaders()) && !empty($descriptor->getBodyParams())) {
            $descriptor->addHeader('Content-Type', 'application/x-www-form-urlencoded');
        }
        
        $request = new Request(
            $descriptor->getMethod(),
            $descriptor->getUrl(),
            $descriptor->getHeaders(),
            $descriptor->fetchBody()
        );

        return $request;
    }
799789
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $router         = $serviceLocator->get('Router');
        $requestContext = $serviceLocator->get('RouterRequestContext');
        $logger         = $serviceLocator->has('Logger') ? $serviceLocator->get('Logger') : null;
        $requestStack   = $serviceLocator->get('RequestStack');

        return new RouterListener($router, $requestContext, $logger, $requestStack);
    }
833108
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $parser = $serviceLocator->get('ControllerNameParser');
        $logger = $serviceLocator->has('Logger') ? $serviceLocator->get('Logger') : null;

        return new ControllerResolver($serviceLocator, $parser, $logger);
    }
802291
protected function mapReflectorToDescriptor($reflector, $descriptor)
    {
        $descriptor->setFullyQualifiedStructuralElementName($reflector->getName() . '()');
        $descriptor->setName($reflector->getShortName());
        $descriptor->setVisibility($reflector->getVisibility() ? : 'public');
        $descriptor->setFinal($reflector->isFinal());
        $descriptor->setAbstract($reflector->isAbstract());
        $descriptor->setStatic($reflector->isStatic());
        $descriptor->setLine($reflector->getLinenumber());
    }
923908
public function getResource($descriptor)
    {
        return isset($this->_pipes[$descriptor]) ? $this->_pipes[$descriptor] : null;
    }
640740
protected function renderBodyContent(Descriptor $descriptor) {
		$content = new Table();
		$content->addClass('topology-props');
		
		foreach ($descriptor->getProperties() as $property => $value) {
			$value = htmlspecialchars($value);
			
			if (is_numeric($property)) {
				$content[] = [$value, ''];
				continue;
			}
			
			$property  = htmlspecialchars($property);
			$content[] = [$property . ':', $value];
		}
		
		return $content->render();
	}
500994
protected function renderChildElement(Descriptor $descriptor, $linkTitle) {
		$element = $this->renderElement($descriptor);
		$link    = $this->getTagsLocator()->get('link');

		if (is_string($linkTitle)) {
			return $element . $link->render($linkTitle);
		}

		return $element . $link->render();
	}
4570
private function createRequestHandler(RequestHandlerInterface $requestHandler)
    {
        return function (\swoole_http_request $swooleRequest, \swoole_http_response $swooleResponse) use ($requestHandler) {
            $request = $this->messageTransformer->transform($swooleRequest);
            $response = $requestHandler->handle($request);
            $this->messageTransformer->reverseTransform($response, $swooleResponse);

            $requestHandler->finish($request, $response);
        };
    }
872890
private function _createClass(
        Descriptor $descriptor, FileDescriptor $file)
    {
        foreach ($descriptor->getEnumType() as $enum) {
            $this->_createEnum($enum, $file);
        }

        /** @var Descriptor $nested */
        foreach ($descriptor->getNestedType() as $i => $nested) {
            if (!$nested->isMapEntry()) {
                $this->_createClass($nested, $file);
            }
        }

        /**
         * namespace & use
         */
        $buffer = new CodeStringBuffer(self::TAB, self::EOL);
        $this->_createFileComment($file, $buffer);
        $buffer->newline();

        $namespaceName = $this->_createNamespaceName($descriptor);
        if ($namespaceName) {
            $buffer->append('namespace ' . $namespaceName . ';')->newline();
        }
        $buffer->append('use Google\Protobuf\Internal\GPBType;');
        $buffer->append('use Google\Protobuf\Internal\RepeatedField;');
        $buffer->append('use Google\Protobuf\Internal\GPBUtil;');
        $buffer->newline();

        /**
         * class comment
         */
        $comment = new CommentStringBuffer(self::TAB, self::EOL);
        $path = $this->_createEmbeddedMessagePath($descriptor);
        if ($path) {
            $comment->append($descriptor->getFullName() . ' message embedded in ' . $path . ' message');
        } else {
            $comment->append($descriptor->getFullName() . ' message');
        }


        $location = $file->getSourceCodeLocation($descriptor);
        if (!$location) {
            throw  new \Exception("cannot find source code location:" . $descriptor->getFullName()
                . " path: " . implode(", ", $descriptor->getSourceCodePath()));
        }
        if ($location->getLeadingComments()) {
            $comment->append($location->getLeadingComments());
        }
        if ($location->getTrailingComments()) {
            $comment->append($location->getTrailingComments());
        }
        $buffer->append($comment);

        /**
         * class name
         */
        $fullName = $this->_createClassName($descriptor);
        $shortName = $this->getClassShortName($fullName);
        $baseMessage = $this->customArguments['base_message'] ?? '';
        if (!$baseMessage) {
            $baseMessage = '\Google\Protobuf\Internal\Message';
        }
        $buffer->append("class $shortName extends $baseMessage")
            ->append('{')
            ->incrIndentation();

        $this->_createClassBody($descriptor->getField(), $buffer, $file);

        $buffer->decrIndentation()
            ->append('}');

        $this->generateClass($shortName, $namespaceName, $buffer);
    }
1254135
public function addDescriptors(array $descriptors): self
    {
        $this->descriptors = array_values(
            array_unique(
                array_merge($this->descriptors, $descriptors)
            )
        );

        return $this;
    }
343656
protected function convertToArrayDescriptor($descriptor)
    {
        $arrayDescriptor = new CollectionDescriptor('array');
        $arrayDescriptor->setTypes(array($descriptor));
        $arrayDescriptor->setKeyTypes(array('mixed'));

        return $arrayDescriptor;
    }
59169
protected function mapReflectorPropertiesOntoDescriptor(Function_ $reflector, FunctionDescriptor $descriptor): void
    {
        $packages = new Collection();
        $package = $this->extractPackageFromDocBlock($reflector->getDocBlock());
        //TODO: this looks like a potential bug. Have to investigate this!
        if ($package) {
            $tag = new TagDescriptor('package');
            $tag->setDescription($package);
            $packages->add($tag);
        }

        $descriptor->getTags()->set('package', $packages);

        $descriptor->setFullyQualifiedStructuralElementName($reflector->getFqsen());
        $descriptor->setName($reflector->getName());
        $descriptor->setLine($reflector->getLocation()->getLineNumber());
        $descriptor->setNamespace('\\' . trim(substr(
            (string) $reflector->getFqsen(),
            0,
            -strlen($reflector->getName()) - 2
        ), '\\'));
        $descriptor->setReturnType($reflector->getReturnType());
    }
463369
private function filterEachDescriptor($descriptor)
    {
        $descriptors = new Collection();
        foreach ($descriptor as $key => $item) {
            $item = $this->filterDescriptor($item);
            if (!$item) {
                continue;
            }

            $descriptors[$key] = $item;
        }

        return $descriptors;
    }
1349483
public function addStep(StepDescriptor $descriptor)
    {
        $id = $descriptor->getId();
        if (null !== $this->getStep($id)) {
            $errMsg = sprintf('Шаг с id %s уже существует', $id);
            throw new InvalidArgumentException($errMsg);
        }

        $this->getSteps()->attach($descriptor);
        return $this;
    }
1238422
private static function secondDomainFilter($requestUrlArr) {
        $domain = Domain::checkSecondDomain();
        if ($domain) {
            if (empty($requestUrlArr[0])) {
                $requestUrlArr[0] = $domain;
            } else {
                array_unshift($requestUrlArr, $domain);
            }
        }
        return $requestUrlArr;
    }
998231
public function description($descr = null)
    {
        if ($descr === null) {
            return $this->description;
        } else {
            $this->description = $descr;
            return $this;
        }
    }
1186472
public function createParameters(PageDocumentDescriptor $descriptor)
    {
        $language = $descriptor->getLanguage();
        $parameters = ['_locale' => $descriptor->getLanguage()];

        $country = $this->countryCollection->findBy(
            function (Country $country) use ($language) {
                return $country->getLanguages()->contains($language);
            }
        );
        if ($country) {
            $parameters = $parameters + ['_country' => $country->getIdentifier()];
        }

        return $parameters;
    }