3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createClass(array $val, array $vals) { return new class($val, $vals) { public function __construct(public array $val, public array $vals) { } }; } $x = []; $y = &$x[]; $y = []; $z = createClass($y, $x); $y[] = 'a'; var_dump($x, $z->val, $z->vals);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5q93F
function name:  (null)
number of ops:  19
compiled vars:  !0 = $x, !1 = $y, !2 = $z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   11     1        FETCH_DIM_W                                      $4      !0
          2        ASSIGN_REF                                               !1, $4
   12     3        ASSIGN                                                   !1, <array>
   13     4        INIT_FCALL                                               'createclass'
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !2, $7
   14     9        ASSIGN_DIM                                               !1
         10        OP_DATA                                                  'a'
   16    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !0
         13        FETCH_OBJ_R                                      ~10     !2, 'val'
         14        SEND_VAL                                                 ~10
         15        FETCH_OBJ_R                                      ~11     !2, 'vals'
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function createclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5q93F
function name:  createClass
number of ops:  9
compiled vars:  !0 = $val, !1 = $vals
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        DECLARE_ANON_CLASS                               96      
          3        NEW                                              $3      $2
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
          7      > RETURN                                                   $3
    8     8*     > RETURN                                                   null

End of function createclass

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

End of function __construct

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.86 ms | 1403 KiB | 16 Q