3v4l.org

run code in 300+ PHP versions simultaneously
<?php class stdobject { public function __call($method, $arguments) { if (isset($this->{$method}) && is_callable($this->{$method})) { return call_user_func_array($this->{$method}, $arguments); } else { throw new Exception("Fatal error: Call to undefined method: $method"); } } } $mod = function() { $self = new stdobject(); $self->init = function ($params) use ($self) { $self->_opmode = &$params['opmode']; }; $self->setup = function () use ($self) { $self->_opmode = 'dog'; }; $self->print = function () use ($self) { echo $self->_opmode . "\n"; }; return $self; }; $obj = $mod(); $reference = 'fish'; $obj->init(['opmode' => &$reference]); $obj->print(); // fish $obj->setup(); $obj->print(); // dog $reference = 'cats'; $obj->print(); // cats
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SLAri
function name:  (null)
number of ops:  20
compiled vars:  !0 = $mod, !1 = $obj, !2 = $reference
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSLAri%3A13%240'
          1        ASSIGN                                                   !0, ~3
   31     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0  $5      
          4        ASSIGN                                                   !1, $5
   33     5        ASSIGN                                                   !2, 'fish'
   34     6        INIT_METHOD_CALL                                         !1, 'init'
          7        INIT_ARRAY                                       ~8      !2, 'opmode'
          8        SEND_VAL_EX                                              ~8
          9        DO_FCALL                                      0          
   35    10        INIT_METHOD_CALL                                         !1, 'print'
         11        DO_FCALL                                      0          
   37    12        INIT_METHOD_CALL                                         !1, 'setup'
         13        DO_FCALL                                      0          
   38    14        INIT_METHOD_CALL                                         !1, 'print'
         15        DO_FCALL                                      0          
   40    16        ASSIGN                                                   !2, 'cats'
   41    17        INIT_METHOD_CALL                                         !1, 'print'
         18        DO_FCALL                                      0          
         19      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FSLAri%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SLAri
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   NEW                                              $1      'stdobject'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   16     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSLAri%3A16%241'
          4        BIND_LEXICAL                                             ~5, !0
          5        ASSIGN_OBJ                                               !0, 'init'
   18     6        OP_DATA                                                  ~5
   20     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSLAri%3A20%242'
          8        BIND_LEXICAL                                             ~7, !0
          9        ASSIGN_OBJ                                               !0, 'setup'
   22    10        OP_DATA                                                  ~7
   24    11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FSLAri%3A24%243'
         12        BIND_LEXICAL                                             ~9, !0
         13        ASSIGN_OBJ                                               !0, 'print'
   26    14        OP_DATA                                                  ~9
   28    15      > RETURN                                                   !0
   29    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSLAri%3A13%240

Function %00%7Bclosure%7D%2Fin%2FSLAri%3A16%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SLAri
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $params, !1 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   17     2        FETCH_DIM_W                                      $3      !0, 'opmode'
          3        MAKE_REF                                         $4      $3
          4        ASSIGN_OBJ_REF                                           !1, '_opmode'
          5        OP_DATA                                                  $4
   18     6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSLAri%3A16%241

Function %00%7Bclosure%7D%2Fin%2FSLAri%3A20%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SLAri
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   BIND_STATIC                                              !0
   21     1        ASSIGN_OBJ                                               !0, '_opmode'
          2        OP_DATA                                                  'dog'
   22     3      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSLAri%3A20%242

Function %00%7Bclosure%7D%2Fin%2FSLAri%3A24%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SLAri
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   BIND_STATIC                                              !0
   25     1        FETCH_OBJ_R                                      ~1      !0, '_opmode'
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
   26     4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FSLAri%3A24%243

Class stdobject:
Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
filename:       /in/SLAri
function name:  __call
number of ops:  24
compiled vars:  !0 = $method, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ISSET_ISEMPTY_PROP_OBJ                           ~2      !0
          3      > JMPZ_EX                                          ~2      ~2, ->9
          4    >   INIT_FCALL                                               'is_callable'
          5        FETCH_OBJ_R                                      ~3      !0
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8        BOOL                                             ~2      $4
          9    > > JMPZ                                                     ~2, ->17
    6    10    >   FETCH_OBJ_R                                      ~5      !0
         11        INIT_USER_CALL                                0          'call_user_func_array', ~5
         12        SEND_ARRAY                                               !1
         13        CHECK_UNDEF_ARGS                                         
         14        DO_FCALL                                      0  $6      
         15      > RETURN                                                   $6
         16*       JMP                                                      ->23
    8    17    >   NEW                                              $7      'Exception'
         18        NOP                                                      
         19        FAST_CONCAT                                      ~8      'Fatal+error%3A+Call+to+undefined+method%3A+', !0
         20        SEND_VAL_EX                                              ~8
         21        DO_FCALL                                      0          
         22      > THROW                                         0          $7
   10    23*     > RETURN                                                   null

End of function __call

End of class stdobject.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.54 ms | 1404 KiB | 15 Q