3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo implements ArrayAccess { protected $_values = ["bar" => 1]; public function offsetExists($offset) { return array_key_exists($offset, $this->_values); } public function offsetGet($offset) { return $this->offsetExists($offset) ? $this->_values[$offset]:NULL; } public function offsetSet($offset, $value) { $this->_values[$offset] = $value; } public function offsetUnset($offset) { if ($this->offsetExists($offset)) { unset($this->_values[$offset]); } } } $a = new Foo(); foreach ($a as $key => $value) { echo "key: $key, value: $value"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/8H8vR
function name:  (null)
number of ops:  15
compiled vars:  !0 = $a, !1 = $value, !2 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'foo'
   25     1        NEW                                                  $3      'Foo'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $3
   27     4      > FE_RESET_R                                           $6      !0, ->13
          5    > > FE_FETCH_R                                           ~7      $6, !1, ->13
          6    >   ASSIGN                                                       !2, ~7
   28     7        ROPE_INIT                                         4  ~10     'key%3A+'
          8        ROPE_ADD                                          1  ~10     ~10, !2
          9        ROPE_ADD                                          2  ~10     ~10, '%2C+value%3A+'
         10        ROPE_END                                          3  ~9      ~10, !1
         11        ECHO                                                         ~9
   27    12      > JMP                                                          ->5
         13    >   FE_FREE                                                      $6
   29    14      > RETURN                                                       1

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

End of function offsetexists

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8H8vR
function name:  offsetGet
number of ops:  12
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   12     1        INIT_METHOD_CALL                                             'offsetExists'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $1      
          4      > JMPZ                                                         $1, ->9
          5    >   FETCH_OBJ_R                                          ~2      '_values'
          6        FETCH_DIM_R                                          ~3      ~2, !0
          7        QM_ASSIGN                                            ~4      ~3
          8      > JMP                                                          ->10
          9    >   QM_ASSIGN                                            ~4      null
         10    > > RETURN                                                       ~4
   13    11*     > 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/8H8vR
function name:  offsetSet
number of ops:  6
compiled vars:  !0 = $offset, !1 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   16     2        FETCH_OBJ_W                                          $2      '_values'
          3        ASSIGN_DIM                                                   $2, !0
          4        OP_DATA                                                      !1
   17     5      > RETURN                                                       null

End of function offsetset

Function offsetunset:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/8H8vR
function name:  offsetUnset
number of ops:  8
compiled vars:  !0 = $offset
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   RECV                                                 !0      
   20     1        INIT_METHOD_CALL                                             'offsetExists'
          2        SEND_VAR_EX                                                  !0
          3        DO_FCALL                                          0  $1      
          4      > JMPZ                                                         $1, ->7
   21     5    >   FETCH_OBJ_UNSET                                      $2      '_values'
          6        UNSET_DIM                                                    $2, !0
   23     7    > > RETURN                                                       null

End of function offsetunset

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
209.12 ms | 3395 KiB | 13 Q