3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { function __construct (&$arr) { $this->arr = &$arr; } function createInstance () { $reflectionClass = new ReflectionClass("Bar"); return $reflectionClass->newInstanceArgs(array($this, $this->arr)); } function mod($key, $val) { $this->arr[$key] = $val; } } class Bar { function __construct (&$foo, &$arr) { $this->foo = &$foo; $this->arr = &$arr; } function mod($key, $val) { $this->arr[$key] = $val; } } $arr = array(); $foo = new Foo($arr); $arr["x"] = 1; $foo->mod("y", 2); $bar = $foo->createInstance(); $bar->mod("z", 3); var_dump($arr,$foo,$bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VRTtV
function name:  (null)
number of ops:  24
compiled vars:  !0 = $arr, !1 = $foo, !2 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, <array>
   27     1        NEW                                              $4      'Foo'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   29     5        ASSIGN_DIM                                               !0, 'x'
          6        OP_DATA                                                  1
   31     7        INIT_METHOD_CALL                                         !1, 'mod'
          8        SEND_VAL_EX                                              'y'
          9        SEND_VAL_EX                                              2
         10        DO_FCALL                                      0          
   33    11        INIT_METHOD_CALL                                         !1, 'createInstance'
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !2, $9
   35    14        INIT_METHOD_CALL                                         !2, 'mod'
         15        SEND_VAL_EX                                              'z'
         16        SEND_VAL_EX                                              3
         17        DO_FCALL                                      0          
   37    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !1
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

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

End of function __construct

Function createinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VRTtV
function name:  createInstance
number of ops:  13
compiled vars:  !0 = $reflectionClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $1      'ReflectionClass'
          1        SEND_VAL_EX                                              'Bar'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
    8     4        INIT_METHOD_CALL                                         !0, 'newInstanceArgs'
          5        FETCH_THIS                                       ~4      
          6        INIT_ARRAY                                       ~5      ~4
          7        FETCH_OBJ_R                                      ~6      'arr'
          8        ADD_ARRAY_ELEMENT                                ~5      ~6
          9        SEND_VAL_EX                                              ~5
         10        DO_FCALL                                      0  $7      
         11      > RETURN                                                   $7
    9    12*     > RETURN                                                   null

End of function createinstance

Function mod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VRTtV
function name:  mod
number of ops:  6
compiled vars:  !0 = $key, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_OBJ_W                                      $2      'arr'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   12     5      > RETURN                                                   null

End of function mod

End of class Foo.

Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VRTtV
function name:  __construct
number of ops:  7
compiled vars:  !0 = $foo, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        ASSIGN_OBJ_REF                                           'foo'
          3        OP_DATA                                                  !0
   18     4        ASSIGN_OBJ_REF                                           'arr'
          5        OP_DATA                                                  !1
   19     6      > RETURN                                                   null

End of function __construct

Function mod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VRTtV
function name:  mod
number of ops:  6
compiled vars:  !0 = $key, !1 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        FETCH_OBJ_W                                      $2      'arr'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   22     5      > RETURN                                                   null

End of function mod

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.05 ms | 1400 KiB | 15 Q