src/Repository/DeploymentBuilder.php
protected function collectFiles(string $dir, string $basePath): array
    {
        $files = [];
        $dh = \opendir($dir);
        
        try {
            while (false !== ($entry = \readdir($dh))) {
                if ($entry == '.' || $entry == '..') {
                    continue;
                }
                
                $check = $dir . \DIRECTORY_SEPARATOR . $entry;
                
                if (\is_dir($check)) {
                    foreach ($this->collectFiles($check, $basePath . '/' . $entry) as $k => $v) {
                        $files[$k] = $v;
                    }
                } elseif (\is_file($check)) {
                    $files[$basePath . '/' . $entry] = $check;
                }
            }
            
            return $files;
        } finally {
            \closedir($dh);
        }
    }
protected function collectFiles(string $dir, string $basePath): array
    {
        $files = [];
        $dh = \opendir($dir);
        
        try {
            while (false !== ($entry = \readdir($dh))) {
                if ($entry == '.' || $entry == '..') {
                    continue;
                }
                
                $check = $dir . \DIRECTORY_SEPARATOR . $entry;
                
                if (\is_dir($check)) {
                    foreach ($this->collectFiles($check, $basePath . '/' . $entry) as $k => $v) {
                        $files[$k] = $v;
                    }
                } elseif (\is_file($check)) {
                    $files[$basePath . '/' . $entry] = $check;
                }
            }
            
            return $files;
        } finally {
            \closedir($dh);
        }
    }
protected function collectFiles ( string $ dir , string $ basePath ) : array { $ files = [ ] ; $ dh = \ opendir ( $ dir ) ; try { while ( false !== ( $ entry = \ readdir ( $ dh ) ) ) { if ( $ entry == '.' || $ entry == '..' ) { continue ; } $ check = $ dir . \ DIRECTORY_SEPARATOR . $ entry ; if ( \ is_dir ( $ check ) ) { foreach ( $ this -> collectFiles ( $ check , $ basePath . '/' . $ entry ) as $ k => $ v ) { $ files [ $ k ] = $ v ; } } elseif ( \ is_file ( $ check ) ) { $ files [ $ basePath . '/' . $ entry ] = $ check ; } } return $ files ; } finally { \ closedir ( $ dh ) ; } }
Collect all files from the directory, uses recursion to grab files from sub-directories.
Collect all files from the directory uses recursion to grab files from sub - directories .