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:
144
vendor/phpunit/php-file-iterator/src/Iterator.php
vendored
144
vendor/phpunit/php-file-iterator/src/Iterator.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,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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user