3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dir = '/tmp/test'; @mkdir($dir, 0777, true); touch($dir . '/.anyhidden'); // like .DS_Store on mac... @mkdir($dir . '/mydir'); class DirFilterIterator extends \FilterIterator { public function accept() { if ($this->current()->isDir()) { return true; } return false; } } $flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO; $flags |= \FilesystemIterator::SKIP_DOTS; // uncomment this line to see the bug? $it = new \RecursiveDirectoryIterator($dir, $flags); $rit = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::SELF_FIRST, 0); $rit = new DirFilterIterator($rit); $iterator = new \AppendIterator(); $iterator->append($rit); foreach ($iterator as $f) { /** * @var \SplFileInfo $f */ if ('.' !== $f->getBasename() && '..' !== $f->getBasename()) { echo sprintf('pathname: %s, filename: %s', $f->getPathname(), $f->getFilename()); echo '<br />'; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 64
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 64
Branch analysis from position: 43
2 jumps found. (Code = 46) Position 1 = 47, Position 2 = 51
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 63
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 63
Branch analysis from position: 51
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
filename:       /in/2Xc4J
function name:  (null)
number of ops:  66
compiled vars:  !0 = $dir, !1 = $flags, !2 = $it, !3 = $rit, !4 = $iterator, !5 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2Ftmp%2Ftest'
    4     1        BEGIN_SILENCE                                    ~7      
          2        INIT_FCALL                                               'mkdir'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 511
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                                 
          7        END_SILENCE                                              ~7
    5     8        INIT_FCALL                                               'touch'
          9        CONCAT                                           ~9      !0, '%2F.anyhidden'
         10        SEND_VAL                                                 ~9
         11        DO_ICALL                                                 
    6    12        BEGIN_SILENCE                                    ~11     
         13        INIT_FCALL                                               'mkdir'
         14        CONCAT                                           ~12     !0, '%2Fmydir'
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                                 
         17        END_SILENCE                                              ~11
   21    18        ASSIGN                                                   !1, 0
   24    19        ASSIGN_OP                                     9          !1, 4096
   27    20        NEW                                              $16     'RecursiveDirectoryIterator'
         21        SEND_VAR_EX                                              !0
         22        SEND_VAR_EX                                              !1
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !2, $16
   29    25        NEW                                              $19     'RecursiveIteratorIterator'
         26        SEND_VAR_EX                                              !2
         27        SEND_VAL_EX                                              1
         28        SEND_VAL_EX                                              0
         29        DO_FCALL                                      0          
         30        ASSIGN                                                   !3, $19
   30    31        NEW                                              $22     'DirFilterIterator'
         32        SEND_VAR_EX                                              !3
         33        DO_FCALL                                      0          
         34        ASSIGN                                                   !3, $22
   31    35        NEW                                              $25     'AppendIterator'
         36        DO_FCALL                                      0          
         37        ASSIGN                                                   !4, $25
   32    38        INIT_METHOD_CALL                                         !4, 'append'
         39        SEND_VAR_EX                                              !3
         40        DO_FCALL                                      0          
   34    41      > FE_RESET_R                                       $29     !4, ->64
         42    > > FE_FETCH_R                                               $29, !5, ->64
   38    43    >   INIT_METHOD_CALL                                         !5, 'getBasename'
         44        DO_FCALL                                      0  $30     
         45        IS_NOT_IDENTICAL                                 ~31     $30, '.'
         46      > JMPZ_EX                                          ~31     ~31, ->51
         47    >   INIT_METHOD_CALL                                         !5, 'getBasename'
         48        DO_FCALL                                      0  $32     
         49        IS_NOT_IDENTICAL                                 ~33     $32, '..'
         50        BOOL                                             ~31     ~33
         51    > > JMPZ                                                     ~31, ->63
   39    52    >   INIT_FCALL                                               'sprintf'
         53        SEND_VAL                                                 'pathname%3A+%25s%2C+filename%3A+%25s'
         54        INIT_METHOD_CALL                                         !5, 'getPathname'
         55        DO_FCALL                                      0  $34     
         56        SEND_VAR                                                 $34
         57        INIT_METHOD_CALL                                         !5, 'getFilename'
         58        DO_FCALL                                      0  $35     
         59        SEND_VAR                                                 $35
         60        DO_ICALL                                         $36     
         61        ECHO                                                     $36
   40    62        ECHO                                                     '%3Cbr+%2F%3E'
   34    63    > > JMP                                                      ->42
         64    >   FE_FREE                                                  $29
   42    65      > RETURN                                                   1

Class DirFilterIterator:
Function accept:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Xc4J
function name:  accept
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_METHOD_CALL                                         'current'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'isDir'
          3        DO_FCALL                                      0  $1      
          4      > JMPZ                                                     $1, ->6
   14     5    > > RETURN                                                   <true>
   16     6    > > RETURN                                                   <false>
   17     7*     > RETURN                                                   null

End of function accept

End of class DirFilterIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.88 ms | 1400 KiB | 19 Q