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 */ var_dump($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 = 55
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 55
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 49, Position 2 = 53
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 54
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 54
Branch analysis from position: 53
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
filename:       /in/d0R8o
function name:  (null)
number of ops:  57
compiled vars:  !0 = $dir, !1 = $flags, !2 = $it, !3 = $rit, !4 = $iterator, !5 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, '%2Ftmp%2Ftest'
    7     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
    8     8        INIT_FCALL                                               'touch'
          9        CONCAT                                           ~9      !0, '%2F.anyhidden'
         10        SEND_VAL                                                 ~9
         11        DO_ICALL                                                 
    9    12        BEGIN_SILENCE                                    ~11     
         13        INIT_FCALL                                               'mkdir'
         14        CONCAT                                           ~12     !0, '%2Fmydir'
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                                 
         17        END_SILENCE                                              ~11
   24    18        ASSIGN                                                   !1, 0
   30    19        NEW                                              $15     'RecursiveDirectoryIterator'
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !2, $15
   32    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
   33    30        NEW                                              $21     'DirFilterIterator'
         31        SEND_VAR_EX                                              !3
         32        DO_FCALL                                      0          
         33        ASSIGN                                                   !3, $21
   34    34        NEW                                              $24     'AppendIterator'
         35        DO_FCALL                                      0          
         36        ASSIGN                                                   !4, $24
   35    37        INIT_METHOD_CALL                                         !4, 'append'
         38        SEND_VAR_EX                                              !3
         39        DO_FCALL                                      0          
   37    40      > FE_RESET_R                                       $28     !4, ->55
         41    > > FE_FETCH_R                                               $28, !5, ->55
   41    42    >   INIT_FCALL                                               'var_dump'
         43        SEND_VAR                                                 !5
         44        DO_ICALL                                                 
   42    45        INIT_METHOD_CALL                                         !5, 'getBasename'
         46        DO_FCALL                                      0  $30     
         47        IS_NOT_IDENTICAL                                 ~31     $30, '.'
         48      > JMPZ_EX                                          ~31     ~31, ->53
         49    >   INIT_METHOD_CALL                                         !5, 'getBasename'
         50        DO_FCALL                                      0  $32     
         51        IS_NOT_IDENTICAL                                 ~33     $32, '..'
         52        BOOL                                             ~31     ~33
         53    > > JMPZ                                                     ~31, ->54
   37    54    > > JMP                                                      ->41
         55    >   FE_FREE                                                  $28
   46    56      > 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/d0R8o
function name:  accept
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     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
   17     5    > > RETURN                                                   <true>
   19     6    > > RETURN                                                   <false>
   20     7*     > RETURN                                                   null

End of function accept

End of class DirFilterIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.28 ms | 1400 KiB | 19 Q