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:
Manish Verma
2018-08-06 20:08:55 +05:30
parent 126fbb0255
commit 1ac0f42a58
2464 changed files with 65239 additions and 46734 deletions

View File

@@ -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;
}
}

View File

@@ -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,61 +8,57 @@
* file that was distributed with this source code.
*/
/**
* Factory Method implementation that creates a File_Iterator that operates on
* an AppendIterator that contains an RecursiveDirectoryIterator for each given
* path.
*
* @since Class available since Release 1.1.0
*/
class File_Iterator_Factory
namespace SebastianBergmann\FileIterator;
class Factory
{
/**
* @param array|string $paths
* @param array|string $suffixes
* @param array|string $prefixes
* @param array $exclude
* @return AppendIterator
* @param array|string $paths
* @param array|string $suffixes
* @param array|string $prefixes
* @param array $exclude
*
* @return \AppendIterator
*/
public function getFileIterator($paths, $suffixes = '', $prefixes = '', array $exclude = array())
public function getFileIterator($paths, $suffixes = '', $prefixes = '', array $exclude = []): \AppendIterator
{
if (is_string($paths)) {
$paths = array($paths);
if (\is_string($paths)) {
$paths = [$paths];
}
$paths = $this->getPathsAfterResolvingWildcards($paths);
$exclude = $this->getPathsAfterResolvingWildcards($exclude);
if (is_string($prefixes)) {
if ($prefixes != '') {
$prefixes = array($prefixes);
if (\is_string($prefixes)) {
if ($prefixes !== '') {
$prefixes = [$prefixes];
} else {
$prefixes = array();
$prefixes = [];
}
}
if (is_string($suffixes)) {
if ($suffixes != '') {
$suffixes = array($suffixes);
if (\is_string($suffixes)) {
if ($suffixes !== '') {
$suffixes = [$suffixes];
} else {
$suffixes = array();
$suffixes = [];
}
}
$iterator = new AppendIterator;
$iterator = new \AppendIterator;
foreach ($paths as $path) {
if (is_dir($path)) {
if (\is_dir($path)) {
$iterator->append(
new File_Iterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS)
),
$suffixes,
$prefixes,
$exclude,
$path
)
new Iterator(
$path,
new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS | \RecursiveDirectoryIterator::SKIP_DOTS)
),
$suffixes,
$prefixes,
$exclude
)
);
}
}
@@ -70,19 +66,15 @@ class File_Iterator_Factory
return $iterator;
}
/**
* @param array $paths
* @return array
*/
protected function getPathsAfterResolvingWildcards(array $paths)
protected function getPathsAfterResolvingWildcards(array $paths): array
{
$_paths = array();
$_paths = [];
foreach ($paths as $path) {
if ($locals = glob($path, GLOB_ONLYDIR)) {
$_paths = array_merge($_paths, array_map('realpath', $locals));
if ($locals = \glob($path, GLOB_ONLYDIR)) {
$_paths = \array_merge($_paths, \array_map('\realpath', $locals));
} else {
$_paths[] = realpath($path);
$_paths[] = \realpath($path);
}
}

View File

@@ -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,147 +8,101 @@
* file that was distributed with this source code.
*/
/**
* FilterIterator implementation that filters files based on prefix(es) and/or
* suffix(es). Hidden files and files from hidden directories are also filtered.
*
* @since Class available since Release 1.0.0
*/
class File_Iterator extends FilterIterator
namespace SebastianBergmann\FileIterator;
class Iterator extends \FilterIterator
{
const PREFIX = 0;
const SUFFIX = 1;
/**
* @var array
*/
protected $suffixes = array();
/**
* @var array
*/
protected $prefixes = array();
/**
* @var array
*/
protected $exclude = array();
/**
* @var string
*/
protected $basepath;
private $basePath;
/**
* @param Iterator $iterator
* @param array $suffixes
* @param array $prefixes
* @param array $exclude
* @param string $basepath
* @var array
*/
public function __construct(Iterator $iterator, array $suffixes = array(), array $prefixes = array(), array $exclude = array(), $basepath = NULL)
private $suffixes = [];
/**
* @var array
*/
private $prefixes = [];
/**
* @var array
*/
private $exclude = [];
/**
* @param string $basePath
* @param \Iterator $iterator
* @param array $suffixes
* @param array $prefixes
* @param array $exclude
*/
public function __construct(string $basePath, \Iterator $iterator, array $suffixes = [], array $prefixes = [], array $exclude = [])
{
$exclude = array_filter(array_map('realpath', $exclude));
if ($basepath !== NULL) {
$basepath = realpath($basepath);
}
if ($basepath === FALSE) {
$basepath = NULL;
} else {
foreach ($exclude as &$_exclude) {
$_exclude = str_replace($basepath, '', $_exclude);
}
}
$this->basePath = \realpath($basePath);
$this->prefixes = $prefixes;
$this->suffixes = $suffixes;
$this->exclude = $exclude;
$this->basepath = $basepath;
$this->exclude = \array_filter(\array_map('realpath', $exclude));
parent::__construct($iterator);
}
/**
* @return bool
*/
public function accept()
{
$current = $this->getInnerIterator()->current();
$filename = $current->getFilename();
$realpath = $current->getRealPath();
$realPath = $current->getRealPath();
if ($this->basepath !== NULL) {
$realpath = str_replace($this->basepath, '', $realpath);
}
// Filter files in hidden directories.
if (preg_match('=/\.[^/]*/=', $realpath)) {
return FALSE;
}
return $this->acceptPath($realpath) &&
return $this->acceptPath($realPath) &&
$this->acceptPrefix($filename) &&
$this->acceptSuffix($filename);
}
/**
* @param string $path
* @return bool
* @since Method available since Release 1.1.0
*/
protected function acceptPath($path)
private function acceptPath(string $path): bool
{
// Filter files in hidden directories by checking path that is relative to the base path.
if (\preg_match('=/\.[^/]*/=', \str_replace($this->basePath, '', $path))) {
return false;
}
foreach ($this->exclude as $exclude) {
if (strpos($path, $exclude) === 0) {
return FALSE;
if (\strpos($path, $exclude) === 0) {
return false;
}
}
return TRUE;
return true;
}
/**
* @param string $filename
* @return bool
* @since Method available since Release 1.1.0
*/
protected function acceptPrefix($filename)
private function acceptPrefix(string $filename): bool
{
return $this->acceptSubString($filename, $this->prefixes, self::PREFIX);
}
/**
* @param string $filename
* @return bool
* @since Method available since Release 1.1.0
*/
protected function acceptSuffix($filename)
private function acceptSuffix(string $filename): bool
{
return $this->acceptSubString($filename, $this->suffixes, self::SUFFIX);
}
/**
* @param string $filename
* @param array $subStrings
* @param int $type
* @return bool
* @since Method available since Release 1.1.0
*/
protected function acceptSubString($filename, array $subStrings, $type)
private function acceptSubString(string $filename, array $subStrings, int $type): bool
{
if (empty($subStrings)) {
return TRUE;
return true;
}
$matched = FALSE;
$matched = false;
foreach ($subStrings as $string) {
if (($type == self::PREFIX && strpos($filename, $string) === 0) ||
($type == self::SUFFIX &&
substr($filename, -1 * strlen($string)) == $string)) {
$matched = TRUE;
if (($type === self::PREFIX && \strpos($filename, $string) === 0) ||
($type === self::SUFFIX &&
\substr($filename, -1 * \strlen($string)) === $string)) {
$matched = true;
break;
}
}