3v4l.org

run code in 300+ PHP versions simultaneously
<?php class IsolatedTest { protected $closure; public function __construct($closure) { $this->closure = $closure; } public function __invoke() { call_user_func($this->closure); } } class Test { public function testing(callable $what) { return Closure::bind($what, $this, $this); } } $test = new IsolatedTest(function () { echo 'This can be forked and called.'; }); $more = (new Test)->testing($test); var_dump($more);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/usUfQ
function name:  (null)
number of ops:  15
compiled vars:  !0 = $test, !1 = $more
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $2      'IsolatedTest'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FusUfQ%3A26%240'
   28     2        SEND_VAL_EX                                              ~3
          3        DO_FCALL                                      0          
   26     4        ASSIGN                                                   !0, $2
   30     5        NEW                                              $6      'Test'
          6        DO_FCALL                                      0          
          7        INIT_METHOD_CALL                                         $6, 'testing'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !1, $8
   32    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FusUfQ%3A26%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/usUfQ
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ECHO                                                     'This+can+be+forked+and+called.'
   28     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FusUfQ%3A26%240

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

End of function __construct

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/usUfQ
function name:  __invoke
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                      ~0      'closure'
          1        INIT_USER_CALL                                0          'call_user_func', ~0
          2        DO_FCALL                                      0          
   15     3      > RETURN                                                   null

End of function __invoke

End of class IsolatedTest.

Class Test:
Function testing:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/usUfQ
function name:  testing
number of ops:  10
compiled vars:  !0 = $what
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          2        SEND_VAR                                                 !0
          3        FETCH_THIS                                       ~1      
          4        SEND_VAL                                                 ~1
          5        FETCH_THIS                                       ~2      
          6        SEND_VAL                                                 ~2
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   23     9*     > RETURN                                                   null

End of function testing

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.06 ms | 946 KiB | 16 Q