3v4l.org

run code in 300+ PHP versions simultaneously
<?php class xiter extends ArrayIterator { public function as_array() { var_dump(__METHOD__); return iterator_to_array($this); } } class fiter extends FilterIterator { public function accept() { return $this->getInnerIterator()->current() % 2 == 0; } } $iter = new xiter(array(1, 2, 3, 4)); $fiter = new fiter($iter); foreach ($iter as $i) var_dump($i); foreach ($fiter as $i) var_dump($i); var_dump($iter->as_array()); var_dump($fiter->as_array()); var_dump($fiter->as_array2());
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 = 16, Position 2 = 21
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 14
filename:       /in/QLpk8
function name:  (null)
number of ops:  38
compiled vars:  !0 = $iter, !1 = $fiter, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $3      'xiter'
          1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   19     4        NEW                                              $6      'fiter'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   21     8      > FE_RESET_R                                       $9      !0, ->14
          9    > > FE_FETCH_R                                               $9, !2, ->14
         10    >   INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
         13      > JMP                                                      ->9
         14    >   FE_FREE                                                  $9
   22    15      > FE_RESET_R                                       $11     !1, ->21
         16    > > FE_FETCH_R                                               $11, !2, ->21
         17    >   INIT_FCALL                                               'var_dump'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                                 
         20      > JMP                                                      ->16
         21    >   FE_FREE                                                  $11
   24    22        INIT_FCALL                                               'var_dump'
         23        INIT_METHOD_CALL                                         !0, 'as_array'
         24        DO_FCALL                                      0  $13     
         25        SEND_VAR                                                 $13
         26        DO_ICALL                                                 
   25    27        INIT_FCALL                                               'var_dump'
         28        INIT_METHOD_CALL                                         !1, 'as_array'
         29        DO_FCALL                                      0  $15     
         30        SEND_VAR                                                 $15
         31        DO_ICALL                                                 
   26    32        INIT_FCALL                                               'var_dump'
         33        INIT_METHOD_CALL                                         !1, 'as_array2'
         34        DO_FCALL                                      0  $17     
         35        SEND_VAR                                                 $17
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Class xiter:
Function as_array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QLpk8
function name:  as_array
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 'xiter%3A%3Aas_array'
          2        DO_ICALL                                                 
    7     3        INIT_FCALL                                               'iterator_to_array'
          4        FETCH_THIS                                       ~1      
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $2      
          7      > RETURN                                                   $2
    8     8*     > RETURN                                                   null

End of function as_array

End of class xiter.

Class fiter:
Function accept:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QLpk8
function name:  accept
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_METHOD_CALL                                         'getInnerIterator'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'current'
          3        DO_FCALL                                      0  $1      
          4        MOD                                              ~2      $1, 2
          5        IS_EQUAL                                         ~3      ~2, 0
          6      > RETURN                                                   ~3
   15     7*     > RETURN                                                   null

End of function accept

End of class fiter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.25 ms | 1400 KiB | 17 Q