3v4l.org

run code in 300+ PHP versions simultaneously
<?php class it implements OuterIterator { private $inner; public function __construct(Iterator $inner) { $this->inner = $inner; } public function getInnerIterator() { echo "++ inner\n"; return $this->inner; } public function next() { echo "-- Next\n"; return $this->inner->next(); } public function current() { echo "-- Current\n"; return $this->inner->current(); } public function key() { echo "-- Key\n"; return $this->inner->key(); } public function rewind() { echo "-- Rewind\n"; return $this->inner->rewind(); } public function valid() { echo "-- Valid\n"; return $this->inner->valid(); } } $it = new it(new ArrayIterator(array("foo", "bar"))); foreach ($it as $key => $value) { echo $value."\n"; } $array_a = new ArrayIterator(array('a', 'b', 'c')); $array_b = new ArrayIterator(array('d', 'e', 'f')); $iterator = new AppendIterator; $iterator->append($array_a); $iterator->append($array_b); foreach ($iterator as $current) { echo $current; if ($current=='e') { $iterator->append(new ArrayIterator('g','h')); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 45
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 45
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 44
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 44
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
Branch analysis from position: 14
filename:       /in/h4XAh
function name:  (null)
number of ops:  47
compiled vars:  !0 = $it, !1 = $value, !2 = $key, !3 = $array_a, !4 = $array_b, !5 = $iterator, !6 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'it'
   45     1        NEW                                              $7      'it'
          2        NEW                                              $8      'ArrayIterator'
          3        SEND_VAL_EX                                              <array>
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $8
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $7
   46     8      > FE_RESET_R                                       $12     !0, ->14
          9    > > FE_FETCH_R                                       ~13     $12, !1, ->14
         10    >   ASSIGN                                                   !2, ~13
   47    11        CONCAT                                           ~15     !1, '%0A'
         12        ECHO                                                     ~15
   46    13      > JMP                                                      ->9
         14    >   FE_FREE                                                  $12
   52    15        NEW                                              $16     'ArrayIterator'
         16        SEND_VAL_EX                                              <array>
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !3, $16
   53    19        NEW                                              $19     'ArrayIterator'
         20        SEND_VAL_EX                                              <array>
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !4, $19
   55    23        NEW                                              $22     'AppendIterator'
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !5, $22
   56    26        INIT_METHOD_CALL                                         !5, 'append'
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0          
   57    29        INIT_METHOD_CALL                                         !5, 'append'
         30        SEND_VAR_EX                                              !4
         31        DO_FCALL                                      0          
   59    32      > FE_RESET_R                                       $27     !5, ->45
         33    > > FE_FETCH_R                                               $27, !6, ->45
   60    34    >   ECHO                                                     !6
   61    35        IS_EQUAL                                                 !6, 'e'
         36      > JMPZ                                                     ~28, ->44
   62    37    >   INIT_METHOD_CALL                                         !5, 'append'
         38        NEW                                              $29     'ArrayIterator'
         39        SEND_VAL_EX                                              'g'
         40        SEND_VAL_EX                                              'h'
         41        DO_FCALL                                      0          
         42        SEND_VAR_NO_REF_EX                                       $29
         43        DO_FCALL                                      0          
   59    44    > > JMP                                                      ->33
         45    >   FE_FREE                                                  $27
   64    46      > RETURN                                                   1

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

End of function __construct

Function getinneriterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h4XAh
function name:  getInnerIterator
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     '%2B%2B+inner%0A'
   13     1        FETCH_OBJ_R                                      ~0      'inner'
          2      > RETURN                                                   ~0
   14     3*     > RETURN                                                   null

End of function getinneriterator

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h4XAh
function name:  next
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                     '--+Next%0A'
   18     1        FETCH_OBJ_R                                      ~0      'inner'
          2        INIT_METHOD_CALL                                         ~0, 'next'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   19     5*     > RETURN                                                   null

End of function next

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h4XAh
function name:  current
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ECHO                                                     '--+Current%0A'
   24     1        FETCH_OBJ_R                                      ~0      'inner'
          2        INIT_METHOD_CALL                                         ~0, 'current'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   25     5*     > 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/h4XAh
function name:  key
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ECHO                                                     '--+Key%0A'
   30     1        FETCH_OBJ_R                                      ~0      'inner'
          2        INIT_METHOD_CALL                                         ~0, 'key'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   31     5*     > RETURN                                                   null

End of function key

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/h4XAh
function name:  rewind
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ECHO                                                     '--+Rewind%0A'
   36     1        FETCH_OBJ_R                                      ~0      'inner'
          2        INIT_METHOD_CALL                                         ~0, 'rewind'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   37     5*     > 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/h4XAh
function name:  valid
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   ECHO                                                     '--+Valid%0A'
   42     1        FETCH_OBJ_R                                      ~0      'inner'
          2        INIT_METHOD_CALL                                         ~0, 'valid'
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   43     5*     > RETURN                                                   null

End of function valid

End of class it.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.98 ms | 1394 KiB | 13 Q