3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Methods { public function doSomething(){ echo 'Did something'; } } class Router { public $methods; public function __construct($methods){ $this->methods = $methods; } public function execute($fn){ return call_user_func($fn->bindTo($this)); } } $router = new Router(new Methods); $router->execute(function(){ echo 'Running the closure'; $this->methods->doSomething(); });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DjENA
function name:  (null)
number of ops:  11
compiled vars:  !0 = $router
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $1      'Router'
          1        NEW                                              $2      'Methods'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $2
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   21     6        INIT_METHOD_CALL                                         !0, 'execute'
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDjENA%3A21%240'
   24     8        SEND_VAL_EX                                              ~6
          9        DO_FCALL                                      0          
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FDjENA%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DjENA
function name:  {closure}
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ECHO                                                     'Running+the+closure'
   23     1        FETCH_THIS                                       $0      
          2        FETCH_OBJ_R                                      ~1      $0, 'methods'
          3        INIT_METHOD_CALL                                         ~1, 'doSomething'
          4        DO_FCALL                                      0          
   24     5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDjENA%3A21%240

Class Methods:
Function dosomething:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DjENA
function name:  doSomething
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     'Did+something'
    6     1      > RETURN                                                   null

End of function dosomething

End of class Methods.

Class Router:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DjENA
function name:  __construct
number of ops:  4
compiled vars:  !0 = $methods
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ASSIGN_OBJ                                               'methods'
          2        OP_DATA                                                  !0
   13     3      > RETURN                                                   null

End of function __construct

Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DjENA
function name:  execute
number of ops:  9
compiled vars:  !0 = $fn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_METHOD_CALL                                         !0, 'bindTo'
          2        FETCH_THIS                                       $1      
          3        SEND_VAR_EX                                              $1
          4        DO_FCALL                                      0  $2      
          5        INIT_USER_CALL                                0          'call_user_func', $2
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
   17     8*     > RETURN                                                   null

End of function execute

End of class Router.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.61 ms | 1399 KiB | 13 Q