3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection implements \ArrayAccess, \Iterator { private $_array = array(); public function __invoke() { return $this->_array; } public function offsetExists($offset) { return array_key_exists($offset, $this->_array); } public function offsetGet($offset) { return $this->_array[$offset]; } public function offsetSet($offset, $value) { $this->_array[$offset] = $value; } public function offsetUnset($offset) { unset($this->_array[$offset]); } public function current() { return current($this->_array); } public function key() { return key($this->_array); } public function next() { return next($this->_array); } public function rewind() { return reset($this->_array); } public function valid() { return !is_null(key($this->_array)); } } $a = new Collection(); $a['alpha'] = 'blah'; $a['beta'] = 'yada'; $a['gamma'] = 'woot'; var_dump(current($a)); var_dump(next($a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KpE85
function name:  (null)
number of ops:  23
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'collection'
   20     1        NEW                                              $1      'Collection'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   21     4        ASSIGN_DIM                                               !0, 'alpha'
          5        OP_DATA                                                  'blah'
   22     6        ASSIGN_DIM                                               !0, 'beta'
          7        OP_DATA                                                  'yada'
   23     8        ASSIGN_DIM                                               !0, 'gamma'
          9        OP_DATA                                                  'woot'
   25    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'current'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                                 
   27    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'next'
         18        SEND_REF                                                 !0
         19        DO_ICALL                                         $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Class Collection:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KpE85
function name:  __invoke
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_OBJ_R                                      ~0      '_array'
          1      > RETURN                                                   ~0
          2*     > RETURN                                                   null

End of function __invoke

Function offsetexists:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KpE85
function name:  offsetExists
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      '_array'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3      > RETURN                                                   ~2
          4*     > 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/KpE85
function name:  offsetGet
number of ops:  5
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      '_array'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3      > RETURN                                                   ~2
          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/KpE85
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_OBJ_W                                      $2      '_array'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
          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/KpE85
function name:  offsetUnset
number of ops:  4
compiled vars:  !0 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        FETCH_OBJ_UNSET                                  $1      '_array'
          2        UNSET_DIM                                                $1, !0
          3      > RETURN                                                   null

End of function offsetunset

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KpE85
function name:  current
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'current'
          1        FETCH_OBJ_R                                      ~0      '_array'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function current

Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KpE85
function name:  key
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~0      '_array'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function key

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KpE85
function name:  next
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $0      '_array'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function next

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KpE85
function name:  rewind
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'reset'
          1        FETCH_OBJ_W                                      $0      '_array'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of function rewind

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KpE85
function name:  valid
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~0      '_array'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4        TYPE_CHECK                                    2  ~2      $1
          5        BOOL_NOT                                         ~3      ~2
          6      > RETURN                                                   ~3
          7*     > RETURN                                                   null

End of function valid

End of class Collection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.24 ms | 1011 KiB | 18 Q