Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
83
vendor/phpunit/php-file-iterator/src/Facade.php
vendored
83
vendor/phpunit/php-file-iterator/src/Facade.php
vendored
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the File_Iterator package.
|
||||
* This file is part of php-file-iterator.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -8,36 +8,30 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Façade implementation that uses File_Iterator_Factory to create a
|
||||
* File_Iterator that operates on an AppendIterator that contains an
|
||||
* RecursiveDirectoryIterator for each given path. The list of unique
|
||||
* files is returned as an array.
|
||||
*
|
||||
* @since Class available since Release 1.3.0
|
||||
*/
|
||||
class File_Iterator_Facade
|
||||
namespace SebastianBergmann\FileIterator;
|
||||
|
||||
class Facade
|
||||
{
|
||||
/**
|
||||
* @param array|string $paths
|
||||
* @param array|string $suffixes
|
||||
* @param array|string $prefixes
|
||||
* @param array $exclude
|
||||
* @param bool $commonPath
|
||||
* @param array|string $paths
|
||||
* @param array|string $suffixes
|
||||
* @param array|string $prefixes
|
||||
* @param array $exclude
|
||||
* @param bool $commonPath
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getFilesAsArray($paths, $suffixes = '', $prefixes = '', array $exclude = array(), $commonPath = FALSE)
|
||||
public function getFilesAsArray($paths, $suffixes = '', $prefixes = '', array $exclude = [], bool $commonPath = false): array
|
||||
{
|
||||
if (is_string($paths)) {
|
||||
$paths = array($paths);
|
||||
if (\is_string($paths)) {
|
||||
$paths = [$paths];
|
||||
}
|
||||
|
||||
$factory = new File_Iterator_Factory;
|
||||
$iterator = $factory->getFileIterator(
|
||||
$paths, $suffixes, $prefixes, $exclude
|
||||
);
|
||||
$factory = new Factory;
|
||||
|
||||
$files = array();
|
||||
$iterator = $factory->getFileIterator($paths, $suffixes, $prefixes, $exclude);
|
||||
|
||||
$files = [];
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
$file = $file->getRealPath();
|
||||
@@ -48,46 +42,40 @@ class File_Iterator_Facade
|
||||
}
|
||||
|
||||
foreach ($paths as $path) {
|
||||
if (is_file($path)) {
|
||||
$files[] = realpath($path);
|
||||
if (\is_file($path)) {
|
||||
$files[] = \realpath($path);
|
||||
}
|
||||
}
|
||||
|
||||
$files = array_unique($files);
|
||||
sort($files);
|
||||
$files = \array_unique($files);
|
||||
\sort($files);
|
||||
|
||||
if ($commonPath) {
|
||||
return array(
|
||||
return [
|
||||
'commonPath' => $this->getCommonPath($files),
|
||||
'files' => $files
|
||||
);
|
||||
} else {
|
||||
return $files;
|
||||
];
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the common path of a set of files.
|
||||
*
|
||||
* @param array $files
|
||||
* @return string
|
||||
*/
|
||||
protected function getCommonPath(array $files)
|
||||
protected function getCommonPath(array $files): string
|
||||
{
|
||||
$count = count($files);
|
||||
$count = \count($files);
|
||||
|
||||
if ($count == 0) {
|
||||
if ($count === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($count == 1) {
|
||||
return dirname($files[0]) . DIRECTORY_SEPARATOR;
|
||||
if ($count === 1) {
|
||||
return \dirname($files[0]) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
$_files = array();
|
||||
$_files = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$_files[] = $_fileParts = explode(DIRECTORY_SEPARATOR, $file);
|
||||
$_files[] = $_fileParts = \explode(DIRECTORY_SEPARATOR, $file);
|
||||
|
||||
if (empty($_fileParts[0])) {
|
||||
$_fileParts[0] = DIRECTORY_SEPARATOR;
|
||||
@@ -95,14 +83,15 @@ class File_Iterator_Facade
|
||||
}
|
||||
|
||||
$common = '';
|
||||
$done = FALSE;
|
||||
$done = false;
|
||||
$j = 0;
|
||||
$count--;
|
||||
|
||||
while (!$done) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
if ($_files[$i][$j] != $_files[$i+1][$j]) {
|
||||
$done = TRUE;
|
||||
if ($_files[$i][$j] != $_files[$i + 1][$j]) {
|
||||
$done = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user