Skip to content

Commit

Permalink
Support psr/http-message 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
otsch committed Jun 28, 2023
1 parent ce2f019 commit f4883ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.4] - 2023-06-28
### Fixed
- Support psr/http-message v2.0.

## [2.0.3] - 2023-01-30
### Fixed
- As there is the new query string package, replace the last usage of the `Helpers::queryStringToArray()` method with the `Query` class from the package, to not have duplicate logic. Also, the package already contains some fixes.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"require": {
"php" : "^8.0",
"psr/http-message": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"symfony/polyfill-intl-idn": "^1.11",
"crwlr/query-string": "^1.0"
},
Expand Down
20 changes: 8 additions & 12 deletions src/Psr/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public function getFragment(): string
* @throws Exception
* @throws InvalidArgumentException
*/
public function withScheme($scheme): Uri
public function withScheme(string $scheme): Uri
{
if (!is_string($scheme) || (!Validator::scheme($scheme) && trim($scheme) !== '')) {
if ((!Validator::scheme($scheme) && trim($scheme) !== '')) {
throw new InvalidArgumentException('Invalid scheme.');
}

Expand All @@ -120,7 +120,7 @@ public function withScheme($scheme): Uri
* @return Uri
* @throws Exception
*/
public function withUserInfo($user, $password = null): Uri
public function withUserInfo(string $user, ?string $password = null): Uri
{
$newUrl = $this->newUrlInstance();
$newUrl->user($user);
Expand All @@ -134,7 +134,7 @@ public function withUserInfo($user, $password = null): Uri
* @return Uri
* @throws Exception
*/
public function withHost($host): Uri
public function withHost(string $host): Uri
{
$newUrl = $this->newUrlInstance();
$newUrl->host($host);
Expand All @@ -148,7 +148,7 @@ public function withHost($host): Uri
* @throws Exception
* @throws InvalidArgumentException
*/
public function withPort($port): Uri
public function withPort(?int $port): Uri
{
if ($port !== null && Validator::port($port) === null) {
throw new InvalidArgumentException('Port is outside the valid TCP and UDP port ranges.');
Expand All @@ -173,14 +173,10 @@ public function withPort($port): Uri
* @return Uri
* @throws Exception
*/
public function withPath($path): Uri
public function withPath(string $path): Uri
{
$newUrl = $this->newUrlInstance();

if (!is_string($path)) {
$path = '';
}

if (!str_starts_with($path, '/') && trim($path) !== '') {
$path = $this->resolver->resolvePath($path, $this->url->path() ?? '');
}
Expand All @@ -195,7 +191,7 @@ public function withPath($path): Uri
* @return Uri
* @throws Exception
*/
public function withQuery($query): Uri
public function withQuery(string $query): Uri
{
$newUrl = $this->newUrlInstance();
$newUrl->query($query);
Expand All @@ -208,7 +204,7 @@ public function withQuery($query): Uri
* @return Uri
* @throws Exception
*/
public function withFragment($fragment): Uri
public function withFragment(string $fragment): Uri
{
$newUrl = $this->newUrlInstance();
$newUrl->fragment($fragment);
Expand Down

0 comments on commit f4883ac

Please sign in to comment.