diff --git a/src/foundation/src/Application.php b/src/foundation/src/Application.php index 972088506..3147df81b 100644 --- a/src/foundation/src/Application.php +++ b/src/foundation/src/Application.php @@ -31,7 +31,7 @@ class Application extends Container implements ApplicationContract * * @var string */ - public const VERSION = '0.1.5'; + public const VERSION = '0.1.6'; /** * The base path for the Hypervel installation. diff --git a/src/http/src/RouteDependency.php b/src/http/src/RouteDependency.php index c1fb74cdd..96e8485a9 100644 --- a/src/http/src/RouteDependency.php +++ b/src/http/src/RouteDependency.php @@ -16,9 +16,9 @@ class RouteDependency { /** - * All of the resolved dependencies by dispatched routes. + * All of the resolved definitions by dispatched routes. */ - protected array $resolvedDependencies = []; + protected array $resolvedDefinitions = []; /** * All of the after resolving callbacks by class type. @@ -105,22 +105,11 @@ public function getAfterResolvingCallbacks(object $object): array */ public function getMethodParameters(string $controller, string $action, array $arguments): array { - $signature = "{$controller}::{$action}"; - if (! $arguments && isset($this->resolvedDependencies[$signature])) { - return $this->resolvedDependencies[$signature]; - } - - $dependencies = $this->getDependencies( - $this->methodDefinitionCollector->getParameters($controller, $action), + return $this->getDependencies( + $this->getMethodDefinitions($controller, $action), "{$controller}::{$action}", $arguments ); - - if (! $arguments) { - $this->resolvedDependencies[$signature] = $dependencies; - } - - return $dependencies; } /** @@ -130,22 +119,33 @@ public function getMethodParameters(string $controller, string $action, array $a */ public function getClosureParameters(Closure $closure, array $arguments): array { - $signature = spl_object_hash($closure); - if (! $arguments && isset($this->resolvedDependencies[$signature])) { - return $this->resolvedDependencies[$signature]; - } - - $dependencies = $this->getDependencies( - $this->closureDefinitionCollector->getParameters($closure), + return $this->getDependencies( + $this->getClosureDefinitions($closure), 'Closure', $arguments ); + } - if (! $arguments) { - $this->resolvedDependencies[$signature] = $dependencies; - } + /** + * Parse the parameters of method definitions. + */ + public function getMethodDefinitions(string $controller, string $action): array + { + $signature = "{$controller}::{$action}"; - return $dependencies; + return $this->resolvedDefinitions[$signature] + ?? $this->resolvedDefinitions[$signature] = $this->methodDefinitionCollector->getParameters($controller, $action); + } + + /** + * Parse the parameters of closure definitions. + */ + public function getClosureDefinitions(Closure $closure): array + { + $signature = spl_object_hash($closure); + + return $this->resolvedDefinitions[$signature] + ?? $this->resolvedDefinitions[$signature] = $this->closureDefinitionCollector->getParameters($closure); } /**