3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ar implements ArrayAccess { private $storage = []; private $offset = null; public function __construct(array $ar) { $this->storage = array_values($ar); $this->offset = 0; } public function offsetExists($offset) { return $offset <= count($this->storage); } public function offsetGet($offset) { return $this->storage[$offset]; } public function offsetSet($offset, $value) { $this->storage[$offset] = $value; } public function offsetUnset($offset) { unset($this->storage[$offset]); $this->storage = array_values($this->storage); } } $obj = new Ar([1,2,3,4,5,6,7]); var_dump(array_values($obj));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Rh7kg
function name:  (null)
number of ops:  12
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'ar'
   35     1        NEW                                              $1      'Ar'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   37     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'array_values'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Class Ar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Rh7kg
function name:  __construct
number of ops:  9
compiled vars:  !0 = $ar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'array_values'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN_OBJ                                               'storage'
          5        OP_DATA                                                  $2
   10     6        ASSIGN_OBJ                                               'offset'
          7        OP_DATA                                                  0
   11     8      > RETURN                                                   null

End of function __construct

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Rh7kg
function name:  offsetExists
number of ops:  6
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        FETCH_OBJ_R                                      ~1      'storage'
          2        COUNT                                            ~2      ~1
          3        IS_SMALLER_OR_EQUAL                              ~3      !0, ~2
          4      > RETURN                                                   ~3
   16     5*     > RETURN                                                   null

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Rh7kg
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        FETCH_OBJ_R                                      ~1      'storage'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
   21     4*     > 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/Rh7kg
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        FETCH_OBJ_W                                      $2      'storage'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   26     5      > 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/Rh7kg
function name:  offsetUnset
number of ops:  10
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        FETCH_OBJ_UNSET                                  $1      'storage'
          2        UNSET_DIM                                                $1, !0
   31     3        INIT_FCALL                                               'array_values'
          4        FETCH_OBJ_R                                      ~3      'storage'
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
          7        ASSIGN_OBJ                                               'storage'
          8        OP_DATA                                                  $4
   32     9      > RETURN                                                   null

End of function offsetunset

End of class Ar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.2 ms | 1400 KiB | 17 Q