Skip to content

Commit

Permalink
Replaced deprecated method calls from league/uri v6 (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilge authored Dec 13, 2024
1 parent 3088887 commit fd0f43b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"amphp/pipeline": "^1",
"amphp/socket": "^2",
"amphp/sync": "^2",
"league/uri": "^6 | ^7",
"league/uri": "^7",
"league/uri-components": "^2.4 | ^7",
"league/uri-interfaces": "^7.1",
"psr/http-message": "^1 | ^2"
Expand Down
3 changes: 1 addition & 2 deletions src/Connection/Internal/Http2ConnectionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,7 @@ public function handlePushPromise(int $streamId, int $pushId, array $pseudo, arr
}

try {
/** @psalm-suppress DeprecatedMethod */
$uri = Uri\Http::createFromComponents([
$uri = Uri\Http::fromComponents([
"scheme" => $scheme,
"host" => $host,
"port" => $port,
Expand Down
3 changes: 1 addition & 2 deletions src/Interceptor/FollowRedirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ private function getRedirectUri(Response $response): ?PsrUri
$header = $response->getHeader('location');
\assert($header !== null); // see check above

/** @psalm-suppress DeprecatedMethod */
$locationUri = Uri\Http::createFromString($header);
$locationUri = Uri\Http::new($header);
} catch (\Exception $e) {
return null;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Interceptor/MatchOrigin.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public function request(
private function checkOrigin(string $origin): string
{
try {
/** @psalm-suppress DeprecatedMethod */
$originUri = Http::createFromString($origin);
$originUri = Http::new($origin);
} catch (\Exception) {
throw new HttpException("Invalid origin provided: parsing failed: " . $origin);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Interceptor/ResolveBaseUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ final class ResolveBaseUri extends ModifyRequest
{
public function __construct(string $baseUri)
{
/** @psalm-suppress DeprecatedMethod */
parent::__construct(
fn (Request $request) => $request->setUri(Http::createFromBaseUri($request->getUri(), $baseUri))
fn (Request $request) => $request->setUri(Http::fromBaseUri($request->getUri(), $baseUri))
);
}
}
3 changes: 1 addition & 2 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ public function isIdempotent(): bool

private function createUriFromString(string $uri): UriInterface
{
/** @psalm-suppress DeprecatedMethod */
return Uri\Http::createFromString($uri);
return Uri\Http::new($uri);
}
}
2 changes: 1 addition & 1 deletion test/Connection/Http1ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function testWritingRequestWithValidUriPathProceedsWithMatchingUriPath(
[$server, $client] = Socket\createSocketPair();

$connection = new Http1Connection($client, 0, null, 5);
$uri = Uri\Http::createFromString('http://localhost')->withPath($requestPath);
$uri = Uri\Http::new('http://localhost')->withPath($requestPath);
$request = new Request($uri);
$request->setInactivityTimeout(0.5);

Expand Down
2 changes: 1 addition & 1 deletion test/Connection/Http2ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public function testWritingRequestWithValidUriPathProceedsWithMatchingUriPath(
string $requestPath,
string $expectedPath
): void {
$uri = Uri\Http::createFromString('http://localhost')->withPath($requestPath);
$uri = Uri\Http::new('http://localhost')->withPath($requestPath);
$request = new Request($uri);
$request->setInactivityTimeout(0.5);

Expand Down

0 comments on commit fd0f43b

Please sign in to comment.