3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayFoo implements ArrayAccess { public $data; public function __construct(array $data) { $this->data = $data; } public function offsetGet($index) { if (is_array($index)) { $temp = $this->data; foreach ($index as $key) { if (!isset($temp[$key])) return null; else $temp = $temp[$key]; } return $temp; } else { if (isset($this->data[$index])) return $this->data[$index]; else return null; } } public function offsetSet($index, $value) { } public function offsetExists($index) { } public function offsetUnset($index) { } } $tripla = new ArrayFoo(array( 'one' => array( 'does' => array( 'not' => array( 'simply' => array( 'walk' => array( 'into' => array( 'mordor' => 'Boromir' ) ) ) ) ) ) )); var_dump($tripla[array('one', 'does', 'not', 'simply', 'walk', 'into', 'mordor')]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/agSMb
function name:  (null)
number of ops:  10
compiled vars:  !0 = $tripla
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'arrayfoo'
   41     1        NEW                                              $1      'ArrayFoo'
   48     2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
   41     4        ASSIGN                                                   !0, $1
   57     5        INIT_FCALL                                               'var_dump'
          6        FETCH_DIM_R                                      ~4      !0, <array>
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

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

End of function __construct

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/agSMb
function name:  offsetGet
number of ops:  28
compiled vars:  !0 = $index, !1 = $temp, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~3, ->19
   16     3    >   FETCH_OBJ_R                                      ~4      'data'
          4        ASSIGN                                                   !1, ~4
   17     5      > FE_RESET_R                                       $6      !0, ->16
          6    > > FE_FETCH_R                                               $6, !2, ->16
   19     7    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !1, !2
          8        BOOL_NOT                                         ~8      ~7
          9      > JMPZ                                                     ~8, ->13
   20    10    >   FE_FREE                                                  $6
         11      > RETURN                                                   null
         12*       JMP                                                      ->15
   22    13    >   FETCH_DIM_R                                      ~9      !1, !2
         14        ASSIGN                                                   !1, ~9
   17    15      > JMP                                                      ->6
         16    >   FE_FREE                                                  $6
   25    17      > RETURN                                                   !1
         18*       JMP                                                      ->27
   29    19    >   FETCH_OBJ_IS                                     ~11     'data'
         20        ISSET_ISEMPTY_DIM_OBJ                         0          ~11, !0
         21      > JMPZ                                                     ~12, ->26
   30    22    >   FETCH_OBJ_R                                      ~13     'data'
         23        FETCH_DIM_R                                      ~14     ~13, !0
         24      > RETURN                                                   ~14
         25*       JMP                                                      ->27
   32    26    > > RETURN                                                   null
   34    27*     > RETURN                                                   null

End of function offsetget

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

End of function offsetset

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

End of function offsetexists

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

End of function offsetunset

End of class ArrayFoo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157 ms | 1392 KiB | 15 Q