From d5bcddc8eb2625022cd02e70cd6e43e7f18c6492 Mon Sep 17 00:00:00 2001 From: N'Bayramberdiyev Date: Sun, 30 Mar 2025 12:13:29 +0300 Subject: [PATCH 1/3] Correct route callable/handler type --- Slim/CallableResolver.php | 6 +++--- .../AdvancedCallableResolverInterface.php | 4 ++-- Slim/Interfaces/CallableResolverInterface.php | 2 +- Slim/Interfaces/RouteCollectorInterface.php | 2 +- Slim/Interfaces/RouteCollectorProxyInterface.php | 16 ++++++++-------- Slim/Interfaces/RouteInterface.php | 4 ++-- Slim/Routing/Route.php | 4 ++-- Slim/Routing/RouteCollector.php | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Slim/CallableResolver.php b/Slim/CallableResolver.php index dab46c460..fcab3c189 100644 --- a/Slim/CallableResolver.php +++ b/Slim/CallableResolver.php @@ -79,7 +79,7 @@ public function resolveMiddleware($toResolve): callable } /** - * @param string|callable $toResolve + * @param callable|array|string $toResolve * * @throws RuntimeException */ @@ -180,8 +180,8 @@ private function bindToContainer(callable $callable): callable } /** - * @param string|callable $toResolve - * @return string|callable + * @param callable|array|string $toResolve + * @return callable|array|string */ private function prepareToResolve($toResolve) { diff --git a/Slim/Interfaces/AdvancedCallableResolverInterface.php b/Slim/Interfaces/AdvancedCallableResolverInterface.php index aa1d897de..7ba963b75 100644 --- a/Slim/Interfaces/AdvancedCallableResolverInterface.php +++ b/Slim/Interfaces/AdvancedCallableResolverInterface.php @@ -15,14 +15,14 @@ interface AdvancedCallableResolverInterface extends CallableResolverInterface /** * Resolve $toResolve into a callable * - * @param string|callable $toResolve + * @param callable|array|string $toResolve */ public function resolveRoute($toResolve): callable; /** * Resolve $toResolve into a callable * - * @param string|callable $toResolve + * @param callable|array|string $toResolve */ public function resolveMiddleware($toResolve): callable; } diff --git a/Slim/Interfaces/CallableResolverInterface.php b/Slim/Interfaces/CallableResolverInterface.php index 92bfda43a..06ec37aa9 100644 --- a/Slim/Interfaces/CallableResolverInterface.php +++ b/Slim/Interfaces/CallableResolverInterface.php @@ -15,7 +15,7 @@ interface CallableResolverInterface /** * Resolve $toResolve into a callable * - * @param string|callable $toResolve + * @param callable|array|string $toResolve */ public function resolve($toResolve): callable; } diff --git a/Slim/Interfaces/RouteCollectorInterface.php b/Slim/Interfaces/RouteCollectorInterface.php index aa83883f6..9b03e1166 100644 --- a/Slim/Interfaces/RouteCollectorInterface.php +++ b/Slim/Interfaces/RouteCollectorInterface.php @@ -97,7 +97,7 @@ public function group(string $pattern, $callable): RouteGroupInterface; * * @param string[] $methods Array of HTTP methods * @param string $pattern The route pattern - * @param callable|string $handler The route callable + * @param callable|array|string $handler The route callable */ public function map(array $methods, string $pattern, $handler): RouteInterface; } diff --git a/Slim/Interfaces/RouteCollectorProxyInterface.php b/Slim/Interfaces/RouteCollectorProxyInterface.php index 0220af030..f764dc41d 100644 --- a/Slim/Interfaces/RouteCollectorProxyInterface.php +++ b/Slim/Interfaces/RouteCollectorProxyInterface.php @@ -46,7 +46,7 @@ public function setBasePath(string $basePath): RouteCollectorProxyInterface; * Add GET route * * @param string $pattern The route URI pattern - * @param callable|string $callable The route callback routine + * @param callable|array|string $callable The route callback routine */ public function get(string $pattern, $callable): RouteInterface; @@ -54,7 +54,7 @@ public function get(string $pattern, $callable): RouteInterface; * Add POST route * * @param string $pattern The route URI pattern - * @param callable|string $callable The route callback routine + * @param callable|array|string $callable The route callback routine */ public function post(string $pattern, $callable): RouteInterface; @@ -62,7 +62,7 @@ public function post(string $pattern, $callable): RouteInterface; * Add PUT route * * @param string $pattern The route URI pattern - * @param callable|string $callable The route callback routine + * @param callable|array|string $callable The route callback routine */ public function put(string $pattern, $callable): RouteInterface; @@ -70,7 +70,7 @@ public function put(string $pattern, $callable): RouteInterface; * Add PATCH route * * @param string $pattern The route URI pattern - * @param callable|string $callable The route callback routine + * @param callable|array|string $callable The route callback routine */ public function patch(string $pattern, $callable): RouteInterface; @@ -78,7 +78,7 @@ public function patch(string $pattern, $callable): RouteInterface; * Add DELETE route * * @param string $pattern The route URI pattern - * @param callable|string $callable The route callback routine + * @param callable|array|string $callable The route callback routine */ public function delete(string $pattern, $callable): RouteInterface; @@ -86,7 +86,7 @@ public function delete(string $pattern, $callable): RouteInterface; * Add OPTIONS route * * @param string $pattern The route URI pattern - * @param callable|string $callable The route callback routine + * @param callable|array|string $callable The route callback routine */ public function options(string $pattern, $callable): RouteInterface; @@ -94,7 +94,7 @@ public function options(string $pattern, $callable): RouteInterface; * Add route for any HTTP method * * @param string $pattern The route URI pattern - * @param callable|string $callable The route callback routine + * @param callable|array|string $callable The route callback routine */ public function any(string $pattern, $callable): RouteInterface; @@ -103,7 +103,7 @@ public function any(string $pattern, $callable): RouteInterface; * * @param string[] $methods Numeric array of HTTP method names * @param string $pattern The route URI pattern - * @param callable|string $callable The route callback routine + * @param callable|array|string $callable The route callback routine */ public function map(array $methods, string $pattern, $callable): RouteInterface; diff --git a/Slim/Interfaces/RouteInterface.php b/Slim/Interfaces/RouteInterface.php index 8ed817ef4..4a467bad6 100644 --- a/Slim/Interfaces/RouteInterface.php +++ b/Slim/Interfaces/RouteInterface.php @@ -47,14 +47,14 @@ public function setPattern(string $pattern): RouteInterface; /** * Get route callable * - * @return callable|string + * @return callable|array|string */ public function getCallable(); /** * Set route callable * - * @param callable|string $callable + * @param callable|array|string $callable */ public function setCallable($callable): RouteInterface; diff --git a/Slim/Routing/Route.php b/Slim/Routing/Route.php index a2d9d04a2..62cb08004 100644 --- a/Slim/Routing/Route.php +++ b/Slim/Routing/Route.php @@ -91,7 +91,7 @@ class Route implements RouteInterface, RequestHandlerInterface /** * Route callable * - * @var callable|string + * @var callable|array|string */ protected $callable; @@ -109,7 +109,7 @@ class Route implements RouteInterface, RequestHandlerInterface /** * @param string[] $methods The route HTTP methods * @param string $pattern The route pattern - * @param callable|string $callable The route callable + * @param callable|array|string $callable The route callable * @param ResponseFactoryInterface $responseFactory * @param CallableResolverInterface $callableResolver * @param TContainerInterface $container diff --git a/Slim/Routing/RouteCollector.php b/Slim/Routing/RouteCollector.php index 6f9f0f66b..b5c7de4dd 100644 --- a/Slim/Routing/RouteCollector.php +++ b/Slim/Routing/RouteCollector.php @@ -283,7 +283,7 @@ public function map(array $methods, string $pattern, $handler): RouteInterface /** * @param string[] $methods - * @param callable|string $callable + * @param callable|array|string $callable */ protected function createRoute(array $methods, string $pattern, $callable): RouteInterface { From c8ab7e61c93f8117e40b07b8a056eace0edd55ae Mon Sep 17 00:00:00 2001 From: N'Bayramberdiyev Date: Sun, 30 Mar 2025 12:19:54 +0300 Subject: [PATCH 2/3] Fix docblock indentation --- Slim/CallableResolver.php | 2 +- Slim/Interfaces/RouteCollectorInterface.php | 4 +-- .../RouteCollectorProxyInterface.php | 34 +++++++++---------- Slim/Routing/Route.php | 18 +++++----- Slim/Routing/RouteCollector.php | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Slim/CallableResolver.php b/Slim/CallableResolver.php index fcab3c189..d56e23ef2 100644 --- a/Slim/CallableResolver.php +++ b/Slim/CallableResolver.php @@ -180,7 +180,7 @@ private function bindToContainer(callable $callable): callable } /** - * @param callable|array|string $toResolve + * @param callable|array|string $toResolve * @return callable|array|string */ private function prepareToResolve($toResolve) diff --git a/Slim/Interfaces/RouteCollectorInterface.php b/Slim/Interfaces/RouteCollectorInterface.php index 9b03e1166..c4ea3a7bc 100644 --- a/Slim/Interfaces/RouteCollectorInterface.php +++ b/Slim/Interfaces/RouteCollectorInterface.php @@ -95,8 +95,8 @@ public function group(string $pattern, $callable): RouteGroupInterface; /** * Add route * - * @param string[] $methods Array of HTTP methods - * @param string $pattern The route pattern + * @param string[] $methods Array of HTTP methods + * @param string $pattern The route pattern * @param callable|array|string $handler The route callable */ public function map(array $methods, string $pattern, $handler): RouteInterface; diff --git a/Slim/Interfaces/RouteCollectorProxyInterface.php b/Slim/Interfaces/RouteCollectorProxyInterface.php index f764dc41d..c30bfaa12 100644 --- a/Slim/Interfaces/RouteCollectorProxyInterface.php +++ b/Slim/Interfaces/RouteCollectorProxyInterface.php @@ -45,65 +45,65 @@ public function setBasePath(string $basePath): RouteCollectorProxyInterface; /** * Add GET route * - * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param string $pattern The route URI pattern + * @param callable|array|string $callable The route callback routine */ public function get(string $pattern, $callable): RouteInterface; /** * Add POST route * - * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param string $pattern The route URI pattern + * @param callable|array|string $callable The route callback routine */ public function post(string $pattern, $callable): RouteInterface; /** * Add PUT route * - * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param string $pattern The route URI pattern + * @param callable|array|string $callable The route callback routine */ public function put(string $pattern, $callable): RouteInterface; /** * Add PATCH route * - * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param string $pattern The route URI pattern + * @param callable|array|string $callable The route callback routine */ public function patch(string $pattern, $callable): RouteInterface; /** * Add DELETE route * - * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param string $pattern The route URI pattern + * @param callable|array|string $callable The route callback routine */ public function delete(string $pattern, $callable): RouteInterface; /** * Add OPTIONS route * - * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param string $pattern The route URI pattern + * @param callable|array|string $callable The route callback routine */ public function options(string $pattern, $callable): RouteInterface; /** * Add route for any HTTP method * - * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param string $pattern The route URI pattern + * @param callable|array|string $callable The route callback routine */ public function any(string $pattern, $callable): RouteInterface; /** * Add route with multiple methods * - * @param string[] $methods Numeric array of HTTP method names - * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param string[] $methods Numeric array of HTTP method names + * @param string $pattern The route URI pattern + * @param callable|array|string $callable The route callback routine */ public function map(array $methods, string $pattern, $callable): RouteInterface; diff --git a/Slim/Routing/Route.php b/Slim/Routing/Route.php index 62cb08004..234adcd1b 100644 --- a/Slim/Routing/Route.php +++ b/Slim/Routing/Route.php @@ -107,15 +107,15 @@ class Route implements RouteInterface, RequestHandlerInterface protected bool $groupMiddlewareAppended = false; /** - * @param string[] $methods The route HTTP methods - * @param string $pattern The route pattern - * @param callable|array|string $callable The route callable - * @param ResponseFactoryInterface $responseFactory - * @param CallableResolverInterface $callableResolver - * @param TContainerInterface $container - * @param InvocationStrategyInterface|null $invocationStrategy - * @param RouteGroupInterface[] $groups The parent route groups - * @param int $identifier The route identifier + * @param string[] $methods The route HTTP methods + * @param string $pattern The route pattern + * @param callable|array|string $callable The route callable + * @param ResponseFactoryInterface $responseFactory + * @param CallableResolverInterface $callableResolver + * @param TContainerInterface $container + * @param InvocationStrategyInterface|null $invocationStrategy + * @param RouteGroupInterface[] $groups The parent route groups + * @param int $identifier The route identifier */ public function __construct( array $methods, diff --git a/Slim/Routing/RouteCollector.php b/Slim/Routing/RouteCollector.php index b5c7de4dd..274781d9e 100644 --- a/Slim/Routing/RouteCollector.php +++ b/Slim/Routing/RouteCollector.php @@ -282,7 +282,7 @@ public function map(array $methods, string $pattern, $handler): RouteInterface } /** - * @param string[] $methods + * @param string[] $methods * @param callable|array|string $callable */ protected function createRoute(array $methods, string $pattern, $callable): RouteInterface From c23d3c22f2177c92cca40d2bd9f9be3c1d746c84 Mon Sep 17 00:00:00 2001 From: N'Bayramberdiyev Date: Sun, 30 Mar 2025 13:34:49 +0300 Subject: [PATCH 3/3] Use shaped array type --- Slim/CallableResolver.php | 6 +++--- .../AdvancedCallableResolverInterface.php | 4 ++-- Slim/Interfaces/CallableResolverInterface.php | 2 +- Slim/Interfaces/RouteCollectorInterface.php | 2 +- Slim/Interfaces/RouteCollectorProxyInterface.php | 16 ++++++++-------- Slim/Interfaces/RouteInterface.php | 4 ++-- Slim/Routing/Route.php | 4 ++-- Slim/Routing/RouteCollector.php | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Slim/CallableResolver.php b/Slim/CallableResolver.php index d56e23ef2..1de91d846 100644 --- a/Slim/CallableResolver.php +++ b/Slim/CallableResolver.php @@ -79,7 +79,7 @@ public function resolveMiddleware($toResolve): callable } /** - * @param callable|array|string $toResolve + * @param callable|array{class-string, string}|string $toResolve * * @throws RuntimeException */ @@ -180,8 +180,8 @@ private function bindToContainer(callable $callable): callable } /** - * @param callable|array|string $toResolve - * @return callable|array|string + * @param callable|array{string, string}|string $toResolve + * @return callable|array|string */ private function prepareToResolve($toResolve) { diff --git a/Slim/Interfaces/AdvancedCallableResolverInterface.php b/Slim/Interfaces/AdvancedCallableResolverInterface.php index 7ba963b75..114546613 100644 --- a/Slim/Interfaces/AdvancedCallableResolverInterface.php +++ b/Slim/Interfaces/AdvancedCallableResolverInterface.php @@ -15,14 +15,14 @@ interface AdvancedCallableResolverInterface extends CallableResolverInterface /** * Resolve $toResolve into a callable * - * @param callable|array|string $toResolve + * @param callable|array{class-string, string}|string $toResolve */ public function resolveRoute($toResolve): callable; /** * Resolve $toResolve into a callable * - * @param callable|array|string $toResolve + * @param callable|array{class-string, string}|string $toResolve */ public function resolveMiddleware($toResolve): callable; } diff --git a/Slim/Interfaces/CallableResolverInterface.php b/Slim/Interfaces/CallableResolverInterface.php index 06ec37aa9..e2614cf48 100644 --- a/Slim/Interfaces/CallableResolverInterface.php +++ b/Slim/Interfaces/CallableResolverInterface.php @@ -15,7 +15,7 @@ interface CallableResolverInterface /** * Resolve $toResolve into a callable * - * @param callable|array|string $toResolve + * @param callable|array{class-string, string}|string $toResolve */ public function resolve($toResolve): callable; } diff --git a/Slim/Interfaces/RouteCollectorInterface.php b/Slim/Interfaces/RouteCollectorInterface.php index c4ea3a7bc..c37d4738f 100644 --- a/Slim/Interfaces/RouteCollectorInterface.php +++ b/Slim/Interfaces/RouteCollectorInterface.php @@ -97,7 +97,7 @@ public function group(string $pattern, $callable): RouteGroupInterface; * * @param string[] $methods Array of HTTP methods * @param string $pattern The route pattern - * @param callable|array|string $handler The route callable + * @param callable|array{class-string, string}|string $handler The route callable */ public function map(array $methods, string $pattern, $handler): RouteInterface; } diff --git a/Slim/Interfaces/RouteCollectorProxyInterface.php b/Slim/Interfaces/RouteCollectorProxyInterface.php index c30bfaa12..ea230353c 100644 --- a/Slim/Interfaces/RouteCollectorProxyInterface.php +++ b/Slim/Interfaces/RouteCollectorProxyInterface.php @@ -46,7 +46,7 @@ public function setBasePath(string $basePath): RouteCollectorProxyInterface; * Add GET route * * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param callable|array{class-string, string}|string $callable The route callback routine */ public function get(string $pattern, $callable): RouteInterface; @@ -54,7 +54,7 @@ public function get(string $pattern, $callable): RouteInterface; * Add POST route * * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param callable|array{class-string, string}|string $callable The route callback routine */ public function post(string $pattern, $callable): RouteInterface; @@ -62,7 +62,7 @@ public function post(string $pattern, $callable): RouteInterface; * Add PUT route * * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param callable|array{class-string, string}|string $callable The route callback routine */ public function put(string $pattern, $callable): RouteInterface; @@ -70,7 +70,7 @@ public function put(string $pattern, $callable): RouteInterface; * Add PATCH route * * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param callable|array{class-string, string}|string $callable The route callback routine */ public function patch(string $pattern, $callable): RouteInterface; @@ -78,7 +78,7 @@ public function patch(string $pattern, $callable): RouteInterface; * Add DELETE route * * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param callable|array{class-string, string}|string $callable The route callback routine */ public function delete(string $pattern, $callable): RouteInterface; @@ -86,7 +86,7 @@ public function delete(string $pattern, $callable): RouteInterface; * Add OPTIONS route * * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param callable|array{class-string, string}|string $callable The route callback routine */ public function options(string $pattern, $callable): RouteInterface; @@ -94,7 +94,7 @@ public function options(string $pattern, $callable): RouteInterface; * Add route for any HTTP method * * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param callable|array{class-string, string}|string $callable The route callback routine */ public function any(string $pattern, $callable): RouteInterface; @@ -103,7 +103,7 @@ public function any(string $pattern, $callable): RouteInterface; * * @param string[] $methods Numeric array of HTTP method names * @param string $pattern The route URI pattern - * @param callable|array|string $callable The route callback routine + * @param callable|array{class-string, string}|string $callable The route callback routine */ public function map(array $methods, string $pattern, $callable): RouteInterface; diff --git a/Slim/Interfaces/RouteInterface.php b/Slim/Interfaces/RouteInterface.php index 4a467bad6..8a6c1833b 100644 --- a/Slim/Interfaces/RouteInterface.php +++ b/Slim/Interfaces/RouteInterface.php @@ -47,14 +47,14 @@ public function setPattern(string $pattern): RouteInterface; /** * Get route callable * - * @return callable|array|string + * @return callable|array{class-string, string}|string */ public function getCallable(); /** * Set route callable * - * @param callable|array|string $callable + * @param callable|array{class-string, string}|string $callable */ public function setCallable($callable): RouteInterface; diff --git a/Slim/Routing/Route.php b/Slim/Routing/Route.php index 234adcd1b..cc900c114 100644 --- a/Slim/Routing/Route.php +++ b/Slim/Routing/Route.php @@ -91,7 +91,7 @@ class Route implements RouteInterface, RequestHandlerInterface /** * Route callable * - * @var callable|array|string + * @var callable|array{class-string, string}|string */ protected $callable; @@ -109,7 +109,7 @@ class Route implements RouteInterface, RequestHandlerInterface /** * @param string[] $methods The route HTTP methods * @param string $pattern The route pattern - * @param callable|array|string $callable The route callable + * @param callable|array{class-string, string}|string $callable The route callable * @param ResponseFactoryInterface $responseFactory * @param CallableResolverInterface $callableResolver * @param TContainerInterface $container diff --git a/Slim/Routing/RouteCollector.php b/Slim/Routing/RouteCollector.php index 274781d9e..0fb7e4133 100644 --- a/Slim/Routing/RouteCollector.php +++ b/Slim/Routing/RouteCollector.php @@ -283,7 +283,7 @@ public function map(array $methods, string $pattern, $handler): RouteInterface /** * @param string[] $methods - * @param callable|array|string $callable + * @param callable|array{class-string, string}|string $callable */ protected function createRoute(array $methods, string $pattern, $callable): RouteInterface {