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 = 41, Position 2 = 63
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 63
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 46, Position 2 = 50
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 62
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 62
Branch analysis from position: 50
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
filename:       /in/RjoTg
function name:  (null)
number of ops:  65
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
   27    19        NEW                                              $15     'RecursiveDirectoryIterator'
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !2, $15
   29    24        NEW                                              $18     'RecursiveIteratorIterator'
         25        SEND_VAR_EX                                              !2
         26        SEND_VAL_EX                                              1
         27        SEND_VAL_EX                                              0
         28        DO_FCALL                                      0          
         29        ASSIGN                                                   !3, $18
   30    30        NEW                                              $21     'DirFilterIterator'
         31        SEND_VAR_EX                                              !3
         32        DO_FCALL                                      0          
         33        ASSIGN                                                   !3, $21
   31    34        NEW                                              $24     'AppendIterator'
         35        DO_FCALL                                      0          
         36        ASSIGN                                                   !4, $24
   32    37        INIT_METHOD_CALL                                         !4, 'append'
         38        SEND_VAR_EX                                              !3
         39        DO_FCALL                                      0          
   34    40      > FE_RESET_R                                       $28     !4, ->63
         41    > > FE_FETCH_R                                               $28, !5, ->63
   38    42    >   INIT_METHOD_CALL                                         !5, 'getBasename'
         43        DO_FCALL                                      0  $29     
         44        IS_NOT_IDENTICAL                                 ~30     $29, '.'
         45      > JMPZ_EX                                          ~30     ~30, ->50
         46    >   INIT_METHOD_CALL                                         !5, 'getBasename'
         47        DO_FCALL                                      0  $31     
         48        IS_NOT_IDENTICAL                                 ~32     $31, '..'
         49        BOOL                                             ~30     ~32
         50    > > JMPZ                                                     ~30, ->62
   39    51    >   INIT_FCALL                                               'sprintf'
         52        SEND_VAL                                                 'pathname%3A+%25s%2C+filename%3A+%25s'
         53        INIT_METHOD_CALL                                         !5, 'getPathname'
         54        DO_FCALL                                      0  $33     
         55        SEND_VAR                                                 $33
         56        INIT_METHOD_CALL                                         !5, 'getFilename'
         57        DO_FCALL                                      0  $34     
         58        SEND_VAR                                                 $34
         59        DO_ICALL                                         $35     
         60        ECHO                                                     $35
   40    61        ECHO                                                     '%3Cbr+%2F%3E'
   34    62    > > JMP                                                      ->41
         63    >   FE_FREE                                                  $28
   42    64      > 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/RjoTg
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:
147.64 ms | 1400 KiB | 19 Q