3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyIterator implements Iterator { public $var = array(); public function pprrint() {echo implode(',',$this->var);} public function __construct($arra) { if (is_array($arra)) { $this->var = $arra; /* echo implode(',',$arra) ;*/} } /*public function rewind() { echo "rewinding\n"; reset($this->var); }*/ public function current() { $var = current($this->var); echo "current: $var\n"; return $var; } public function key() { $var = key($this->var); echo "key: $var\n"; return $var; } public function next() { $var = next($this->var); echo "next: $var\n"; return $var; } public function valid() { $this->var=$var; echo "valid: $var\n"; return $var; } } $values = array(1,2,3); $it = new MyIterator($values); $it->pprrint(); foreach($it as $key => $value) { print "$key => $value\n"; } echo "\n"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/PLaJv
function name:  (null)
number of ops:  20
compiled vars:  !0 = $values, !1 = $it, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'myiterator'
   44     1        ASSIGN                                                   !0, <array>
   46     2        NEW                                              $5      'MyIterator'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   47     6        INIT_METHOD_CALL                                         !1, 'pprrint'
          7        DO_FCALL                                      0          
   48     8      > FE_RESET_R                                       $9      !1, ->17
          9    > > FE_FETCH_R                                       ~10     $9, !2, ->17
         10    >   ASSIGN                                                   !3, ~10
   49    11        ROPE_INIT                                     4  ~13     !3
         12        ROPE_ADD                                      1  ~13     ~13, '+%3D%3E+'
         13        ROPE_ADD                                      2  ~13     ~13, !2
         14        ROPE_END                                      3  ~12     ~13, '%0A'
         15        ECHO                                                     ~12
   48    16      > JMP                                                      ->9
         17    >   FE_FREE                                                  $9
   51    18        ECHO                                                     '%0A'
   55    19      > RETURN                                                   1

Class MyIterator:
Function pprrint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PLaJv
function name:  pprrint
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'implode'
          1        SEND_VAL                                                 '%2C'
          2        FETCH_OBJ_R                                      ~0      'var'
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                         $1      
          5        ECHO                                                     $1
          6      > RETURN                                                   null

End of function pprrint

Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
filename:       /in/PLaJv
function name:  __construct
number of ops:  6
compiled vars:  !0 = $arra
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~1, ->5
   10     3    >   ASSIGN_OBJ                                               'var'
          4        OP_DATA                                                  !0
   12     5    > > 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/PLaJv
function name:  current
number of ops:  11
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'current'
          1        FETCH_OBJ_R                                      ~1      'var'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   21     5        ROPE_INIT                                     3  ~5      'current%3A+'
          6        ROPE_ADD                                      1  ~5      ~5, !0
          7        ROPE_END                                      2  ~4      ~5, '%0A'
          8        ECHO                                                     ~4
   22     9      > RETURN                                                   !0
   23    10*     > 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/PLaJv
function name:  key
number of ops:  11
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~1      'var'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   27     5        ROPE_INIT                                     3  ~5      'key%3A+'
          6        ROPE_ADD                                      1  ~5      ~5, !0
          7        ROPE_END                                      2  ~4      ~5, '%0A'
          8        ECHO                                                     ~4
   28     9      > RETURN                                                   !0
   29    10*     > 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/PLaJv
function name:  next
number of ops:  11
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $1      'var'
          2        SEND_REF                                                 $1
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   33     5        ROPE_INIT                                     3  ~5      'next%3A+'
          6        ROPE_ADD                                      1  ~5      ~5, !0
          7        ROPE_END                                      2  ~4      ~5, '%0A'
          8        ECHO                                                     ~4
   34     9      > RETURN                                                   !0
   35    10*     > 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/PLaJv
function name:  valid
number of ops:  8
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   ASSIGN_OBJ                                               'var'
          1        OP_DATA                                                  !0
   39     2        ROPE_INIT                                     3  ~3      'valid%3A+'
          3        ROPE_ADD                                      1  ~3      ~3, !0
          4        ROPE_END                                      2  ~2      ~3, '%0A'
          5        ECHO                                                     ~2
   40     6      > RETURN                                                   !0
   41     7*     > RETURN                                                   null

End of function valid

End of class MyIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.97 ms | 1404 KiB | 21 Q