3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tempdir($dir=false,$prefix='php') { $tempfile = tempnam(sys_get_temp_dir(),''); if (file_exists($tempfile)) { unlink($tempfile); } mkdir($tempfile); if (is_dir($tempfile)) { return $tempfile; } } function getFileCount($path) { $size = 0; $files = scandir($path); foreach($files as $t) { if ($t[0] == '.') { continue; } $name = rtrim($path, '/') . '/' . $t; if (is_dir($name)) { $size += getFileCount(rtrim($path, '/') . '/' . $t); } else { $size++; unlink($name); } } return $size; } $directory = dirname(__FILE__)."/tgz"; $iterator = new DirectoryIterator($directory); $files = array(); foreach ($iterator as $fileinfo) { if ($fileinfo->isFile()) { $files[$fileinfo->getPathname()] = $fileinfo->getFilename(); } } ksort($files); foreach ($files as $path => $file) { $p = new PharData($path); $tmpdir = tempdir(); $p->extractTo($tmpdir); var_dump($file); var_dump(getFileCount($tmpdir)); rmdir($tmpdir); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 22
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 22
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 21
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 21
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 52
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 52
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
Branch analysis from position: 22
filename:       /in/KUTqI
function name:  (null)
number of ops:  54
compiled vars:  !0 = $directory, !1 = $iterator, !2 = $files, !3 = $fileinfo, !4 = $file, !5 = $path, !6 = $p, !7 = $tmpdir
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'dirname'
          1        SEND_VAL                                                 '%2Fin%2FKUTqI'
          2        DO_ICALL                                         $8      
          3        CONCAT                                           ~9      $8, '%2Ftgz'
          4        ASSIGN                                                   !0, ~9
   33     5        NEW                                              $11     'DirectoryIterator'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $11
   34     9        ASSIGN                                                   !2, <array>
   35    10      > FE_RESET_R                                       $15     !1, ->22
         11    > > FE_FETCH_R                                               $15, !3, ->22
   36    12    >   INIT_METHOD_CALL                                         !3, 'isFile'
         13        DO_FCALL                                      0  $16     
         14      > JMPZ                                                     $16, ->21
   37    15    >   INIT_METHOD_CALL                                         !3, 'getPathname'
         16        DO_FCALL                                      0  $17     
         17        INIT_METHOD_CALL                                         !3, 'getFilename'
         18        DO_FCALL                                      0  $19     
         19        ASSIGN_DIM                                               !2, $17
         20        OP_DATA                                                  $19
   35    21    > > JMP                                                      ->11
         22    >   FE_FREE                                                  $15
   41    23        INIT_FCALL                                               'ksort'
         24        SEND_REF                                                 !2
         25        DO_ICALL                                                 
   42    26      > FE_RESET_R                                       $21     !2, ->52
         27    > > FE_FETCH_R                                       ~22     $21, !4, ->52
         28    >   ASSIGN                                                   !5, ~22
   43    29        NEW                                              $24     'PharData'
         30        SEND_VAR_EX                                              !5
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !6, $24
   44    33        INIT_FCALL                                               'tempdir'
         34        DO_FCALL                                      0  $27     
         35        ASSIGN                                                   !7, $27
   45    36        INIT_METHOD_CALL                                         !6, 'extractTo'
         37        SEND_VAR_EX                                              !7
         38        DO_FCALL                                      0          
   47    39        INIT_FCALL                                               'var_dump'
         40        SEND_VAR                                                 !4
         41        DO_ICALL                                                 
   48    42        INIT_FCALL                                               'var_dump'
         43        INIT_FCALL                                               'getfilecount'
         44        SEND_VAR                                                 !7
         45        DO_FCALL                                      0  $31     
         46        SEND_VAR                                                 $31
         47        DO_ICALL                                                 
   49    48        INIT_FCALL                                               'rmdir'
         49        SEND_VAR                                                 !7
         50        DO_ICALL                                                 
   42    51      > JMP                                                      ->27
         52    >   FE_FREE                                                  $21
   50    53      > RETURN                                                   1

Function tempdir:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/KUTqI
function name:  tempdir
number of ops:  25
compiled vars:  !0 = $dir, !1 = $prefix, !2 = $tempfile
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      <false>
          1        RECV_INIT                                        !1      'php'
    4     2        INIT_FCALL                                               'tempnam'
          3        INIT_FCALL                                               'sys_get_temp_dir'
          4        DO_ICALL                                         $3      
          5        SEND_VAR                                                 $3
          6        SEND_VAL                                                 ''
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !2, $4
    5     9        INIT_FCALL                                               'file_exists'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $6      
         12      > JMPZ                                                     $6, ->16
    6    13    >   INIT_FCALL                                               'unlink'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
    8    16    >   INIT_FCALL                                               'mkdir'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
    9    19        INIT_FCALL                                               'is_dir'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $9      
         22      > JMPZ                                                     $9, ->24
   10    23    > > RETURN                                                   !2
   12    24    > > RETURN                                                   null

End of function tempdir

Function getfilecount:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 39
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 39
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 12
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 34
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/KUTqI
function name:  getFileCount
number of ops:  42
compiled vars:  !0 = $path, !1 = $size, !2 = $files, !3 = $t, !4 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        ASSIGN                                                   !1, 0
   16     2        INIT_FCALL                                               'scandir'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !2, $6
   17     6      > FE_RESET_R                                       $8      !2, ->39
          7    > > FE_FETCH_R                                               $8, !3, ->39
   18     8    >   FETCH_DIM_R                                      ~9      !3, 0
          9        IS_EQUAL                                                 ~9, '.'
         10      > JMPZ                                                     ~10, ->12
   19    11    > > JMP                                                      ->7
   21    12    >   INIT_FCALL                                               'rtrim'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 '%2F'
         15        DO_ICALL                                         $11     
         16        CONCAT                                           ~12     $11, '%2F'
         17        CONCAT                                           ~13     ~12, !3
         18        ASSIGN                                                   !4, ~13
   22    19        INIT_FCALL                                               'is_dir'
         20        SEND_VAR                                                 !4
         21        DO_ICALL                                         $15     
         22      > JMPZ                                                     $15, ->34
   23    23    >   INIT_FCALL_BY_NAME                                       'getFileCount'
         24        INIT_FCALL                                               'rtrim'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 '%2F'
         27        DO_ICALL                                         $16     
         28        CONCAT                                           ~17     $16, '%2F'
         29        CONCAT                                           ~18     ~17, !3
         30        SEND_VAL_EX                                              ~18
         31        DO_FCALL                                      0  $19     
         32        ASSIGN_OP                                     1          !1, $19
         33      > JMP                                                      ->38
   25    34    >   PRE_INC                                                  !1
   26    35        INIT_FCALL                                               'unlink'
         36        SEND_VAR                                                 !4
         37        DO_ICALL                                                 
   17    38    > > JMP                                                      ->7
         39    >   FE_FREE                                                  $8
   29    40      > RETURN                                                   !1
   30    41*     > RETURN                                                   null

End of function getfilecount

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.21 ms | 1411 KiB | 39 Q