Skip to content

Commit 5e8fb42

Browse files
committed
Upgrade to php-cs-fixer v3
1 parent d1dc42d commit 5e8fb42

31 files changed

+23
-233
lines changed

.php-cs-fixer.dist.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
$config = new Amp\CodeStyle\Config();
4+
$config->getFinder()
5+
->in(__DIR__ . '/examples')
6+
->in(__DIR__ . '/src')
7+
->in(__DIR__ . '/test');
8+
9+
$config->setCacheFile(__DIR__ . '/.php_cs.cache');
10+
11+
return $config;

.php_cs.dist

-10
This file was deleted.

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"amphp/phpunit-util": "v3.x-dev",
4646
"amphp/http-client": "v5.x-dev",
4747
"amphp/log": "v2.x-dev",
48-
"amphp/php-cs-fixer-config": "dev-master",
48+
"amphp/php-cs-fixer-config": "^2-dev",
4949
"league/uri-components": "^2",
5050
"monolog/monolog": "^2 || ^1.23",
5151
"phpunit/phpunit": "^9"

examples/delayed-response.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
require \dirname(__DIR__) . "/vendor/autoload.php";
4+
require dirname(__DIR__) . "/vendor/autoload.php";
55

66
use Amp\ByteStream;
77
use Amp\Http\Server\HttpServer;
@@ -43,6 +43,6 @@
4343
// Await SIGINT or SIGTERM to be received.
4444
$signal = trapSignal([\SIGINT, \SIGTERM]);
4545

46-
$logger->info(\sprintf("Received signal %d, stopping HTTP server", $signal));
46+
$logger->info(sprintf("Received signal %d, stopping HTTP server", $signal));
4747

4848
$server->stop();

examples/exception.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
require \dirname(__DIR__) . "/vendor/autoload.php";
4+
require dirname(__DIR__) . "/vendor/autoload.php";
55

66
use Amp\ByteStream;
77
use Amp\Http\Server\HttpServer;
@@ -33,6 +33,6 @@
3333
// Await SIGINT or SIGTERM to be received.
3434
$signal = trapSignal([\SIGINT, \SIGTERM]);
3535

36-
$logger->info(\sprintf("Received signal %d, stopping HTTP server", $signal));
36+
$logger->info(sprintf("Received signal %d, stopping HTTP server", $signal));
3737

3838
$server->stop();

examples/hello-world.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
require \dirname(__DIR__) . "/vendor/autoload.php";
4+
require dirname(__DIR__) . "/vendor/autoload.php";
55

66
use Amp\ByteStream;
77
use Amp\Http\Server\HttpServer;
@@ -45,6 +45,6 @@
4545
// Await SIGINT or SIGTERM to be received.
4646
$signal = trapSignal([\SIGINT, \SIGTERM]);
4747

48-
$logger->info(\sprintf("Received signal %d, stopping HTTP server", $signal));
48+
$logger->info(sprintf("Received signal %d, stopping HTTP server", $signal));
4949

5050
$server->stop();

examples/state.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
require \dirname(__DIR__) . "/vendor/autoload.php";
4+
require dirname(__DIR__) . "/vendor/autoload.php";
55

66
use Amp\ByteStream;
77
use Amp\Http\Server\HttpServer;
@@ -44,6 +44,6 @@
4444
// Await SIGINT or SIGTERM to be received.
4545
$signal = trapSignal([\SIGINT, \SIGTERM]);
4646

47-
$logger->info(\sprintf("Received signal %d, stopping HTTP server", $signal));
47+
$logger->info(sprintf("Received signal %d, stopping HTTP server", $signal));
4848

4949
$server->stop();

examples/stream.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
require \dirname(__DIR__) . "/vendor/autoload.php";
4+
require dirname(__DIR__) . "/vendor/autoload.php";
55

66
use Amp\ByteStream;
77
use Amp\ByteStream\ReadableIterableStream;
@@ -47,6 +47,6 @@
4747
// Await SIGINT or SIGTERM to be received.
4848
$signal = trapSignal([\SIGINT, \SIGTERM]);
4949

