3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test implements Iterator { private $ar = [ 1, 2, 3 ]; public function toArray() { return $this->ar; } public function rewind() { reset( $this->ar ); } public function valid() { return !is_null( $this->key() ); } public function key() { return key( $this->ar ); } public function current() { return current( $this->ar ); } public function next() { next( $this->ar ); } } $t = new Test; foreach( $t as $key => $value ) { echo "orig: $key: $value\n"; foreach( $t->toArray() as $copyKey => $copyValue ) { echo " copy: $copyKey: $copyValue\n"; } echo "----\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 28
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 25
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 25
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/l96fW
function name:  (null)
number of ops:  30
compiled vars:  !0 = $t, !1 = $value, !2 = $key, !3 = $copyValue, !4 = $copyKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'test'
   33     1        NEW                                              $5      'Test'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $5
   34     4      > FE_RESET_R                                       $8      !0, ->28
          5    > > FE_FETCH_R                                       ~9      $8, !1, ->28
          6    >   ASSIGN                                                   !2, ~9
   35     7        ROPE_INIT                                     5  ~12     'orig%3A+'
          8        ROPE_ADD                                      1  ~12     ~12, !2
          9        ROPE_ADD                                      2  ~12     ~12, '%3A+'
         10        ROPE_ADD                                      3  ~12     ~12, !1
         11        ROPE_END                                      4  ~11     ~12, '%0A'
         12        ECHO                                                     ~11
   36    13        INIT_METHOD_CALL                                         !0, 'toArray'
         14        DO_FCALL                                      0  $15     
         15      > FE_RESET_R                                       $16     $15, ->25
         16    > > FE_FETCH_R                                       ~17     $16, !3, ->25
         17    >   ASSIGN                                                   !4, ~17
   37    18        ROPE_INIT                                     5  ~20     '++copy%3A+'
         19        ROPE_ADD                                      1  ~20     ~20, !4
         20        ROPE_ADD                                      2  ~20     ~20, '%3A+'
         21        ROPE_ADD                                      3  ~20     ~20, !3
         22        ROPE_END                                      4  ~19     ~20, '%0A'
         23        ECHO                                                     ~19
   36    24      > JMP                                                      ->16
         25    >   FE_FREE                                                  $16
   39    26        ECHO                                                     '----%0A'
   34    27      > JMP                                                      ->5
         28    >   FE_FREE                                                  $8
   40    29      > RETURN                                                   1

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

End of function toarray

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l96fW
function name:  rewind
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'reset'
          1        FETCH_OBJ_W                                      $0      'ar'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                                 
   14     4      > 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/l96fW
function name:  valid
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_METHOD_CALL                                         'key'
          1        DO_FCALL                                      0  $0      
          2        TYPE_CHECK                                    2  ~1      $0
          3        BOOL_NOT                                         ~2      ~1
          4      > RETURN                                                   ~2
   18     5*     > RETURN                                                   null

End of function valid

Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l96fW
function name:  key
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~0      'ar'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   22     5*     > 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/l96fW
function name:  current
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'current'
          1        FETCH_OBJ_R                                      ~0      'ar'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   26     5*     > 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/l96fW
function name:  next
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $0      'ar'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                                 
   30     4      > RETURN                                                   null

End of function next

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.02 ms | 1022 KiB | 17 Q