Skip to content

Commit 40c69b1

Browse files
committed
PHP CS Fixer fixes
1 parent 363142b commit 40c69b1

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

src/Client.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function sendRequest(RequestInterface $request): ResponseInterface
108108
*/
109109
protected function initCurl(UriInterface $uri): ResponseData
110110
{
111-
$this->curl = curl_init((string)$uri);
111+
$this->curl = curl_init((string) $uri);
112112
$dataStream = fopen('php://temp', 'wb+');
113113
if (false === $dataStream) {
114114
throw new ClientException('Unable to open handle for response');
@@ -158,7 +158,8 @@ static function (CurlHandle $curl, string $header) use ($responseData): int {
158158
CURLOPT_WRITEFUNCTION,
159159
CURLOPT_HEADERFUNCTION,
160160
],
161-
true)
161+
true
162+
)
162163
) {
163164
continue;
164165
}
@@ -187,16 +188,16 @@ protected function curlRequest(RequestInterface $request, ResponseData $response
187188
$headers = [];
188189
foreach ($request->getHeaders() as $headerName => $headerValues) {
189190
$headers[] = sprintf(
190-
"%s: %s",
191-
preg_replace("/[^A-Za-z0-9-_.~]/", '', $headerName),
191+
'%s: %s',
192+
preg_replace('/[^A-Za-z0-9-_.~]/', '', $headerName),
192193
preg_replace('/[^\x20-\x7E]/', '', implode(', ', $headerValues))
193194
);
194195
}
195196
curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
196197
}
197-
/** @phpstan-ignore argument.type */ // Method is a non-empty string
198+
/* @phpstan-ignore argument.type */ // Method is a non-empty string
198199
curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $request->getMethod());
199-
$requestBody = (string)$request->getBody();
200+
$requestBody = (string) $request->getBody();
200201
if ('' !== $requestBody) {
201202
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $requestBody);
202203
}

src/Exception/InternalServerErrorException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class InternalServerErrorException extends Exception implements HttpStatus
1919
public function __construct(
2020
private readonly int $statusCode,
2121
private readonly ResponseInterface $response,
22-
string $message = "",
22+
string $message = '',
2323
int $code = 0,
2424
?Exception $previous = null
2525
) {

src/Handler/ThrowOnErrorTransferHandler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class ThrowOnErrorTransferHandler implements TransferHandlerInterface
2222
*
2323
* @throws T
2424
*/
25-
2625
public function handleException(Throwable $e): void
2726
{
2827
throw $e;

src/ResponseData.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace SharkMachine\Psr18Shark;

test/Handler/RedirectTransferHandlerTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testRedirect(int $statusCode): void
5959

6060
$response = $handler->handleResponse($client, $request, $firstResponse);
6161
self::assertSame(200, $response->getStatusCode());
62-
self::assertSame('Should be in the response', (string)$response->getBody());
62+
self::assertSame('Should be in the response', (string) $response->getBody());
6363
}
6464

6565
public function testRedirectLimit(): void
@@ -81,15 +81,15 @@ public function testRedirectLimit(): void
8181
$factory = new Psr17Factory();
8282
/** @var MockInterface&ClientInterface $client */
8383
$client = Mockery::mock(
84-
Client::class . '[initCurl,curlRequest,getResponse]',
85-
[
86-
$factory,
87-
$factory,
88-
null,
89-
null,
90-
new TransferHandlerCollection([$handler])
91-
]
92-
)
84+
Client::class . '[initCurl,curlRequest,getResponse]',
85+
[
86+
$factory,
87+
$factory,
88+
null,
89+
null,
90+
new TransferHandlerCollection([$handler]),
91+
]
92+
)
9393
->shouldAllowMockingProtectedMethods();
9494
$client->expects('getResponse')->andReturn($secondResponse);
9595
$client->expects('initCurl')->once();
@@ -129,7 +129,7 @@ public function testNoRedirect(int $statusCode): void
129129

130130
$response = $handler->handleResponse($client, $request, $expectedResponse);
131131
self::assertSame($statusCode, $response->getStatusCode());
132-
self::assertSame('Should be in the response', (string)$response->getBody());
132+
self::assertSame('Should be in the response', (string) $response->getBody());
133133
self::assertSame($expectedResponse, $response);
134134
}
135135
}

test/Handler/RequestMutationHandlerCollectionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ final class RequestMutationHandlerCollectionTest extends TestCase
1616
{
1717
public function testHandlers(): void
1818
{
19-
$handlerOne = new class implements RequestMutationHandlerInterface {
19+
$handlerOne = new class () implements RequestMutationHandlerInterface {
2020
public function handleRequest(RequestInterface $request): RequestInterface
2121
{
22-
return (new Psr17Factory())->createRequest('GET', 'https://example.com')->withHeader('X-Foo', 'bar');
22+
return new Psr17Factory()->createRequest('GET', 'https://example.com')->withHeader('X-Foo', 'bar');
2323
}
2424
};
25-
$handlerTwo = new class implements RequestMutationHandlerInterface {
25+
$handlerTwo = new class () implements RequestMutationHandlerInterface {
2626
public function handleRequest(RequestInterface $request): RequestInterface
2727
{
28-
return (new Psr17Factory())->createRequest('GET', 'https://example.com')->withHeader('X-Foo', 'bar');
28+
return new Psr17Factory()->createRequest('GET', 'https://example.com')->withHeader('X-Foo', 'bar');
2929
}
3030
};
3131

3232
$handlerCollection = new RequestMutationHandlerCollection([$handlerOne, $handlerTwo]);
3333
foreach ($handlerCollection as $index => $handler) {
34-
if ($index === 0) {
34+
if (0 === $index) {
3535
self::assertSame($handlerOne, $handler);
3636
} else {
3737
self::assertSame($handlerTwo, $handler);
3838
}
39-
$request = $handler->handleRequest((new Psr17Factory())->createRequest('GET', 'https://example.com'));
39+
$request = $handler->handleRequest(new Psr17Factory()->createRequest('GET', 'https://example.com'));
4040
self::assertSame('bar', $request->getHeaderLine('X-Foo'));
4141
}
4242
}

0 commit comments

Comments
 (0)