50-
$logger->info(\sprintf("Received signal %d, stopping HTTP server", $signal));
50+
$logger->info(sprintf("Received signal %d, stopping HTTP server", $signal));
5151

5252
$server->stop();

src/ClientException.php

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
*/
2020
class ClientException extends \Exception
2121
{
22-
/** @var Driver\Client */
2322
private Driver\Client $client;
2423

2524
public function __construct(Driver\Client $client, string $message, int $code = 0, \Throwable $previous = null)

src/Driver/Client.php

-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ interface Client
1515
/**
1616
* Listen for requests on the client and parse them using the given HTTP driver.
1717
*
18-
* @param HttpDriverFactory $driverFactory
19-
*
2018
* @throws \Error If the client has already been started.
2119
*/
2220
public function start(HttpDriverFactory $driverFactory): void;
@@ -45,8 +43,6 @@ public function isWaitingOnResponse(): bool;
4543

4644
/**
4745
* Integer ID of this client.
48-
*
49-
* @return int
5046
*/
5147
public function getId(): int;
5248

@@ -72,8 +68,6 @@ public function isEncrypted(): bool;
7268

7369
/**
7470
* If the client is encrypted a TlsInfo object is returned, otherwise null.
75-
*
76-
* @return TlsInfo|null
7771
*/
7872
public function getTlsInfo(): ?TlsInfo;
7973

src/Driver/ClientFactory.php

-10
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010

1111
interface ClientFactory
1212
{
13-
/**
14-
* @param Socket $socket
15-
* @param RequestHandler $requestHandler
16-
* @param ErrorHandler $errorHandler
17-
* @param PsrLogger $logger
18-
* @param Options $options
19-
* @param TimeoutCache $timeoutCache
20-
*
21-
* @return Client
22-
*/
2313
public function createClient(
2414
Socket $socket,
2515
RequestHandler $requestHandler,

src/Driver/Http1Driver.php

-7
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ private function updateTimeout(): void
117117

118118
/**
119119
* HTTP/1.x response writer.
120-
*
121-
* @param Future $lastWrite
122-
* @param Response $response
123-
* @param Request|null $request
124120
*/
125121
private function send(Future $lastWrite, Response $response, ?Request $request = null): void
126122
{
@@ -806,8 +802,6 @@ static function (int $bodySize) use (&$maxBodySize): void {
806802

807803
/**
808804
* Creates an error response from the error handler and sends that response to the client.
809-
*
810-
* @param ClientException $exception
811805
*/
812806
private function sendErrorResponse(ClientException $exception): Future
813807
{
@@ -825,7 +819,6 @@ private function sendErrorResponse(ClientException $exception): Future
825819
/**
826820
* Filters and updates response headers based on protocol and connection header from the request.
827821
*
828-
* @param Response $response
829822
* @param string $protocol Request protocol.
830823
* @param array $connection Request connection header.
831824
*

src/Driver/Http2Driver.php

-9
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ final class Http2Driver implements HttpDriver, Http2Processor
6767

6868
private int $maxFrameSize = self::DEFAULT_MAX_FRAME_SIZE;
6969

70-
/** @var bool */
7170
private bool $allowsPush;
7271

7372
/** @var int Last used local stream ID. */
@@ -118,12 +117,7 @@ public function __construct(Options $options, PsrLogger $logger)
118117
}
119118

120119
/**
121-
* @param Client $client
122-
* @param callable $onMessage
123-
* @param callable $write
124120
* @param string|null $settings HTTP2-Settings header content from upgrade request or null for direct HTTP/2.
125-
*
126-
* @return \Generator
127121
*/
128122
public function setup(Client $client, \Closure $onMessage, \Closure $write, ?string $settings = null): \Generator
129123
{
@@ -316,7 +310,6 @@ private function send(int $id, Response $response, Request $request): void
316310
/**
317311
* @param int|null $lastId ID of last processed frame. Null to use the last opened frame ID or 0 if no
318312
* streams have been opened.
319-
* @param \Throwable|null $reason
320313
*/
321314
private function shutdown(?int $lastId = null, ?\Throwable $reason = null): void
322315
{
@@ -548,8 +541,6 @@ private function releaseStream(int $id, ClientException $exception = null): void
548541

549542
/**
550543
* @param string|null $settings HTTP2-Settings header content from upgrade request or null for direct HTTP/2.
551-
*
552-
* @return \Generator
553544
*/
554545
private function parser(?string $settings = null): \Generator
555546
{

src/Driver/HttpDriver.php

-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ public function setup(Client $client, \Closure $onMessage, \Closure $write): \Ge
3333

3434
/**
3535
* Write the given response to the client using the write callback provided to `setup()`.
36-
*
37-
* @param Request $request
38-
* @param Response $response
3936
*/
4037
public function write(Request $request, Response $response): void;
4138

src/Driver/HttpDriverFactory.php

-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ interface HttpDriverFactory
1010
{
1111
/**
1212
* Selects an HTTP driver based on the given client.
13-
*
14-
* @param Client $client
15-
* @param ErrorHandler $errorHandler
16-
*
17-
* @param PsrLogger $logger
18-
*
19-
* @param Options $options
20-
*
21-
* @return HttpDriver
2213
*/
2314
public function selectDriver(
2415
Client $client,

src/Driver/RemoteClient.php

-13
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public function __construct(
6767
/**
6868
* Listen for requests on the client and parse them using the HTTP driver generated from the given factory.
6969
*
70-
* @param HttpDriverFactory $driverFactory
71-
*
7270
* @throws \Error If the client has already been started.
7371
*/
7472
public function start(HttpDriverFactory $driverFactory): void
@@ -303,10 +301,7 @@ private function write(string $data, bool $close = false): void
303301
/**
304302
* Invoked by the HTTP parser when a request is parsed.
305303
*
306-
* @param Request $request
307304
* @param string $buffer Remaining buffer in the parser.
308-
*
309-
* @return Future
310305
*/
311306
private function onMessage(Request $request, string $buffer = ''): Future
312307
{
@@ -323,9 +318,6 @@ private function onMessage(Request $request, string $buffer = ''): Future
323318

324319
/**
325320
* Respond to a parsed request.
326-
*
327-
* @param Request $request
328-
* @param string $buffer
329321
*/
330322
private function respond(Request $request, string $buffer): void
331323
{
@@ -396,8 +388,6 @@ private function makeOptionsResponse(): Response
396388

397389
/**
398390
* Used if an exception is thrown from a request handler.
399-
*
400-
* @param Request $request
401391
*/
402392
private function makeExceptionResponse(Request $request): Response
403393
{
@@ -421,9 +411,6 @@ private function makeExceptionResponse(Request $request): Response
421411
/**
422412
* Invokes the export function on Response with the socket upgraded from the HTTP server.
423413
*
424-
* @param callable $upgrade
425-
* @param Request $request
426-
* @param Response $response
427414
* @param string $buffer Remaining buffer read from the socket.
428415
*/
429416
private function export(callable $upgrade, Request $request, Response $response, string $buffer): void

src/Driver/TimeoutCache.php

-5
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ public function update(int $id, int $expiresAt): void
7070
}
7171
}
7272

73-
/**
74-
* @param int $id
75-
*/
7673
public function clear(int $id): void
7774
{
7875
if (!isset($this->pointers[$id])) {
@@ -101,8 +98,6 @@ public function extract(int $now): ?int
10198
/**
10299
* @param int $node Rebuild the data array from the given node downward.
103100
* @param bool $remove Remove the given node from the data array if true.
104-
*
105-
* @return int
106101
*/
107102
private function rebuild(int $node, bool $remove): int
108103
{

src/ErrorHandler.php

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ interface ErrorHandler
88
* @param int $statusCode Error status code, 4xx or 5xx.
99
* @param string|null $reason Reason message. Will use the status code's default reason if not provided.
1010
* @param Request|null $request Null if the error occurred before parsing the request completed.
11-
*
12-
* @return Response
1311
*/
1412
public function handleError(int $statusCode, string $reason = null, Request $request = null): Response;
1513
}

0 commit comments

Comments
 (0)