File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ public function toRequestHandler($reference) : RequestHandlerInterface
7878
7979 list ($ class , $ method ) = $ this ->normalizeReference ($ reference );
8080
81- if (isset ($ class, $ method ) && method_exists ($ class , $ method )) {
81+ if (isset ($ class) && isset ( $ method ) && method_exists ($ class , $ method )) {
8282 return new CallableRequestHandler ([$ this ->resolveClass ($ class ), $ method ]);
8383 }
8484
@@ -107,7 +107,7 @@ public function toMiddleware($reference) : MiddlewareInterface
107107
108108 list ($ class , $ method ) = $ this ->normalizeReference ($ reference );
109109
110- if (isset ($ class, $ method ) && method_exists ($ class , $ method )) {
110+ if (isset ($ class) && isset ( $ method ) && method_exists ($ class , $ method )) {
111111 return new CallableMiddleware ([$ this ->resolveClass ($ class ), $ method ]);
112112 }
113113
@@ -164,9 +164,11 @@ private function stringifyReference($reference) : string
164164 /**
165165 * Resolves the given class
166166 *
167- * @param string $class
167+ * @param class- string<T> $class
168168 *
169- * @return object
169+ * @return T
170+ *
171+ * @template T
170172 */
171173 private function resolveClass (string $ class )
172174 {
Original file line number Diff line number Diff line change @@ -38,8 +38,10 @@ class Route implements RouteInterface
3838 * Server Request attribute name for the route
3939 *
4040 * @var string
41+ *
42+ * @deprecated 2.11.0 Use the RouteInterface::ATTR_ROUTE constant.
4143 */
42- public const ATTR_NAME_FOR_ROUTE = ' @route ' ;
44+ public const ATTR_NAME_FOR_ROUTE = self :: ATTR_ROUTE ;
4345
4446 /**
4547 * Server Request attribute name for the route name
@@ -396,7 +398,7 @@ public function withAddedAttributes(array $attributes) : RouteInterface
396398 */
397399 public function handle (ServerRequestInterface $ request ) : ResponseInterface
398400 {
399- $ request = $ request ->withAttribute (self ::ATTR_NAME_FOR_ROUTE , $ this );
401+ $ request = $ request ->withAttribute (self ::ATTR_ROUTE , $ this );
400402
401403 /** @todo Must be removed from the 3.0.0 version */
402404 $ request = $ request ->withAttribute (self ::ATTR_NAME_FOR_ROUTE_NAME , $ this ->name );
Original file line number Diff line number Diff line change 2323interface RouteInterface extends RequestHandlerInterface
2424{
2525
26+ /**
27+ * Request attribute name for the route instance
28+ *
29+ * @var string
30+ *
31+ * @since 2.11.0
32+ */
33+ public const ATTR_ROUTE = '@route ' ;
34+
2635 /**
2736 * Gets the route name
2837 *
You can’t perform that action at this time.
0 commit comments