Skip to content

Commit 38f0fc1

Browse files
committed
[PsrHttpMessageBridge] Patch return types and fix CS
1 parent 660965b commit 38f0fc1

8 files changed

+20
-58
lines changed

ArgumentValueResolver/PsrServerRequestResolver.php

-6
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ public function __construct(HttpMessageFactoryInterface $httpMessageFactory)
4141
$this->httpMessageFactory = $httpMessageFactory;
4242
}
4343

44-
/**
45-
* {@inheritdoc}
46-
*/
4744
public function supports(Request $request, ArgumentMetadata $argument): bool
4845
{
4946
if ($this instanceof BaseValueResolverInterface) {
@@ -53,9 +50,6 @@ public function supports(Request $request, ArgumentMetadata $argument): bool
5350
return self::SUPPORTED_TYPES[$argument->getType()] ?? false;
5451
}
5552

56-
/**
57-
* {@inheritdoc}
58-
*/
5953
public function resolve(Request $request, ArgumentMetadata $argument): \Traversable
6054
{
6155
if (!isset(self::SUPPORTED_TYPES[$argument->getType()])) {

EventListener/PsrResponseListener.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace Symfony\Bridge\PsrHttpMessage\EventListener;
413

514
use Psr\Http\Message\ResponseInterface;
@@ -38,9 +47,6 @@ public function onKernelView(ViewEvent $event): void
3847
$event->setResponse($this->httpFoundationFactory->createResponse($controllerResult));
3948
}
4049

41-
/**
42-
* {@inheritdoc}
43-
*/
4450
public static function getSubscribedEvents(): array
4551
{
4652
return [

Factory/HttpFoundationFactory.php

+3-17
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
use Symfony\Component\HttpFoundation\StreamedResponse;
2424

2525
/**
26-
* {@inheritdoc}
27-
*
2826
* @author Kévin Dunglas <[email protected]>
2927
*/
3028
class HttpFoundationFactory implements HttpFoundationFactoryInterface
@@ -39,12 +37,7 @@ public function __construct(int $responseBufferMaxLength = 16372)
3937
$this->responseBufferMaxLength = $responseBufferMaxLength;
4038
}
4139

42-
/**
43-
* {@inheritdoc}
44-
*
45-
* @return Request
46-
*/
47-
public function createRequest(ServerRequestInterface $psrRequest, bool $streamed = false)
40+
public function createRequest(ServerRequestInterface $psrRequest, bool $streamed = false): Request
4841
{
4942
$server = [];
5043
$uri = $psrRequest->getUri();
@@ -113,20 +106,13 @@ private function createUploadedFile(UploadedFileInterface $psrUploadedFile): Upl
113106

114107
/**
115108
* Gets a temporary file path.
116-
*
117-
* @return string
118109
*/
119-
protected function getTemporaryPath()
110+
protected function getTemporaryPath(): string
120111
{
121112
return tempnam(sys_get_temp_dir(), uniqid('symfony', true));
122113
}
123114

124-
/**
125-
* {@inheritdoc}
126-
*
127-
* @return Response
128-
*/
129-
public function createResponse(ResponseInterface $psrResponse, bool $streamed = false)
115+
public function createResponse(ResponseInterface $psrResponse, bool $streamed = false): Response
130116
{
131117
$cookies = $psrResponse->getHeader('Set-Cookie');
132118
$psrResponse = $psrResponse->withoutHeader('Set-Cookie');

Factory/PsrHttpFactory.php

+2-12
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,7 @@ public function __construct(ServerRequestFactoryInterface $serverRequestFactory,
4646
$this->responseFactory = $responseFactory;
4747
}
4848

49-
/**
50-
* {@inheritdoc}
51-
*
52-
* @return ServerRequestInterface
53-
*/
54-
public function createRequest(Request $symfonyRequest)
49+
public function createRequest(Request $symfonyRequest): ServerRequestInterface
5550
{
5651
$uri = $symfonyRequest->server->get('QUERY_STRING', '');
5752
$uri = $symfonyRequest->getSchemeAndHttpHost().$symfonyRequest->getBaseUrl().$symfonyRequest->getPathInfo().('' !== $uri ? '?'.$uri : '');
@@ -141,12 +136,7 @@ private function createUploadedFile(UploadedFile $symfonyUploadedFile): Uploaded
141136
);
142137
}
143138

144-
/**
145-
* {@inheritdoc}
146-
*
147-
* @return ResponseInterface
148-
*/
149-
public function createResponse(Response $symfonyResponse)
139+
public function createResponse(Response $symfonyResponse): ResponseInterface
150140
{
151141
$response = $this->responseFactory->createResponse($symfonyResponse->getStatusCode(), Response::$statusTexts[$symfonyResponse->getStatusCode()] ?? '');
152142

Factory/UploadedFile.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ public function __construct(UploadedFileInterface $psrUploadedFile, callable $ge
4949
$this->psrUploadedFile = $psrUploadedFile;
5050
}
5151

52-
/**
53-
* {@inheritdoc}
54-
*/
5552
public function move(string $directory, string $name = null): File
5653
{
5754
if (!$this->isValid() || $this->test) {
@@ -63,7 +60,7 @@ public function move(string $directory, string $name = null): File
6360
try {
6461
$this->psrUploadedFile->moveTo((string) $target);
6562
} catch (\RuntimeException $e) {
66-
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $this->getPathname(), $target, $e->getMessage()), 0, $e);
63+
throw new FileException(sprintf('Could not move the file "%s" to "%s" (%s).', $this->getPathname(), $target, $e->getMessage()), 0, $e);
6764
}
6865

6966
@chmod($target, 0666 & ~umask());

HttpFoundationFactoryInterface.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@ interface HttpFoundationFactoryInterface
2525
{
2626
/**
2727
* Creates a Symfony Request instance from a PSR-7 one.
28-
*
29-
* @return Request
3028
*/
31-
public function createRequest(ServerRequestInterface $psrRequest, bool $streamed = false);
29+
public function createRequest(ServerRequestInterface $psrRequest, bool $streamed = false): Request;
3230

3331
/**
3432
* Creates a Symfony Response instance from a PSR-7 one.
35-
*
36-
* @return Response
3733
*/
38-
public function createResponse(ResponseInterface $psrResponse, bool $streamed = false);
34+
public function createResponse(ResponseInterface $psrResponse, bool $streamed = false): Response;
3935
}

HttpMessageFactoryInterface.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,11 @@ interface HttpMessageFactoryInterface
2525
{
2626
/**
2727
* Creates a PSR-7 Request instance from a Symfony one.
28-
*
29-
* @return ServerRequestInterface
3028
*/
31-
public function createRequest(Request $symfonyRequest);
29+
public function createRequest(Request $symfonyRequest): ServerRequestInterface;
3230

3331
/**
3432
* Creates a PSR-7 Response instance from a Symfony one.
35-
*
36-
* @return ResponseInterface
3733
*/
38-
public function createResponse(Response $symfonyResponse);
34+
public function createResponse(Response $symfonyResponse): ResponseInterface;
3935
}

Tests/EventListener/PsrResponseListenerTest.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ public function testDoesNotConvertControllerResult()
4646
self::assertFalse($event->hasResponse());
4747
}
4848

49-
/**
50-
* @param mixed $controllerResult
51-
*/
52-
private function createEventMock($controllerResult): ViewEvent
49+
private function createEventMock(mixed $controllerResult): ViewEvent
5350
{
5451
return new ViewEvent($this->createMock(HttpKernelInterface::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $controllerResult);
5552
}

0 commit comments

Comments
 (0)