diff --git a/src/Common/ReflectedClass.php b/src/Common/ReflectedClass.php index 97e9a0e..0bc1ef7 100644 --- a/src/Common/ReflectedClass.php +++ b/src/Common/ReflectedClass.php @@ -175,9 +175,7 @@ class ReflectedClass implements ReflectedInterface public function getAttribute(string $attributeType): ?object { foreach($this->getAttributes(true, $attributeType) as $attribute) { - if ($attribute->object instanceof $attributeType) { - return $attribute; - } + return $attribute; } return null; diff --git a/src/Route/RouteFetcher.php b/src/Route/RouteFetcher.php index 4ee34a5..169ae3b 100644 --- a/src/Route/RouteFetcher.php +++ b/src/Route/RouteFetcher.php @@ -81,6 +81,14 @@ class RouteFetcher { { $attributes ??= $this->attributes; + /* + 8.5: return $attributes + |> serialize(...) + |> md5(...) + |> (fn($x) => substr($x, 0, 7)) + |> (fn($x) => $this->handleCaching()) + */ + return $this->handleCaching(substr(md5(serialize($attributes)), 0, 7), function() use ($attributes) : array { $list = []; @@ -124,10 +132,7 @@ class RouteFetcher { $route->class = $class; $route->classMethod = $func; - - if (false === ($route->methods ?? false)) { - $route->methods = $methods ?? $this->defaultMethods; - } + $route->method ??= $methods ?? $this->defaultMethods; if (false !== ($this->callback ?? false)) { call_user_func_array($this->callback, [$route]);