Skip to content

Commit c74232a

Browse files
committed
Drop support for older league/uri components
Fixes #376.
1 parent 4b87c0f commit c74232a

9 files changed

+27
-34
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
"amphp/pipeline": "^1",
3939
"amphp/socket": "^2.1",
4040
"amphp/sync": "^2.2",
41-
"league/uri": "^6.8 | ^7.1",
42-
"league/uri-interfaces": "^2.3 | ^7.1",
41+
"league/uri": "^7.1",
42+
"league/uri-interfaces": "^7.1",
4343
"psr/http-message": "^1 | ^2",
4444
"psr/log": "^1 | ^2 | ^3",
4545
"revolt/event-loop": "^1"
@@ -49,7 +49,7 @@
4949
"amphp/http-client": "^5",
5050
"amphp/log": "^2",
5151
"amphp/php-cs-fixer-config": "^2",
52-
"league/uri-components": "^2.4.2 | ^7.1",
52+
"league/uri-components": "^7.1",
5353
"monolog/monolog": "^3",
5454
"phpunit/phpunit": "^9",
5555
"psalm/phar": "~5.23"

src/Driver/Http1Driver.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,21 @@ public function handleClient(
274274
$target = \substr($target, 0, $position);
275275
}
276276

277-
/** @psalm-suppress DeprecatedMethod */
278-
$uri = Uri\Http::createFromComponents([
277+
$uri = Uri\Http::fromComponents([
279278
"scheme" => $scheme,
280279
"host" => $host,
281280
"port" => $port,
282281
"path" => $target,
283282
"query" => $query,
284283
]);
285284
} elseif ($target === "*") { // asterisk-form
286-
/** @psalm-suppress DeprecatedMethod */
287-
$uri = Uri\Http::createFromComponents([
285+
$uri = Uri\Http::fromComponents([
288286
"scheme" => $scheme,
289287
"host" => $host,
290288
"port" => $port,
291289
]);
292290
} elseif (\preg_match("#^https?://#i", $target)) { // absolute-form
293-
/** @psalm-suppress DeprecatedMethod */
294-
$uri = Uri\Http::createFromString($target);
291+
$uri = Uri\Http::new($target);
295292

296293
if ($uri->getHost() !== $host || $uri->getPort() !== $port) {
297294
throw new ClientException(
@@ -325,8 +322,7 @@ public function handleClient(
325322
);
326323
}
327324

328-
/** @psalm-suppress DeprecatedMethod */
329-
$uri = Uri\Http::createFromComponents([
325+
$uri = Uri\Http::fromComponents([
330326
"host" => $matches[1],
331327
"port" => (int) $matches[2],
332328
]);

src/Driver/Http2Driver.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -996,15 +996,13 @@ public function handleHeaders(int $streamId, array $pseudo, array $headers, bool
996996

997997
try {
998998
if ($target === "*") {
999-
/** @psalm-suppress DeprecatedMethod */
1000-
$uri = Uri\Http::createFromComponents([
999+
$uri = Uri\Http::fromComponents([
10011000
"scheme" => $scheme,
10021001
"host" => $host,
10031002
"port" => $port,
10041003
]);
10051004
} else {
1006-
/** @psalm-suppress DeprecatedMethod */
1007-
$uri = Uri\Http::createFromComponents([
1005+
$uri = Uri\Http::fromComponents([
10081006
"scheme" => $scheme,
10091007
"host" => $host,
10101008
"port" => $port,

src/Response.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,7 @@ public function getPushes(): array
313313
public function push(string $url, array $headers = []): void
314314
{
315315
try {
316-
/** @psalm-suppress DeprecatedMethod */
317-
$uri = Uri\Http::createFromString($url);
316+
$uri = Uri\Http::new($url);
318317
} catch (\Exception $exception) {
319318
throw new \Error("Invalid push URI: " . $exception->getMessage(), 0, $exception);
320319
}

test/Driver/Http1DriverTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -756,15 +756,15 @@ public function testPipelinedRequests(): void
756756

757757
self::assertSame($results[1], $request->getBody()->buffer());
758758

759-
$request = new Request($this->createClientMock(), "GET", Uri\Http::createFromString("/"));
759+
$request = new Request($this->createClientMock(), "GET", Uri\Http::new("/"));
760760

761761
delay(0.01); // Allow parser generator to continue.
762762

763763
self::assertInstanceOf(Request::class, $request);
764764

765765
self::assertSame($results[0], $request->getBody()->buffer());
766766

767-
$request = new Request($this->createClientMock(), "POST", Uri\Http::createFromString("/"));
767+
$request = new Request($this->createClientMock(), "POST", Uri\Http::new("/"));
768768

769769
self::assertSame(3, $responses);
770770
}

test/Driver/SocketClientTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testTrivialHttpRequest(): void
5151
[$address, $server] = $this->startServer(function (Request $req) {
5252
$this->assertEquals("GET", $req->getMethod());
5353
$this->assertEquals("/uri", $req->getUri()->getPath());
54-
$query = Query::createFromUri($req->getUri());
54+
$query = Query::fromUri($req->getUri());
5555
$this->assertEquals(
5656
[["foo", "bar"], ["baz", "1"], ["baz", "2"]],
5757
\iterator_to_array($query->getIterator())

test/Middleware/ExceptionHandlerMiddlewareTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ExceptionHandlerMiddlewareTest extends AsyncTestCase
1818
{
1919
private function setupAndInvokeMiddleware(ExceptionHandler $exceptionHandler, \Throwable $exception): Response
2020
{
21-
$request = new Request($this->createMock(Client::class), 'GET', Http::createFromString('/'));
21+
$request = new Request($this->createMock(Client::class), 'GET', Http::new('/'));
2222

2323
$requestHandler = $this->createMock(RequestHandler::class);
2424
$requestHandler->expects(self::once())

test/Middleware/StackTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class StackTest extends AsyncTestCase
1717
{
1818
public function testStackAppliesMiddlewaresInCorrectOrder(): void
1919
{
20-
$request = new Request($this->createMock(Client::class), "GET", Uri\Http::createFromString("/foobar"));
20+
$request = new Request($this->createMock(Client::class), "GET", Uri\Http::new("/foobar"));
2121

2222
$stack = stackMiddleware(new ClosureRequestHandler(function (Request $request) {
2323
$response = new Response(HttpStatus::OK, [], "OK");

test/RequestTest.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class RequestTest extends AsyncTestCase
1515
public function testGetClient(): void
1616
{
1717
$client = $this->createMock(Client::class);
18-
$request = new Request($client, 'GET', Http::createFromString('/'));
18+
$request = new Request($client, 'GET', Http::new('/'));
1919
self::assertSame($client, $request->getClient());
2020
}
2121

2222
public function testSetMethod(): void
2323
{
2424
$client = $this->createMock(Client::class);
25-
$request = new Request($client, 'GET', Http::createFromString('/'));
25+
$request = new Request($client, 'GET', Http::new('/'));
2626
self::assertSame('GET', $request->getMethod());
2727
$request->setMethod('POST');
2828
self::assertSame('POST', $request->getMethod());
@@ -31,16 +31,16 @@ public function testSetMethod(): void
3131
public function testSetUri(): void
3232
{
3333
$client = $this->createMock(Client::class);
34-
$request = new Request($client, 'GET', Http::createFromString('/'));
34+
$request = new Request($client, 'GET', Http::new('/'));
3535
self::assertSame('/', (string) $request->getUri());
36-
$request->setUri(Http::createFromString('/foobar'));
36+
$request->setUri(Http::new('/foobar'));
3737
self::assertSame('/foobar', (string) $request->getUri());
3838
}
3939

4040
public function testSetProtocolVersion(): void
4141
{
4242
$client = $this->createMock(Client::class);
43-
$request = new Request($client, 'GET', Http::createFromString('/'));
43+
$request = new Request($client, 'GET', Http::new('/'));
4444
self::assertSame('1.1', $request->getProtocolVersion());
4545
$request->setProtocolVersion('1.0');
4646
self::assertSame('1.0', $request->getProtocolVersion());
@@ -49,7 +49,7 @@ public function testSetProtocolVersion(): void
4949
public function testGetHeader(): void
5050
{
5151
$client = $this->createMock(Client::class);
52-
$request = new Request($client, 'GET', Http::createFromString('/'), [
52+
$request = new Request($client, 'GET', Http::new('/'), [
5353
'foo' => 'bar',
5454
]);
5555

@@ -65,7 +65,7 @@ public function testGetHeader(): void
6565
public function testAddHeader(): void
6666
{
6767
$client = $this->createMock(Client::class);
68-
$request = new Request($client, 'GET', Http::createFromString('/'), [
68+
$request = new Request($client, 'GET', Http::new('/'), [
6969
'foo' => 'bar',
7070
]);
7171

@@ -81,7 +81,7 @@ public function testAddHeader(): void
8181
public function testSetHeader(): void
8282
{
8383
$client = $this->createMock(Client::class);
84-
$request = new Request($client, 'GET', Http::createFromString('/'), [
84+
$request = new Request($client, 'GET', Http::new('/'), [
8585
'foo' => 'bar',
8686
]);
8787

@@ -101,7 +101,7 @@ public function testSetHeader(): void
101101
public function testGetAttribute(): void
102102
{
103103
$client = $this->createMock(Client::class);
104-
$request = new Request($client, 'GET', Http::createFromString('/'));
104+
$request = new Request($client, 'GET', Http::new('/'));
105105

106106
$request->setAttribute('foo', 'bar');
107107
self::assertSame('bar', $request->getAttribute('foo'));
@@ -124,7 +124,7 @@ public function testGetAttribute(): void
124124
public function testSetBody(): void
125125
{
126126
$client = $this->createMock(Client::class);
127-
$request = new Request($client, 'POST', Http::createFromString('/'), [
127+
$request = new Request($client, 'POST', Http::new('/'), [
128128
'content-length' => '0',
129129
]);
130130

@@ -140,15 +140,15 @@ public function testSetBody(): void
140140
$request->setBody(new ReadableBuffer('foo'));
141141
self::assertFalse($request->hasHeader('content-length'));
142142

143-
$request = new Request($client, 'GET', Http::createFromString('/'));
143+
$request = new Request($client, 'GET', Http::new('/'));
144144
$request->setBody('');
145145
self::assertFalse($request->hasHeader('content-length'));
146146
}
147147

148148
public function testCookies(): void
149149
{
150150
$client = $this->createMock(Client::class);
151-
$request = new Request($client, 'GET', Http::createFromString('/'), [
151+
$request = new Request($client, 'GET', Http::new('/'), [
152152
'cookie' => (string) new RequestCookie('foo', 'bar'),
153153
]);
154154

0 commit comments

Comments
 (0)