diff --git a/CHANGELOG.md b/CHANGELOG.md index 9eafa70..1af9672 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Chg #207: Replace two `RouteCollectorInterface` methods `addRoute()` and `addGroup()` to single `addRoute()` (@vjik) - Enh #202: Add support for `psr/http-message` version `^2.0` (@vjik) - Chg #222: Make `Route`, `Group` and `MatchingResult` dispatcher-independent (@rustamwin, @vjik) +- Enh #229: Add URL arguments' psalm type in `UrlGeneratorInterface` (@vjik) ## 3.0.0 February 17, 2023 diff --git a/src/UrlGeneratorInterface.php b/src/UrlGeneratorInterface.php index 214e891..7688116 100644 --- a/src/UrlGeneratorInterface.php +++ b/src/UrlGeneratorInterface.php @@ -8,6 +8,9 @@ /** * `UrlGeneratorInterface` allows generating URL given route name, arguments, and query parameters. + * + * @psalm-type ArgumentType = scalar|Stringable|null + * @psalm-type ArgumentsType = array */ interface UrlGeneratorInterface { @@ -15,12 +18,14 @@ interface UrlGeneratorInterface * Generates URL from named route, arguments, and query parameters. * * @param string $name Name of the route. - * @param array $arguments Argument-value set. + * @param array $arguments Argument-value set. * @param array $queryParameters Parameter-value set. * * @throws RouteNotFoundException In case there is no route with the name specified. * * @return string URL generated. + * + * @psalm-param ArgumentsType $arguments */ public function generate(string $name, array $arguments = [], array $queryParameters = []): string; @@ -28,7 +33,7 @@ public function generate(string $name, array $arguments = [], array $queryParame * Generates absolute URL from named route, arguments, and query parameters. * * @param string $name Name of the route. - * @param array $arguments Argument-value set. + * @param array $arguments Argument-value set. * @param array $queryParameters Parameter-value set. * @param string|null $scheme Host scheme. * @param string|null $host Host for manual setup. @@ -36,6 +41,8 @@ public function generate(string $name, array $arguments = [], array $queryParame * @throws RouteNotFoundException In case there is no route with the name specified. * * @return string URL generated. + * + * @psalm-param ArgumentsType $arguments */ public function generateAbsolute( string $name, @@ -48,11 +55,12 @@ public function generateAbsolute( /** * Generate URL from the current route replacing some of its arguments with values specified. * - * @param array $replacedArguments New argument values indexed by replaced argument - * names. + * @param array $replacedArguments New argument values indexed by replaced argument names. * @param array $queryParameters Parameter-value set. * @param string|null $fallbackRouteName Name of a route that should be used if current route. * can not be determined. + * + * @psalm-param ArgumentsType $replacedArguments */ public function generateFromCurrent( array $replacedArguments,