3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mimicking($obj, $exec){ var_dump(debug_backtrace()); return (function() use($exec){ return $exec(); })->bindTo(null, $obj)(); } class A{ protected $stuff = 10; function test(){ return new class($this){ function __construct(A $s){ $this->s = $s; } function asd(){ return mimicking($this->s, function(){ return $this->s->stuff; }); } }; } } $x = new A; echo $x->test()->asd();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m479s
function name:  (null)
number of ops:  9
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_METHOD_CALL                                         !0, 'test'
          4        DO_FCALL                                      0  $4      
          5        INIT_METHOD_CALL                                         $4, 'asd'
          6        DO_FCALL                                      0  $5      
          7        ECHO                                                     $5
          8      > RETURN                                                   1

Function mimicking:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m479s
function name:  mimicking
number of ops:  17
compiled vars:  !0 = $obj, !1 = $exec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'debug_backtrace'
          4        DO_ICALL                                         $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
    5     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fm479s%3A5%240'
          8        BIND_LEXICAL                                             ~4, !1
    7     9        INIT_METHOD_CALL                                         ~4, 'bindTo'
         10        SEND_VAL_EX                                              null
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $5      
         13        INIT_DYNAMIC_CALL                                        $5
         14        DO_FCALL                                      0  $6      
         15      > RETURN                                                   $6
    8    16*     > RETURN                                                   null

End of function mimicking

Function %00%7Bclosure%7D%2Fin%2Fm479s%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m479s
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $exec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   BIND_STATIC                                              !0
    6     1        INIT_DYNAMIC_CALL                                        !0
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
    7     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fm479s%3A5%240

Function %00%7Bclosure%7D%2Fin%2Fm479s%3A18%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m479s
function name:  {closure}
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_THIS                                       $0      
          1        FETCH_OBJ_R                                      ~1      $0, 's'
          2        FETCH_OBJ_R                                      ~2      ~1, 'stuff'
          3      > RETURN                                                   ~2
   20     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fm479s%3A18%242

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

End of function __construct

Function asd:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m479s
function name:  asd
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'mimicking'
          1        FETCH_OBJ_R                                      ~0      's'
          2        SEND_VAL                                                 ~0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fm479s%3A18%242'
   20     4        SEND_VAL                                                 ~1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   21     7*     > RETURN                                                   null

End of function asd

End of class class@anonymous.

Class A:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m479s
function name:  test
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_ANON_CLASS                               <ptr>   
          1        NEW                                              $1      $0
          2        FETCH_THIS                                       $2      
          3        SEND_VAR_EX                                              $2
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $1
   23     6*     > RETURN                                                   null

End of function test

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
193.8 ms | 1403 KiB | 18 Q