3v4l.org

run code in 300+ PHP versions simultaneously
<?php class values implements Iterator{ private $_data = null; // array or object private $_keys = array(); private $_key = false; public function __construct($data = null){ $this->_data = $data; } public function current(){ return $this->{$this->_key}; } public function key(){ return $this->_key; } public function next(){ $this->_key = next($this->_keys); } public function rewind(){ $this->_keys = array(); foreach ($this->_data as $k => $v){ $this->_keys[] = $k; } $this->_key = reset($this->_keys); } public function valid(){ if (false === $this->_key){ return false; } return isset($this->{$this->_key}); } } $values = new values(new DateTime()); foreach($values as $k => $v) { var_dump($k, $v); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/lAdoP
function name:  (null)
number of ops:  17
compiled vars:  !0 = $values, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'values'
   34     1        NEW                                              $3      'values'
          2        NEW                                              $4      'DateTime'
          3        DO_FCALL                                      0          
          4        SEND_VAR_NO_REF_EX                                       $4
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   36     7      > FE_RESET_R                                       $8      !0, ->15
          8    > > FE_FETCH_R                                       ~9      $8, !1, ->15
          9    >   ASSIGN                                                   !2, ~9
   37    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   36    14      > JMP                                                      ->8
         15    >   FE_FREE                                                  $8
   38    16      > RETURN                                                   1

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

End of function __construct

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lAdoP
function name:  current
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      '_key'
          1        FETCH_OBJ_R                                      ~1      ~0
          2      > RETURN                                                   ~1
   12     3*     > 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/lAdoP
function name:  key
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                      ~0      '_key'
          1      > RETURN                                                   ~0
   15     2*     > 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/lAdoP
function name:  next
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $1      '_keys'
          2        SEND_REF                                                 $1
          3        DO_ICALL                                         $2      
          4        ASSIGN_OBJ                                               '_key'
          5        OP_DATA                                                  $2
   18     6      > RETURN                                                   null

End of function next

Function rewind:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/lAdoP
function name:  rewind
number of ops:  18
compiled vars:  !0 = $v, !1 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN_OBJ                                               '_keys'
          1        OP_DATA                                                  <array>
   21     2        FETCH_OBJ_R                                      ~3      '_data'
          3      > FE_RESET_R                                       $4      ~3, ->10
          4    > > FE_FETCH_R                                       ~5      $4, !0, ->10
          5    >   ASSIGN                                                   !1, ~5
   22     6        FETCH_OBJ_W                                      $7      '_keys'
          7        ASSIGN_DIM                                               $7
          8        OP_DATA                                                  !1
   21     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $4
   24    11        INIT_FCALL                                               'reset'
         12        FETCH_OBJ_W                                      $10     '_keys'
         13        SEND_REF                                                 $10
         14        DO_ICALL                                         $11     
         15        ASSIGN_OBJ                                               '_key'
         16        OP_DATA                                                  $11
   25    17      > RETURN                                                   null

End of function rewind

Function valid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lAdoP
function name:  valid
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_OBJ_R                                      ~0      '_key'
          1        TYPE_CHECK                                    4          ~0
          2      > JMPZ                                                     ~1, ->4
   28     3    > > RETURN                                                   <false>
   30     4    >   FETCH_OBJ_R                                      ~2      '_key'
          5        ISSET_ISEMPTY_PROP_OBJ                           ~3      ~2
          6      > RETURN                                                   ~3
   31     7*     > RETURN                                                   null

End of function valid

End of class values.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.57 ms | 1396 KiB | 19 Q