3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Request { public function hello() { return 'hello '; } } class App { public function name() { return 'the app'; } public function response(Request $req, App $app) { return $req->hello().$app->name(); } } //依赖查找 or 自动依赖注入 $c['App'] = new App; $c['Request'] = new Request; $r = new ReflectionMethod('App', 'response'); $params = $r->getParameters(); $params = array_map(function($p) use ($c) { $className = $p->getClass()->name; return $c[$className]??null; }, $params); $res = $r->invokeArgs($c['App'], $params); //手动依赖注入 $app = new App; $req = new Request; $res = $app->response($req, $app);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1OVmo
function name:  (null)
number of ops:  42
compiled vars:  !0 = $c, !1 = $r, !2 = $params, !3 = $res, !4 = $app, !5 = $req
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $7      'App'
          1        DO_FCALL                                      0          
          2        ASSIGN_DIM                                               !0, 'App'
          3        OP_DATA                                                  $7
   26     4        NEW                                              $10     'Request'
          5        DO_FCALL                                      0          
          6        ASSIGN_DIM                                               !0, 'Request'
          7        OP_DATA                                                  $10
   28     8        NEW                                              $12     'ReflectionMethod'
          9        SEND_VAL_EX                                              'App'
         10        SEND_VAL_EX                                              'response'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $12
   29    13        INIT_METHOD_CALL                                         !1, 'getParameters'
         14        DO_FCALL                                      0  $15     
         15        ASSIGN                                                   !2, $15
   30    16        INIT_FCALL                                               'array_map'
         17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F1OVmo%3A30%240'
         18        BIND_LEXICAL                                             ~17, !0
   33    19        SEND_VAL                                                 ~17
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $18     
   30    22        ASSIGN                                                   !2, $18
   35    23        INIT_METHOD_CALL                                         !1, 'invokeArgs'
         24        CHECK_FUNC_ARG                                           
         25        FETCH_DIM_FUNC_ARG                               $20     !0, 'App'
         26        SEND_FUNC_ARG                                            $20
         27        SEND_VAR_EX                                              !2
         28        DO_FCALL                                      0  $21     
         29        ASSIGN                                                   !3, $21
   39    30        NEW                                              $23     'App'
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !4, $23
   40    33        NEW                                              $26     'Request'
         34        DO_FCALL                                      0          
         35        ASSIGN                                                   !5, $26
   41    36        INIT_METHOD_CALL                                         !4, 'response'
         37        SEND_VAR_EX                                              !5
         38        SEND_VAR_EX                                              !4
         39        DO_FCALL                                      0  $29     
         40        ASSIGN                                                   !3, $29
         41      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F1OVmo%3A30%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1OVmo
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $p, !1 = $c, !2 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   31     2        INIT_METHOD_CALL                                         !0, 'getClass'
          3        DO_FCALL                                      0  $3      
          4        FETCH_OBJ_R                                      ~4      $3, 'name'
          5        ASSIGN                                                   !2, ~4
   32     6        FETCH_DIM_IS                                     ~6      !1, !2
          7        COALESCE                                         ~7      ~6
          8        QM_ASSIGN                                        ~7      null
          9      > RETURN                                                   ~7
   33    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F1OVmo%3A30%240

Class Request:
Function hello:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1OVmo
function name:  hello
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                   'hello+'
    8     1*     > RETURN                                                   null

End of function hello

End of class Request.

Class App:
Function name:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1OVmo
function name:  name
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E > > RETURN                                                   'the+app'
   16     1*     > RETURN                                                   null

End of function name

Function response:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1OVmo
function name:  response
number of ops:  9
compiled vars:  !0 = $req, !1 = $app
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        INIT_METHOD_CALL                                         !0, 'hello'
          3        DO_FCALL                                      0  $2      
          4        INIT_METHOD_CALL                                         !1, 'name'
          5        DO_FCALL                                      0  $3      
          6        CONCAT                                           ~4      $2, $3
          7      > RETURN                                                   ~4
   20     8*     > RETURN                                                   null

End of function response

End of class App.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
279.78 ms | 1400 KiB | 15 Q