3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mimicking($obj, $exec){ 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/ALDal
function name:  (null)
number of ops:  9
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   26     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/ALDal
function name:  mimicking
number of ops:  12
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        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FALDal%3A4%240'
          3        BIND_LEXICAL                                             ~2, !1
    6     4        INIT_METHOD_CALL                                         ~2, 'bindTo'
          5        SEND_VAL_EX                                              null
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $3      
          8        INIT_DYNAMIC_CALL                                        $3
          9        DO_FCALL                                      0  $4      
         10      > RETURN                                                   $4
    7    11*     > RETURN                                                   null

End of function mimicking

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

End of function %00%7Bclosure%7D%2Fin%2FALDal%3A4%240

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

End of function %00%7Bclosure%7D%2Fin%2FALDal%3A17%242

Class class@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ALDal
function name:  __construct
number of ops:  4
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        ASSIGN_OBJ                                               's'
          2        OP_DATA                                                  !0
   15     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/ALDal
function name:  asd
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'mimicking'
          1        FETCH_OBJ_R                                      ~0      's'
          2        SEND_VAL                                                 ~0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FALDal%3A17%242'
   19     4        SEND_VAL                                                 ~1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   20     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/ALDal
function name:  test
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_ANON_CLASS                               <indirect>  
          1        NEW                                              $1      $0
          2        FETCH_THIS                                       $2      
          3        SEND_VAR_EX                                              $2
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $1
   22     6*     > RETURN                                                   null

End of function test

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.26 ms | 1403 KiB | 14 Q