Skip to content

Commit

Permalink
Фиксы
Browse files Browse the repository at this point in the history
  • Loading branch information
ProklUng committed May 10, 2023
1 parent a92da0d commit ae37364
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 50 deletions.
22 changes: 11 additions & 11 deletions src/Services/PSR/PSR7/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct(
/**
* @inheritDoc
*/
public function getProtocolVersion()
public function getProtocolVersion() : string
{
if (!empty($this->httpVersion)) {
return $this->httpVersion;
Expand All @@ -88,15 +88,15 @@ public function getProtocolVersion()
/**
* @inheritDoc
*/
public function withProtocolVersion($version)
public function withProtocolVersion($version) : MessageInterface
{
return new static($this->request, $version, $this->body, $this->attributes);
}

/**
* @inheritDoc
*/
public function getHeaders()
public function getHeaders() : array
{
$headers = $this->request->getHeaders()->toArray();
foreach ($headers as &$value) {
Expand All @@ -110,23 +110,23 @@ public function getHeaders()
/**
* @inheritDoc
*/
public function hasHeader($name)
public function hasHeader($name) : bool
{
return !empty($this->getHeader($name));
}

/**
* @inheritDoc
*/
public function getHeader($name)
public function getHeader($name) : array
{
return (array)($this->request->getHeader($name) ?? []);
}

/**
* @inheritDoc
*/
public function getHeaderLine($name)
public function getHeaderLine($name) : string
{
$value = $this->getHeader($name);
if (count($value) === 0) {
Expand All @@ -139,7 +139,7 @@ public function getHeaderLine($name)
/**
* @inheritDoc
*/
public function withHeader($name, $value)
public function withHeader($name, $value) : MessageInterface
{
$newRequest = $this->getClonedRequest();
$newRequest->getHeaders()->add($name, $value);
Expand All @@ -150,7 +150,7 @@ public function withHeader($name, $value)
/**
* @inheritDoc
*/
public function withAddedHeader($name, $value)
public function withAddedHeader($name, $value) : MessageInterface
{
if ($this->hasHeader($name)) {
return $this;
Expand All @@ -165,7 +165,7 @@ public function withAddedHeader($name, $value)
/**
* @inheritDoc
*/
public function withoutHeader($name)
public function withoutHeader($name) : MessageInterface
{
if (!$this->hasHeader($name)) {
return $this;
Expand All @@ -180,7 +180,7 @@ public function withoutHeader($name)
/**
* @inheritDoc
*/
public function getBody()
public function getBody() : StreamInterface
{
if (!$this->body) {
$this->body = Utils::streamFor('');
Expand All @@ -192,7 +192,7 @@ public function getBody()
/**
* @inheritDoc
*/
public function withBody(StreamInterface $body)
public function withBody(StreamInterface $body) : MessageInterface
{
if ($body === $this->body) {
return $this;
Expand Down
12 changes: 6 additions & 6 deletions src/Services/PSR/PSR7/PsrRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class PsrRequest extends Message implements RequestInterface
/**
* @inheritDoc
*/
public function getRequestTarget()
public function getRequestTarget() : string
{
return (string)$this->request->getRequestUri();
}

/**
* @inheritDoc
*/
public function withRequestTarget($requestTarget)
public function withRequestTarget($requestTarget) : RequestInterface
{
$newRequest = $this->getClonedRequest();
$newRequest->getServer()->set('REQUEST_URI', $requestTarget);
Expand All @@ -33,15 +33,15 @@ public function withRequestTarget($requestTarget)
/**
* @inheritDoc
*/
public function getMethod()
public function getMethod() : string
{
return $this->request->getRequestMethod();
}

/**
* @inheritDoc
*/
public function withMethod($method)
public function withMethod($method) : RequestInterface
{
$newRequest = $this->getClonedRequest();
$newRequest->getServer()->set('REQUEST_METHOD', $method);
Expand All @@ -52,15 +52,15 @@ public function withMethod($method)
/**
* @inheritDoc
*/
public function getUri()
public function getUri() : UriInterface
{
return $this->uri;
}

/**
* @inheritDoc
*/
public function withUri(UriInterface $uri, $preserveHost = false)
public function withUri(UriInterface $uri, $preserveHost = false) : RequestInterface
{
$newRequest = $this->getClonedRequest();
$newRequest->getServer()->set('REQUEST_URI', $uri);
Expand Down
29 changes: 15 additions & 14 deletions src/Services/PSR/PSR7/PsrResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Bitrix\Main\ArgumentTypeException;
use Bitrix\Main\HttpResponse;
use GuzzleHttp\Psr7\Utils;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Serializable;
Expand Down Expand Up @@ -51,47 +52,47 @@ public function __construct(HttpResponse $response, ?string $httpVersion = null,
/**
* @inheritDoc
*/
public function getProtocolVersion()
public function getProtocolVersion() : string
{
return $this->httpVersion;
}

/**
* @inheritDoc
*/
public function withProtocolVersion($version)
public function withProtocolVersion($version) : MessageInterface
{
return new static($this->response, $version, $this->body);
}

/**
* @inheritDoc
*/
public function getHeaders()
public function getHeaders() : array
{
return $this->response->getHeaders()->toArray();
}

/**
* @inheritDoc
*/
public function hasHeader($name)
public function hasHeader($name) : bool
{
return !empty($this->getHeader($name));
}

/**
* @inheritDoc
*/
public function getHeader($name)
public function getHeader($name) : array
{
return $this->response->getHeaders()->get($name, true);
}

/**
* @inheritDoc
*/
public function getHeaderLine($name)
public function getHeaderLine($name) : string
{
$value = $this->getHeader($name);
if (empty($value)) {
Expand All @@ -104,7 +105,7 @@ public function getHeaderLine($name)
/**
* @inheritDoc
*/
public function withHeader($name, $value)
public function withHeader($name, $value) : MessageInterface
{
$newResponse = clone $this->response;
$newResponse->getHeaders()->set($name, $value);
Expand All @@ -115,7 +116,7 @@ public function withHeader($name, $value)
/**
* @inheritDoc
*/
public function withAddedHeader($name, $value)
public function withAddedHeader($name, $value) : MessageInterface
{
if ($this->hasHeader($name)) {
return $this;
Expand All @@ -127,7 +128,7 @@ public function withAddedHeader($name, $value)
/**
* @inheritDoc
*/
public function withoutHeader($name)
public function withoutHeader($name) : MessageInterface
{
if (!$this->hasHeader($name)) {
return $this;
Expand All @@ -141,7 +142,7 @@ public function withoutHeader($name)
/**
* @inheritDoc
*/
public function getBody()
public function getBody() : StreamInterface
{
if (!$this->body) {
$this->body = Utils::streamFor($this->response->getContent());
Expand All @@ -154,7 +155,7 @@ public function getBody()
* @inheritDoc
* @throws ArgumentTypeException
*/
public function withBody(StreamInterface $body)
public function withBody(StreamInterface $body) : MessageInterface
{
$newResponse = clone $this->response;
$newResponse->setContent($body);
Expand All @@ -166,7 +167,7 @@ public function withBody(StreamInterface $body)
/**
* @inheritDoc
*/
public function getStatusCode()
public function getStatusCode() : int
{
preg_match('/(\d+)\s+.*/', $this->response->getStatus(), $match);
return (int)($match[1] ?? 200);
Expand All @@ -175,7 +176,7 @@ public function getStatusCode()
/**
* @inheritDoc
*/
public function withStatus($code, $reasonPhrase = '')
public function withStatus($code, $reasonPhrase = '') : ResponseInterface
{
$newResponse = clone $this->response;
$newResponse->getHeaders()->set('Status', implode(' ', [$code, $reasonPhrase]));
Expand All @@ -186,7 +187,7 @@ public function withStatus($code, $reasonPhrase = '')
/**
* @inheritDoc
*/
public function getReasonPhrase()
public function getReasonPhrase() : string
{
preg_match('/\d+\s+(.*)/', $this->response->getStatus(), $match);
return $match[1] ?? '';
Expand Down
8 changes: 4 additions & 4 deletions src/Services/PSR/PSR7/ServerPsrRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getCookieParams(): array
/**
* @inheritDoc
*/
public function withCookieParams(array $cookies)
public function withCookieParams(array $cookies) : ServerRequestInterface
{
$newRequest = $this->getClonedRequest();
$newRequest->getCookieList()->setValues($cookies);
Expand Down Expand Up @@ -60,7 +60,7 @@ public function withQueryParams(array $query): ServerPsrRequest
/**
* @inheritDoc
*/
public function getUploadedFiles()
public function getUploadedFiles() : array
{
return array_map(function (array $file) {
if (is_array($file['tmp_name'])) {
Expand Down Expand Up @@ -90,7 +90,7 @@ public function getUploadedFiles()
/**
* @inheritDoc
*/
public function withUploadedFiles(array $uploadedFiles)
public function withUploadedFiles(array $uploadedFiles) : ServerRequestInterface
{
$newRequest = $this->getClonedRequest();
$newRequest->getFileList()->setValues($uploadedFiles);
Expand All @@ -109,7 +109,7 @@ public function getParsedBody()
/**
* @inheritDoc
*/
public function withParsedBody($data)
public function withParsedBody($data) : ServerRequestInterface
{
$newRequest = $this->getClonedRequest();
$newRequest->getPostList()->setValues($data);
Expand Down
4 changes: 0 additions & 4 deletions tests/Cases/CompilerPass/ContainerAwareCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public function testProcessOrdinaryService(): void

/**
* Мок обработчика.
*
* @return mixed
*/
private function getStubService()
{
Expand All @@ -95,8 +93,6 @@ private function getStubService()

/**
* Мок обработчика.
*
* @return mixed
*/
private function getStubServiceNoContainerAware()
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Cases/CompilerPass/MakePrivateServicePublicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ public function testProcessNotInPublicableList(): void

/**
* Мок сервиса.
*
* @return mixed
*/
private function getStubService()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ public function testProcessWithoutTaggedService(): void

/**
* Мок обработчика.
*
* @return mixed
*/
private function getStubService()
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Cases/CompilerPass/ValidateServiceDefinitionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ public function dataProviderKnownServices() : array

/**
* Мок обработчика.
*
* @return mixed
*/
private function getStubService()
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Cases/ErrorScreenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public function testDie() : void

/**
* Мок CMain.
*
* @return mixed
*/
private function getMockCmain()
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Cases/PhpLoaderSettingsBitrixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PhpLoaderSettingsBitrixTest extends BitrixableTestCase
/**
* @var AppKernel
*/
private $kernel;
protected static $kernel;

/**
* @var string $pathYamlConfig Путь к конфигу.
Expand All @@ -58,8 +58,8 @@ protected function setUp(): void

$this->dummyContainer = $this->container->container();

$this->kernel = $this->dummyContainer->get('kernel');
$locator = new FileLocator($this->kernel);
$this::{$kernel} = $this->dummyContainer->get('kernel');
$locator = new FileLocator($this::{$kernel});

$this->obTestObject = new PhpLoaderSettingsBitrix(
$this->dummyContainer,
Expand Down

0 comments on commit ae37364

Please sign in to comment.