diff --git a/composer.json b/composer.json index 92b0e430..d6dc812b 100644 --- a/composer.json +++ b/composer.json @@ -38,8 +38,8 @@ "amphp/pipeline": "^1", "amphp/socket": "^2.1", "amphp/sync": "^2.2", - "league/uri": "^6.8 | ^7.1", - "league/uri-interfaces": "^2.3 | ^7.1", + "league/uri": "^7.1", + "league/uri-interfaces": "^7.1", "psr/http-message": "^1 | ^2", "psr/log": "^1 | ^2 | ^3", "revolt/event-loop": "^1" @@ -49,7 +49,7 @@ "amphp/http-client": "^5", "amphp/log": "^2", "amphp/php-cs-fixer-config": "^2", - "league/uri-components": "^2.4.2 | ^7.1", + "league/uri-components": "^7.1", "monolog/monolog": "^3", "phpunit/phpunit": "^9", "psalm/phar": "~5.23" diff --git a/src/Driver/Http1Driver.php b/src/Driver/Http1Driver.php index d7624ac5..c81cdc24 100644 --- a/src/Driver/Http1Driver.php +++ b/src/Driver/Http1Driver.php @@ -274,8 +274,7 @@ public function handleClient( $target = \substr($target, 0, $position); } - /** @psalm-suppress DeprecatedMethod */ - $uri = Uri\Http::createFromComponents([ + $uri = Uri\Http::fromComponents([ "scheme" => $scheme, "host" => $host, "port" => $port, @@ -283,15 +282,13 @@ public function handleClient( "query" => $query, ]); } elseif ($target === "*") { // asterisk-form - /** @psalm-suppress DeprecatedMethod */ - $uri = Uri\Http::createFromComponents([ + $uri = Uri\Http::fromComponents([ "scheme" => $scheme, "host" => $host, "port" => $port, ]); } elseif (\preg_match("#^https?://#i", $target)) { // absolute-form - /** @psalm-suppress DeprecatedMethod */ - $uri = Uri\Http::createFromString($target); + $uri = Uri\Http::new($target); if ($uri->getHost() !== $host || $uri->getPort() !== $port) { throw new ClientException( @@ -325,8 +322,7 @@ public function handleClient( ); } - /** @psalm-suppress DeprecatedMethod */ - $uri = Uri\Http::createFromComponents([ + $uri = Uri\Http::fromComponents([ "host" => $matches[1], "port" => (int) $matches[2], ]); diff --git a/src/Driver/Http2Driver.php b/src/Driver/Http2Driver.php index 57c4ca31..704d1c68 100644 --- a/src/Driver/Http2Driver.php +++ b/src/Driver/Http2Driver.php @@ -996,15 +996,13 @@ public function handleHeaders(int $streamId, array $pseudo, array $headers, bool try { if ($target === "*") { - /** @psalm-suppress DeprecatedMethod */ - $uri = Uri\Http::createFromComponents([ + $uri = Uri\Http::fromComponents([ "scheme" => $scheme, "host" => $host, "port" => $port, ]); } else { - /** @psalm-suppress DeprecatedMethod */ - $uri = Uri\Http::createFromComponents([ + $uri = Uri\Http::fromComponents([ "scheme" => $scheme, "host" => $host, "port" => $port, diff --git a/src/Response.php b/src/Response.php index d50e8d92..77f6ef55 100644 --- a/src/Response.php +++ b/src/Response.php @@ -313,8 +313,7 @@ public function getPushes(): array public function push(string $url, array $headers = []): void { try { - /** @psalm-suppress DeprecatedMethod */ - $uri = Uri\Http::createFromString($url); + $uri = Uri\Http::new($url); } catch (\Exception $exception) { throw new \Error("Invalid push URI: " . $exception->getMessage(), 0, $exception); } diff --git a/test/Driver/Http1DriverTest.php b/test/Driver/Http1DriverTest.php index 27642492..34108a06 100644 --- a/test/Driver/Http1DriverTest.php +++ b/test/Driver/Http1DriverTest.php @@ -756,7 +756,7 @@ public function testPipelinedRequests(): void self::assertSame($results[1], $request->getBody()->buffer()); - $request = new Request($this->createClientMock(), "GET", Uri\Http::createFromString("/")); + $request = new Request($this->createClientMock(), "GET", Uri\Http::new("/")); delay(0.01); // Allow parser generator to continue. @@ -764,7 +764,7 @@ public function testPipelinedRequests(): void self::assertSame($results[0], $request->getBody()->buffer()); - $request = new Request($this->createClientMock(), "POST", Uri\Http::createFromString("/")); + $request = new Request($this->createClientMock(), "POST", Uri\Http::new("/")); self::assertSame(3, $responses); } diff --git a/test/Driver/SocketClientTest.php b/test/Driver/SocketClientTest.php index a3711032..f793fa3a 100644 --- a/test/Driver/SocketClientTest.php +++ b/test/Driver/SocketClientTest.php @@ -51,7 +51,7 @@ public function testTrivialHttpRequest(): void [$address, $server] = $this->startServer(function (Request $req) { $this->assertEquals("GET", $req->getMethod()); $this->assertEquals("/uri", $req->getUri()->getPath()); - $query = Query::createFromUri($req->getUri()); + $query = Query::fromUri($req->getUri()); $this->assertEquals( [["foo", "bar"], ["baz", "1"], ["baz", "2"]], \iterator_to_array($query->getIterator()) diff --git a/test/Middleware/ExceptionHandlerMiddlewareTest.php b/test/Middleware/ExceptionHandlerMiddlewareTest.php index f9ca4f3a..625df8d4 100644 --- a/test/Middleware/ExceptionHandlerMiddlewareTest.php +++ b/test/Middleware/ExceptionHandlerMiddlewareTest.php @@ -18,7 +18,7 @@ class ExceptionHandlerMiddlewareTest extends AsyncTestCase { private function setupAndInvokeMiddleware(ExceptionHandler $exceptionHandler, \Throwable $exception): Response { - $request = new Request($this->createMock(Client::class), 'GET', Http::createFromString('/')); + $request = new Request($this->createMock(Client::class), 'GET', Http::new('/')); $requestHandler = $this->createMock(RequestHandler::class); $requestHandler->expects(self::once()) diff --git a/test/Middleware/StackTest.php b/test/Middleware/StackTest.php index eb8110b3..c11cc99c 100644 --- a/test/Middleware/StackTest.php +++ b/test/Middleware/StackTest.php @@ -17,7 +17,7 @@ class StackTest extends AsyncTestCase { public function testStackAppliesMiddlewaresInCorrectOrder(): void { - $request = new Request($this->createMock(Client::class), "GET", Uri\Http::createFromString("/foobar")); + $request = new Request($this->createMock(Client::class), "GET", Uri\Http::new("/foobar")); $stack = stackMiddleware(new ClosureRequestHandler(function (Request $request) { $response = new Response(HttpStatus::OK, [], "OK"); diff --git a/test/RequestTest.php b/test/RequestTest.php index 3097838a..2a9f2499 100644 --- a/test/RequestTest.php +++ b/test/RequestTest.php @@ -15,14 +15,14 @@ class RequestTest extends AsyncTestCase public function testGetClient(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/')); + $request = new Request($client, 'GET', Http::new('/')); self::assertSame($client, $request->getClient()); } public function testSetMethod(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/')); + $request = new Request($client, 'GET', Http::new('/')); self::assertSame('GET', $request->getMethod()); $request->setMethod('POST'); self::assertSame('POST', $request->getMethod()); @@ -31,16 +31,16 @@ public function testSetMethod(): void public function testSetUri(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/')); + $request = new Request($client, 'GET', Http::new('/')); self::assertSame('/', (string) $request->getUri()); - $request->setUri(Http::createFromString('/foobar')); + $request->setUri(Http::new('/foobar')); self::assertSame('/foobar', (string) $request->getUri()); } public function testSetProtocolVersion(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/')); + $request = new Request($client, 'GET', Http::new('/')); self::assertSame('1.1', $request->getProtocolVersion()); $request->setProtocolVersion('1.0'); self::assertSame('1.0', $request->getProtocolVersion()); @@ -49,7 +49,7 @@ public function testSetProtocolVersion(): void public function testGetHeader(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/'), [ + $request = new Request($client, 'GET', Http::new('/'), [ 'foo' => 'bar', ]); @@ -65,7 +65,7 @@ public function testGetHeader(): void public function testAddHeader(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/'), [ + $request = new Request($client, 'GET', Http::new('/'), [ 'foo' => 'bar', ]); @@ -81,7 +81,7 @@ public function testAddHeader(): void public function testSetHeader(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/'), [ + $request = new Request($client, 'GET', Http::new('/'), [ 'foo' => 'bar', ]); @@ -101,7 +101,7 @@ public function testSetHeader(): void public function testGetAttribute(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/')); + $request = new Request($client, 'GET', Http::new('/')); $request->setAttribute('foo', 'bar'); self::assertSame('bar', $request->getAttribute('foo')); @@ -124,7 +124,7 @@ public function testGetAttribute(): void public function testSetBody(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'POST', Http::createFromString('/'), [ + $request = new Request($client, 'POST', Http::new('/'), [ 'content-length' => '0', ]); @@ -140,7 +140,7 @@ public function testSetBody(): void $request->setBody(new ReadableBuffer('foo')); self::assertFalse($request->hasHeader('content-length')); - $request = new Request($client, 'GET', Http::createFromString('/')); + $request = new Request($client, 'GET', Http::new('/')); $request->setBody(''); self::assertFalse($request->hasHeader('content-length')); } @@ -148,7 +148,7 @@ public function testSetBody(): void public function testCookies(): void { $client = $this->createMock(Client::class); - $request = new Request($client, 'GET', Http::createFromString('/'), [ + $request = new Request($client, 'GET', Http::new('/'), [ 'cookie' => (string) new RequestCookie('foo', 'bar'), ]);