1616class RouteDependency
1717{
1818 /**
19- * All of the resolved dependencies by dispatched routes.
19+ * All of the resolved definitions by dispatched routes.
2020 */
21- protected array $ resolvedDependencies = [];
21+ protected array $ resolvedDefinitions = [];
2222
2323 /**
2424 * All of the after resolving callbacks by class type.
@@ -105,22 +105,11 @@ public function getAfterResolvingCallbacks(object $object): array
105105 */
106106 public function getMethodParameters (string $ controller , string $ action , array $ arguments ): array
107107 {
108- $ signature = "{$ controller }:: {$ action }" ;
109- if (! $ arguments && isset ($ this ->resolvedDependencies [$ signature ])) {
110- return $ this ->resolvedDependencies [$ signature ];
111- }
112-
113- $ dependencies = $ this ->getDependencies (
114- $ this ->methodDefinitionCollector ->getParameters ($ controller , $ action ),
108+ return $ this ->getDependencies (
109+ $ this ->getMethodDefinitions ($ controller , $ action ),
115110 "{$ controller }:: {$ action }" ,
116111 $ arguments
117112 );
118-
119- if (! $ arguments ) {
120- $ this ->resolvedDependencies [$ signature ] = $ dependencies ;
121- }
122-
123- return $ dependencies ;
124113 }
125114
126115 /**
@@ -130,22 +119,33 @@ public function getMethodParameters(string $controller, string $action, array $a
130119 */
131120 public function getClosureParameters (Closure $ closure , array $ arguments ): array
132121 {
133- $ signature = spl_object_hash ($ closure );
134- if (! $ arguments && isset ($ this ->resolvedDependencies [$ signature ])) {
135- return $ this ->resolvedDependencies [$ signature ];
136- }
137-
138- $ dependencies = $ this ->getDependencies (
139- $ this ->closureDefinitionCollector ->getParameters ($ closure ),
122+ return $ this ->getDependencies (
123+ $ this ->getClosureDefinitions ($ closure ),
140124 'Closure ' ,
141125 $ arguments
142126 );
127+ }
143128
144- if (! $ arguments ) {
145- $ this ->resolvedDependencies [$ signature ] = $ dependencies ;
146- }
129+ /**
130+ * Parse the parameters of method definitions.
131+ */
132+ public function getMethodDefinitions (string $ controller , string $ action ): array
133+ {
134+ $ signature = "{$ controller }:: {$ action }" ;
147135
148- return $ dependencies ;
136+ return $ this ->resolvedDefinitions [$ signature ]
137+ ?? $ this ->resolvedDefinitions [$ signature ] = $ this ->methodDefinitionCollector ->getParameters ($ controller , $ action );
138+ }
139+
140+ /**
141+ * Parse the parameters of closure definitions.
142+ */
143+ public function getClosureDefinitions (Closure $ closure ): array
144+ {
145+ $ signature = spl_object_hash ($ closure );
146+
147+ return $ this ->resolvedDefinitions [$ signature ]
148+ ?? $ this ->resolvedDefinitions [$ signature ] = $ this ->closureDefinitionCollector ->getParameters ($ closure );
149149 }
150150
151151 /**
0 commit comments