3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DoctorFilter extends FilterIterator { public function accept(): bool { $obj = $this->getInnerIterator()->current(); return is_string($obj) && str_starts_with($obj, 'Dr.'); } } $people = [ 'Dr. Jekyll', 'Mr. Hyde', // This item will be removed 'Dr. Frankenstein', ]; foreach (new DoctorFilter(new ArrayIterator($people)) as $item) { echo $item.PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/ieTAP
function name:  (null)
number of ops:  14
compiled vars:  !0 = $people, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   19     1        NEW                                              $3      'DoctorFilter'
          2        NEW                                              $4      'ArrayIterator'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $4
          6        DO_FCALL                                      0          
          7      > FE_RESET_R                                       $7      $3, ->12
          8    > > FE_FETCH_R                                               $7, !1, ->12
   20     9    >   CONCAT                                           ~8      !1, '%0A'
         10        ECHO                                                     ~8
   19    11      > JMP                                                      ->8
         12    >   FE_FREE                                                  $7
   21    13      > RETURN                                                   1

Class DoctorFilter:
Function accept:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/ieTAP
function name:  accept
number of ops:  16
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_METHOD_CALL                                         'getInnerIterator'
          1        DO_FCALL                                      0  $1      
          2        INIT_METHOD_CALL                                         $1, 'current'
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
    9     5        TYPE_CHECK                                   64  ~4      !0
          6      > JMPZ_EX                                          ~4      ~4, ->12
          7    >   INIT_FCALL                                               'str_starts_with'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 'Dr.'
         10        DO_ICALL                                         $5      
         11        BOOL                                             ~4      $5
         12    >   VERIFY_RETURN_TYPE                                       ~4
         13      > RETURN                                                   ~4
   10    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function accept

End of class DoctorFilter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.17 ms | 1068 KiB | 14 Q