3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Bug { class Directory extends \RecursiveDirectoryIterator { protected $_splFileInfoClass = null; protected $_relativePath = null; public function __construct ( $path, $flags = null, $splFileInfoClass = null ) { if(null === $flags) parent::__construct($path); else parent::__construct($path, $flags); $this->setSplFileInfoClass($splFileInfoClass); $this->setRelativePath($path); return; } public function current ( ) { $out = parent::current(); if( null !== $this->_splFileInfoClass && $out instanceof \SplFileInfo) { $out->setInfoClass($this->_splFileInfoClass); $out = $out->getFileInfo(); if($out instanceof SplFileInfo) $out->setRelativePath($this->getRelativePath()); } return $out; } public function getChildren ( ) { $out = parent::getChildren(); $out->setRelativePath($this->getRelativePath()); if($out instanceof \RecursiveDirectoryIterator) $out->setSplFileInfoClass($this->_splFileInfoClass); return $out; } public function setSplFileInfoClass ( $splFileInfoClass ) { $this->_splFileInfoClass = $splFileInfoClass; return; } public function setRelativePath ( $path ) { $this->_relativePath = $path; return; } public function getRelativePath ( ) { return $this->_relativePath; } } class SplFileInfo extends \SplFileInfo { protected $_relativePath = null; public function __construct ( $filename, $relativePath = null ) { parent::__construct($filename); $this->_relativePath = $relativePath; return; } public function setRelativePath ( $relativePath ) { $old = $this->_relativePath; $this->_relativePath = $relativePath; return $old; } public function getRelativePath ( ) { return $this->_relativePath; } public function getRelativePathname ( ) { if(null === $relative = $this->getRelativePath()) return $this->getPathname(); return substr($this->getPathname(), strlen($relative)); } } } namespace { $finder = new Bug\Directory('.'); $finder->setSplFileInfoClass('Bug\SplFileInfo'); foreach(new \RecursiveIteratorIterator($finder) as $entry) var_dump($entry->getRelativePathname()); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/ddO9O
function name:  (null)
number of ops:  20
compiled vars:  !0 = $finder, !1 = $entry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  110     0  E >   NEW                                              $2      'Bug%5CDirectory'
          1        SEND_VAL_EX                                              '.'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
  111     4        INIT_METHOD_CALL                                         !0, 'setSplFileInfoClass'
          5        SEND_VAL_EX                                              'Bug%5CSplFileInfo'
          6        DO_FCALL                                      0          
  113     7        NEW                                              $6      'RecursiveIteratorIterator'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
         10      > FE_RESET_R                                       $8      $6, ->18
         11    > > FE_FETCH_R                                               $8, !1, ->18
  114    12    >   INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !1, 'getRelativePathname'
         14        DO_FCALL                                      0  $9      
         15        SEND_VAR                                                 $9
         16        DO_ICALL                                                 
  113    17      > JMP                                                      ->11
         18    >   FE_FREE                                                  $8
  116    19      > RETURN                                                   1

Class Bug\Directory:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ddO9O
function name:  __construct
number of ops:  21
compiled vars:  !0 = $path, !1 = $flags, !2 = $splFileInfoClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
   11     3        TYPE_CHECK                                    2          !1
          4      > JMPZ                                                     ~3, ->9
   12     5    >   INIT_STATIC_METHOD_CALL                                  
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8      > JMP                                                      ->13
   14     9    >   INIT_STATIC_METHOD_CALL                                  
         10        SEND_VAR_EX                                              !0
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
   16    13    >   INIT_METHOD_CALL                                         'setSplFileInfoClass'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0          
   17    16        INIT_METHOD_CALL                                         'setRelativePath'
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0          
   19    19      > RETURN                                                   null
   20    20*     > RETURN                                                   null

End of function __construct

Function current:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
Branch analysis from position: 24
Branch analysis from position: 8
filename:       /in/ddO9O
function name:  current
number of ops:  26
compiled vars:  !0 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_STATIC_METHOD_CALL                                  'current'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   26     3        FETCH_OBJ_R                                      ~3      '_splFileInfoClass'
          4        TYPE_CHECK                                  1020  ~4      ~3
          5      > JMPZ_EX                                          ~4      ~4, ->8
   27     6    >   INSTANCEOF                                       ~5      !0, 'SplFileInfo'
          7        BOOL                                             ~4      ~5
          8    > > JMPZ                                                     ~4, ->24
   29     9    >   INIT_METHOD_CALL                                         !0, 'setInfoClass'
         10        CHECK_FUNC_ARG                                           
         11        FETCH_OBJ_FUNC_ARG                               $6      '_splFileInfoClass'
         12        SEND_FUNC_ARG                                            $6
         13        DO_FCALL                                      0          
   30    14        INIT_METHOD_CALL                                         !0, 'getFileInfo'
         15        DO_FCALL                                      0  $8      
         16        ASSIGN                                                   !0, $8
   32    17        INSTANCEOF                                               !0, 'Bug%5CSplFileInfo'
         18      > JMPZ                                                     ~10, ->24
   33    19    >   INIT_METHOD_CALL                                         !0, 'setRelativePath'
         20        INIT_METHOD_CALL                                         'getRelativePath'
         21        DO_FCALL                                      0  $11     
         22        SEND_VAR_NO_REF_EX                                       $11
         23        DO_FCALL                                      0          
   36    24    > > RETURN                                                   !0
   37    25*     > RETURN                                                   null

End of function current

Function getchildren:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/ddO9O
function name:  getChildren
number of ops:  17
compiled vars:  !0 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_STATIC_METHOD_CALL                                  'getChildren'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   42     3        INIT_METHOD_CALL                                         !0, 'setRelativePath'
          4        INIT_METHOD_CALL                                         'getRelativePath'
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR_NO_REF_EX                                       $3
          7        DO_FCALL                                      0          
   44     8        INSTANCEOF                                               !0, 'RecursiveDirectoryIterator'
          9      > JMPZ                                                     ~5, ->15
   45    10    >   INIT_METHOD_CALL                                         !0, 'setSplFileInfoClass'
         11        CHECK_FUNC_ARG                                           
         12        FETCH_OBJ_FUNC_ARG                               $6      '_splFileInfoClass'
         13        SEND_FUNC_ARG                                            $6
         14        DO_FCALL                                      0          
   47    15    > > RETURN                                                   !0
   48    16*     > RETURN                                                   null

End of function getchildren

Function setsplfileinfoclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ddO9O
function name:  setSplFileInfoClass
number of ops:  5
compiled vars:  !0 = $splFileInfoClass
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
   52     1        ASSIGN_OBJ                                               '_splFileInfoClass'
          2        OP_DATA                                                  !0
   54     3      > RETURN                                                   null
   55     4*     > RETURN                                                   null

End of function setsplfileinfoclass

Function setrelativepath:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ddO9O
function name:  setRelativePath
number of ops:  5
compiled vars:  !0 = $path
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
   59     1        ASSIGN_OBJ                                               '_relativePath'
          2        OP_DATA                                                  !0
   61     3      > RETURN                                                   null
   62     4*     > RETURN                                                   null

End of function setrelativepath

Function getrelativepath:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ddO9O
function name:  getRelativePath
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   FETCH_OBJ_R                                      ~0      '_relativePath'
          1      > RETURN                                                   ~0
   67     2*     > RETURN                                                   null

End of function getrelativepath

End of class Bug\Directory.

Class Bug\SplFileInfo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ddO9O
function name:  __construct
number of ops:  9
compiled vars:  !0 = $filename, !1 = $relativePath
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   78     2        INIT_STATIC_METHOD_CALL                                  
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   79     5        ASSIGN_OBJ                                               '_relativePath'
          6        OP_DATA                                                  !1
   81     7      > RETURN                                                   null
   82     8*     > RETURN                                                   null

End of function __construct

Function setrelativepath:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ddO9O
function name:  setRelativePath
number of ops:  7
compiled vars:  !0 = $relativePath, !1 = $old
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   84     0  E >   RECV                                             !0      
   86     1        FETCH_OBJ_R                                      ~2      '_relativePath'
          2        ASSIGN                                                   !1, ~2
   87     3        ASSIGN_OBJ                                               '_relativePath'
          4        OP_DATA                                                  !0
   89     5      > RETURN                                                   !1
   90     6*     > RETURN                                                   null

End of function setrelativepath

Function getrelativepath:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ddO9O
function name:  getRelativePath
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   94     0  E >   FETCH_OBJ_R                                      ~0      '_relativePath'
          1      > RETURN                                                   ~0
   95     2*     > RETURN                                                   null

End of function getrelativepath

Function getrelativepathname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ddO9O
function name:  getRelativePathname
number of ops:  19
compiled vars:  !0 = $relative
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   99     0  E >   INIT_METHOD_CALL                                         'getRelativePath'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                           ~2      !0, $1
          3        TYPE_CHECK                                    2          ~2
          4      > JMPZ                                                     ~3, ->8
  100     5    >   INIT_METHOD_CALL                                         'getPathname'
          6        DO_FCALL                                      0  $4      
          7      > RETURN                                                   $4
  102     8    >   INIT_NS_FCALL_BY_NAME                                    'Bug%5Csubstr'
          9        INIT_METHOD_CALL                                         'getPathname'
         10        DO_FCALL                                      0  $5      
         11        SEND_VAR_NO_REF_EX                                       $5
         12        INIT_NS_FCALL_BY_NAME                                    'Bug%5Cstrlen'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $6      
         15        SEND_VAR_NO_REF_EX                                       $6
         16        DO_FCALL                                      0  $7      
         17      > RETURN                                                   $7
  103    18*     > RETURN                                                   null

End of function getrelativepathname

End of class Bug\SplFileInfo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.84 ms | 1412 KiB | 19 Q