From e822afb2d7e9de305acd0b970303f401bfb072cf Mon Sep 17 00:00:00 2001 From: Evgeniy Zyubin Date: Mon, 30 Dec 2024 01:40:42 +0300 Subject: [PATCH 1/2] Fix for PHP 8.4 --- .github/workflows/build.yml | 2 ++ .github/workflows/static.yml | 1 + src/Route.php | 2 +- src/RouteCollection.php | 2 +- src/RouteCollectionInterface.php | 2 +- src/RouteCollector.php | 2 +- 6 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7fa0ea1..420cb9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,8 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" + - "8.4" steps: - name: Checkout. diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 3e79b31..0d90f64 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -35,6 +35,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" steps: - name: Checkout. diff --git a/src/Route.php b/src/Route.php index 546adc8..3790eea 100644 --- a/src/Route.php +++ b/src/Route.php @@ -337,7 +337,7 @@ public function path(array $parameters = []): string * @throws InvalidRouteParameterException If the host or the parameter value does not match its regexp. * @psalm-suppress PossiblyNullArgument */ - public function url(array $parameters = [], string $host = null, bool $secure = null): string + public function url(array $parameters = [], ?string $host = null, ?bool $secure = null): string { $path = $this->path($parameters); $host = $host ? trim($host, '/') : null; diff --git a/src/RouteCollection.php b/src/RouteCollection.php index 6e4c56c..b8ca92b 100644 --- a/src/RouteCollection.php +++ b/src/RouteCollection.php @@ -135,7 +135,7 @@ public function path(string $name, array $parameters = []): string /** * {@inheritDoc} */ - public function url(string $name, array $parameters = [], string $host = null, bool $secure = null): string + public function url(string $name, array $parameters = [], ?string $host = null, ?bool $secure = null): string { $route = $this->get($name); return $route->url($parameters, $host, $secure); diff --git a/src/RouteCollectionInterface.php b/src/RouteCollectionInterface.php index 688daa6..b0e587c 100644 --- a/src/RouteCollectionInterface.php +++ b/src/RouteCollectionInterface.php @@ -90,5 +90,5 @@ public function path(string $name, array $parameters = []): string; * @return string URL generated. * @throws RouteNotFoundException if the route does not exist. */ - public function url(string $name, array $parameters = [], string $host = null, bool $secure = null): string; + public function url(string $name, array $parameters = [], ?string $host = null, ?bool $secure = null): string; } diff --git a/src/RouteCollector.php b/src/RouteCollector.php index 8f52233..f781994 100644 --- a/src/RouteCollector.php +++ b/src/RouteCollector.php @@ -19,7 +19,7 @@ final class RouteCollector /** * @param RouteCollectionInterface|null $routes */ - public function __construct(RouteCollectionInterface $routes = null) + public function __construct(?RouteCollectionInterface $routes = null) { $this->routes = $routes ?? new RouteCollection(); } From 5d624d4aa6303a6008a3213a3f54b0663647446d Mon Sep 17 00:00:00 2001 From: Evgeniy Zyubin Date: Mon, 30 Dec 2024 01:44:34 +0300 Subject: [PATCH 2/2] Fix psalm --- src/Route.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Route.php b/src/Route.php index 3790eea..339c06b 100644 --- a/src/Route.php +++ b/src/Route.php @@ -297,7 +297,7 @@ public function match(ServerRequestInterface $request): bool * @param array $parameters parameter-value set. * @return string URL path generated. * @throws InvalidRouteParameterException if the value does not match its regexp or the required parameter is null. - * @psalm-suppress MixedAssignment + * @psalm-suppress MixedAssignment, RiskyTruthyFalsyComparison */ public function path(array $parameters = []): string { @@ -335,7 +335,7 @@ public function path(array $parameters = []): string * @param bool|null $secure if `true`, then `https`. If `false`, then `http`. If `null`, then without the protocol. * @return string URL generated. * @throws InvalidRouteParameterException If the host or the parameter value does not match its regexp. - * @psalm-suppress PossiblyNullArgument + * @psalm-suppress PossiblyNullArgument, RiskyTruthyFalsyComparison */ public function url(array $parameters = [], ?string $host = null, ?bool $secure = null): string { @@ -435,6 +435,7 @@ private function normalizeParameter($value, string $name, string $pattern, bool * * @param string $host * @return bool + * @psalm-suppress RiskyTruthyFalsyComparison */ private function isMatchedHost(string $host): bool {