File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,18 @@ public function __construct(
3333 public function handle (ContainerInterface $ container , array $ arguments ): mixed
3434 {
3535 if (is_string ($ this ->handler )) {
36- $ reflection = new \ReflectionFunction ($ this ->handler );
37- $ arguments = $ this ->prepareArguments ($ reflection , $ arguments );
38- $ instance = $ container ->get ($ this ->handler );
39- return call_user_func ($ instance , ...$ arguments );
36+ if (class_exists ($ this ->handler ) && method_exists ($ this ->handler , '__invoke ' )) {
37+ $ reflection = new \ReflectionMethod ($ this ->handler , '__invoke ' );
38+ $ arguments = $ this ->prepareArguments ($ reflection , $ arguments );
39+ $ instance = $ container ->get ($ this ->handler );
40+ return call_user_func ($ instance , ...$ arguments );
41+ }
42+
43+ if (function_exists ($ this ->handler )) {
44+ $ reflection = new \ReflectionFunction ($ this ->handler );
45+ $ arguments = $ this ->prepareArguments ($ reflection , $ arguments );
46+ return call_user_func ($ this ->handler , ...$ arguments );
47+ }
4048 }
4149
4250 if (is_callable ($ this ->handler )) {
You can’t perform that action at this time.
0 commit comments