From db14710ce4667ccb23ba65409544336a4c50ce57 Mon Sep 17 00:00:00 2001 From: Ignace Nyamagana Butera Date: Sun, 31 May 2020 20:37:32 +0200 Subject: [PATCH] Revert signature changes in src/Http because of PHPStan false positive --- phpstan.src.neon | 2 ++ src/Http.php | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/phpstan.src.neon b/phpstan.src.neon index 0699097e4..3b9f1f8c4 100644 --- a/phpstan.src.neon +++ b/phpstan.src.neon @@ -2,6 +2,8 @@ includes: - vendor/phpstan/phpstan-strict-rules/rules.neon parameters: ignoreErrors: + - message: '#Return type \(League\\Uri\\Http\) of method League\\Uri\\Http::with(.*)\(\) should be covariant with return type \(static\(Psr\\Http\\Message\\UriInterface\)\) of method Psr\\Http\\Message\\UriInterface::with(.*)\(\)#' + path: src/Http.php - message: '#Method League\\Uri\\Uri::withPath\(\) has parameter \$path with no typehint specified\.#' path: src/Uri.php - message: '#Variable method call on \$this\(League\\Uri\\Uri\)\.#' diff --git a/src/Http.php b/src/Http.php index 062a9b8e4..2307d653a 100644 --- a/src/Http.php +++ b/src/Http.php @@ -185,7 +185,7 @@ public function getFragment(): string /** * {@inheritDoc} */ - public function withScheme($scheme) + public function withScheme($scheme): self { $scheme = $this->filterInput($scheme); if ('' === $scheme) { @@ -197,7 +197,7 @@ public function withScheme($scheme) return $this; } - return new static($uri); + return new self($uri); } /** @@ -221,7 +221,7 @@ private function filterInput($str) /** * {@inheritDoc} */ - public function withUserInfo($user, $password = null) + public function withUserInfo($user, $password = null): self { $user = $this->filterInput($user); if ('' === $user) { @@ -233,13 +233,13 @@ public function withUserInfo($user, $password = null) return $this; } - return new static($uri); + return new self($uri); } /** * {@inheritDoc} */ - public function withHost($host) + public function withHost($host): self { $host = $this->filterInput($host); if ('' === $host) { @@ -251,39 +251,39 @@ public function withHost($host) return $this; } - return new static($uri); + return new self($uri); } /** * {@inheritDoc} */ - public function withPort($port) + public function withPort($port): self { $uri = $this->uri->withPort($port); if ($uri->getPort() === $this->uri->getPort()) { return $this; } - return new static($uri); + return new self($uri); } /** * {@inheritDoc} */ - public function withPath($path) + public function withPath($path): self { $uri = $this->uri->withPath($path); if ($uri->getPath() === $this->uri->getPath()) { return $this; } - return new static($uri); + return new self($uri); } /** * {@inheritDoc} */ - public function withQuery($query) + public function withQuery($query): self { $query = $this->filterInput($query); if ('' === $query) { @@ -295,13 +295,13 @@ public function withQuery($query) return $this; } - return new static($uri); + return new self($uri); } /** * {@inheritDoc} */ - public function withFragment($fragment) + public function withFragment($fragment): self { $fragment = $this->filterInput($fragment); if ('' === $fragment) { @@ -313,7 +313,7 @@ public function withFragment($fragment) return $this; } - return new static($uri); + return new self($uri); } /**