3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = new class([ "item" => [ "I", "am", "a", "animal" => "beaver", ], "callable" => function(){ return true; } ]) implements ArrayAccess { public function __construct(array $initial = []) { foreach ($initial as $k => $v) { if (is_array($v)) { $this->$k = new self($v); } else $this->$k = $v; } } public function offsetGet($offset) { if (!isset($this->$offset)) { return ($this->$offset = new self()); } return $this->$offset; } public function offsetSet($offset, $value) { if (is_array($value)) { $this->$offset = new self($value); } else $this->$offset = $value; } public function offsetUnset($offset) { unset($this->$offset); } public function offsetExists($offset) { return isset($this->$offset); } public function array(self $object = null) : array { $array = []; if ($object === null) $object = $this; foreach ($object as $k => $v) { if ($v instanceof self) { $array[$k] = $this->array($v); } else $array[$k] = $v; } return $array; } public function __invoke(...$args) {} /* more magic here, perhaps ... */ }; $config["item"]["next"] = [ "I", "am", "a", "animal" => "badger", ]; # write undefined index of existing member $config[1][2] = "hello"; # write undefined index $config[5][8][10] = "whatever"; # write more undef index $config[9][10](); # read undef index and invoke it as function var_dump($config->array()); # show flattened array, not needed for iteration and whatever ... ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fa5Tk
function name:  (null)
number of ops:  28
compiled vars:  !0 = $config
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_ANON_CLASS                               <unknown> 
          1        NEW                                              $2      $1
    4     2        INIT_ARRAY                                       ~3      <array>, 'item'
    9     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FFa5Tk%3A9%241'
   11     4        ADD_ARRAY_ELEMENT                                ~3      ~4, 'callable'
          5        SEND_VAL_EX                                              ~3
          6        DO_FCALL                                      0          
    2     7        ASSIGN                                                   !0, $2
   59     8        FETCH_DIM_W                                      $7      !0, 'item'
          9        ASSIGN_DIM                                               $7, 'next'
   60    10        OP_DATA                                                  <array>
   65    11        FETCH_DIM_W                                      $9      !0, 1
         12        ASSIGN_DIM                                               $9, 2
         13        OP_DATA                                                  'hello'
   66    14        FETCH_DIM_W                                      $11     !0, 5
         15        FETCH_DIM_W                                      $12     $11, 8
         16        ASSIGN_DIM                                               $12, 10
         17        OP_DATA                                                  'whatever'
   67    18        FETCH_DIM_R                                      ~14     !0, 9
         19        FETCH_DIM_R                                      ~15     ~14, 10
         20        INIT_DYNAMIC_CALL                                        ~15
         21        DO_FCALL                                      0          
   69    22        INIT_FCALL                                               'var_dump'
         23        INIT_METHOD_CALL                                         !0, 'array'
         24        DO_FCALL                                      0  $17     
         25        SEND_VAR                                                 $17
         26        DO_ICALL                                                 
   70    27      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FFa5Tk%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fa5Tk
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E > > RETURN                                                   <true>
   11     1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FFa5Tk%3A9%241

Class ArrayAccess@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 15
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/Fa5Tk
function name:  __construct
number of ops:  17
compiled vars:  !0 = $initial, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV_INIT                                        !0      <array>
   15     1      > FE_RESET_R                                       $3      !0, ->15
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->15
          3    >   ASSIGN                                                   !2, ~4
   16     4        TYPE_CHECK                                  128          !1
          5      > JMPZ                                                     ~6, ->12
   17     6    >   NEW                          self                $8      
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        ASSIGN_OBJ                                               !2
         10        OP_DATA                                                  $8
         11      > JMP                                                      ->14
   18    12    >   ASSIGN_OBJ                                               !2
         13        OP_DATA                                                  !1
   15    14    > > JMP                                                      ->2
         15    >   FE_FREE                                                  $3
   20    16      > RETURN                                                   null

End of function __construct

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fa5Tk
function name:  offsetGet
number of ops:  12
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        ISSET_ISEMPTY_PROP_OBJ                           ~1      !0
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->9
   24     4    >   NEW                          self                $4      
          5        DO_FCALL                                      0          
          6        ASSIGN_OBJ                                       ~3      !0
          7        OP_DATA                                                  $4
          8      > RETURN                                                   ~3
   27     9    >   FETCH_OBJ_R                                      ~6      !0
         10      > RETURN                                                   ~6
   28    11*     > RETURN                                                   null

End of function offsetget

Function offsetset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fa5Tk
function name:  offsetSet
number of ops:  13
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   31     2        TYPE_CHECK                                  128          !1
          3      > JMPZ                                                     ~2, ->10
   32     4    >   NEW                          self                $4      
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
          7        ASSIGN_OBJ                                               !0
          8        OP_DATA                                                  $4
          9      > JMP                                                      ->12
   33    10    >   ASSIGN_OBJ                                               !0
         11        OP_DATA                                                  !1
   34    12    > > RETURN                                                   null

End of function offsetset

Function offsetunset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fa5Tk
function name:  offsetUnset
number of ops:  3
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        UNSET_OBJ                                                !0
          2      > RETURN                                                   null

End of function offsetunset

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fa5Tk
function name:  offsetExists
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        ISSET_ISEMPTY_PROP_OBJ                           ~1      !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function offsetexists

Function array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 6
filename:       /in/Fa5Tk
function name:  array
number of ops:  25
compiled vars:  !0 = $object, !1 = $array, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV_INIT                                        !0      null
   40     1        ASSIGN                                                   !1, <array>
   42     2        TYPE_CHECK                                    2          !0
          3      > JMPZ                                                     ~5, ->6
   43     4    >   FETCH_THIS                                       ~6      
          5        ASSIGN                                                   !0, ~6
   45     6    > > FE_RESET_R                                       $8      !0, ->20
          7    > > FE_FETCH_R                                       ~9      $8, !2, ->20
          8    >   ASSIGN                                                   !3, ~9
   46     9        INSTANCEOF                                               !2
         10      > JMPZ                                                     ~11, ->17
   47    11    >   INIT_METHOD_CALL                                         'array'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0  $13     
         14        ASSIGN_DIM                                               !1, !3
         15        OP_DATA                                                  $13
         16      > JMP                                                      ->19
   48    17    >   ASSIGN_DIM                                               !1, !3
         18        OP_DATA                                                  !2
   45    19    > > JMP                                                      ->7
         20    >   FE_FREE                                                  $8
   51    21        VERIFY_RETURN_TYPE                                       !1
         22      > RETURN                                                   !1
   52    23*       VERIFY_RETURN_TYPE                                       
         24*     > RETURN                                                   null

End of function array

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Fa5Tk
function name:  __invoke
number of ops:  2
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV_VARIADIC                                    !0      
          1      > RETURN                                                   null

End of function __invoke

End of class ArrayAccess@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.76 ms | 1408 KiB | 15 Q