File tree Expand file tree Collapse file tree
tests/php/ControllerIntegration/Workflow Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -207,7 +207,29 @@ protected function setUp(): void {
207207 $ bootContext ->expects ($ this ->any ())
208208 ->method ('injectFn ' )
209209 ->willReturnCallback (function (callable $ fn ) use ($ container , $ generalLogger ): mixed {
210- return $ fn ($ this ->workflowManager , $ container , $ generalLogger );
210+ $ firstArgument = $ this ->workflowManager ;
211+ $ reflection = null ;
212+ if (is_array ($ fn ) && isset ($ fn [0 ], $ fn [1 ])) {
213+ $ reflection = new \ReflectionMethod ($ fn [0 ], (string )$ fn [1 ]);
214+ } elseif ($ fn instanceof \Closure) {
215+ $ reflection = new \ReflectionFunction ($ fn );
216+ } elseif (is_string ($ fn )) {
217+ $ reflection = new \ReflectionFunction ($ fn );
218+ }
219+
220+ if ($ reflection !== null ) {
221+ $ parameters = $ reflection ->getParameters ();
222+ if ($ parameters !== []) {
223+ $ type = $ parameters [0 ]->getType ();
224+ if ($ type instanceof \ReflectionNamedType && !$ type ->isBuiltin ()) {
225+ if (ltrim ($ type ->getName (), '\\' ) === ltrim (IEventDispatcher::class, '\\' )) {
226+ $ firstArgument = $ this ->dispatcher ;
227+ }
228+ }
229+ }
230+ }
231+
232+ return $ fn ($ firstArgument , $ container , $ generalLogger );
211233 });
212234 $ workflowApp ->boot ($ bootContext );
213235 }
You can’t perform that action at this time.
0 commit comments