3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Maps implements Iterator { protected $key, $data; public function __construct() { $key = new stdClass; $value = new stdClass; $key->long = 1.1; $key->lat = 42.0; $value = "New York, NY"; $this->data[] = array($key, $value); $key->long = 2.2; $key->lat = 24.0; $value = "Rochester, NY"; $this->data[] = array($key, $value); } public function key() { return $this->data[0]; } public function current() { return $this->data[1]; } public function next() { next($this->data); } public function valid() { return key($this->data) !== null; } public function rewind() { reset($this->data); } } $maps = new Maps; foreach($maps as $keyMap => $locationMap) { var_dump($keyMap, $locationMap); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/5oYNB
function name:  (null)
number of ops:  14
compiled vars:  !0 = $maps, !1 = $locationMap, !2 = $keyMap
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'maps'
   55     1        NEW                                              $3      'Maps'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   57     4      > FE_RESET_R                                       $6      !0, ->12
          5    > > FE_FETCH_R                                       ~7      $6, !1, ->12
          6    >   ASSIGN                                                   !2, ~7
   58     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   57    11      > JMP                                                      ->5
         12    >   FE_FREE                                                  $6
   59    13      > RETURN                                                   1

Class Maps:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5oYNB
function name:  __construct
number of ops:  27
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $2      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   10     3        NEW                                              $5      'stdClass'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   12     6        ASSIGN_OBJ                                               !0, 'long'
          7        OP_DATA                                                  1.1
   13     8        ASSIGN_OBJ                                               !0, 'lat'
          9        OP_DATA                                                  42
   15    10        ASSIGN                                                   !1, 'New+York%2C+NY'
   17    11        INIT_ARRAY                                       ~13     !0
         12        ADD_ARRAY_ELEMENT                                ~13     !1
         13        FETCH_OBJ_W                                      $11     'data'
         14        ASSIGN_DIM                                               $11
         15        OP_DATA                                                  ~13
   19    16        ASSIGN_OBJ                                               !0, 'long'
         17        OP_DATA                                                  2.2
   20    18        ASSIGN_OBJ                                               !0, 'lat'
         19        OP_DATA                                                  24
   22    20        ASSIGN                                                   !1, 'Rochester%2C+NY'
   24    21        INIT_ARRAY                                       ~19     !0
         22        ADD_ARRAY_ELEMENT                                ~19     !1
         23        FETCH_OBJ_W                                      $17     'data'
         24        ASSIGN_DIM                                               $17
         25        OP_DATA                                                  ~19
   26    26      > RETURN                                                   null

End of function __construct

Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5oYNB
function name:  key
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1        FETCH_DIM_R                                      ~1      ~0, 0
          2      > RETURN                                                   ~1
   31     3*     > RETURN                                                   null

End of function key

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5oYNB
function name:  current
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   FETCH_OBJ_R                                      ~0      'data'
          1        FETCH_DIM_R                                      ~1      ~0, 1
          2      > RETURN                                                   ~1
   36     3*     > RETURN                                                   null

End of function current

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

End of function next

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

End of function valid

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

End of function rewind

End of class Maps.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.48 ms | 1404 KiB | 21 Q