3v4l.org

run code in 300+ PHP versions simultaneously
<?php class It implements Iterator { private $arr = [1,2,3]; public function key() { echo __METHOD__ . "\n"; return key($this->arr); } public function current() { echo __METHOD__ . "\n"; return current($this->arr); } public function rewind() { echo __METHOD__ . "\n"; reset($this->arr); } public function next() { echo __METHOD__ . "\n"; next($this->arr); } public function valid() { echo __METHOD__ . "\n"; return key($this->arr) === null; } } $it = new It; foreach ($it as $k => $v) {}
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/dOr1H
function name:  (null)
number of ops:  10
compiled vars:  !0 = $it, !1 = $v, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'it'
   38     1        NEW                                              $3      'It'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   39     4      > FE_RESET_R                                       $6      !0, ->8
          5    > > FE_FETCH_R                                       ~7      $6, !1, ->8
          6    >   ASSIGN                                                   !2, ~7
          7      > JMP                                                      ->5
          8    >   FE_FREE                                                  $6
          9      > RETURN                                                   1

Class It:
Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dOr1H
function name:  key
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'It%3A%3Akey%0A'
   10     1        INIT_FCALL                                               'key'
          2        FETCH_OBJ_R                                      ~0      'arr'
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   11     6*     > 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/dOr1H
function name:  current
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ECHO                                                     'It%3A%3Acurrent%0A'
   16     1        INIT_FCALL                                               'current'
          2        FETCH_OBJ_R                                      ~0      'arr'
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   17     6*     > RETURN                                                   null

End of function current

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

End of function rewind

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dOr1H
function name:  next
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   ECHO                                                     'It%3A%3Anext%0A'
   28     1        INIT_FCALL                                               'next'
          2        FETCH_OBJ_W                                      $0      'arr'
          3        SEND_REF                                                 $0
          4        DO_ICALL                                                 
   29     5      > 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/dOr1H
function name:  valid
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ECHO                                                     'It%3A%3Avalid%0A'
   34     1        INIT_FCALL                                               'key'
          2        FETCH_OBJ_R                                      ~0      'arr'
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5        TYPE_CHECK                                    2  ~2      $1
          6      > RETURN                                                   ~2
   35     7*     > RETURN                                                   null

End of function valid

End of class It.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.54 ms | 1400 KiB | 21 Q