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:
40
vendor/phpunit/php-file-iterator/.github/stale.yml
vendored
Normal file
40
vendor/phpunit/php-file-iterator/.github/stale.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 60
|
||||
|
||||
# Number of days of inactivity before a stale Issue or Pull Request is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 7
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
- enhancement
|
||||
|
||||
# Set to true to ignore issues in a project (defaults to false)
|
||||
exemptProjects: false
|
||||
|
||||
# Set to true to ignore issues in a milestone (defaults to false)
|
||||
exemptMilestones: false
|
||||
|
||||
# Label to use when marking as stale
|
||||
staleLabel: stale
|
||||
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions.
|
||||
|
||||
# Comment to post when removing the stale label.
|
||||
# unmarkComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Comment to post when closing a stale Issue or Pull Request.
|
||||
closeComment: >
|
||||
This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions.
|
||||
|
||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
||||
limitPerRun: 30
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: issues
|
||||
|
11
vendor/phpunit/php-file-iterator/.gitignore
vendored
11
vendor/phpunit/php-file-iterator/.gitignore
vendored
@@ -1,7 +1,4 @@
|
||||
build/api
|
||||
build/code-browser
|
||||
build/coverage
|
||||
build/logs
|
||||
build/pdepend
|
||||
cache.properties
|
||||
phpunit.xml
|
||||
/.idea
|
||||
/.php_cs
|
||||
/.php_cs.cache
|
||||
|
||||
|
167
vendor/phpunit/php-file-iterator/.php_cs.dist
vendored
Normal file
167
vendor/phpunit/php-file-iterator/.php_cs.dist
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
$header = <<<'EOF'
|
||||
This file is part of php-file-iterator.
|
||||
|
||||
(c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
EOF;
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setRules(
|
||||
[
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'binary_operator_spaces' => [
|
||||
'operators' => [
|
||||
'=' => 'align',
|
||||
'=>' => 'align',
|
||||
],
|
||||
],
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_before_statement' => [
|
||||
'statements' => [
|
||||
'break',
|
||||
'continue',
|
||||
'declare',
|
||||
'do',
|
||||
'for',
|
||||
'foreach',
|
||||
'if',
|
||||
'include',
|
||||
'include_once',
|
||||
'require',
|
||||
'require_once',
|
||||
'return',
|
||||
'switch',
|
||||
'throw',
|
||||
'try',
|
||||
'while',
|
||||
'yield',
|
||||
],
|
||||
],
|
||||
'braces' => true,
|
||||
'cast_spaces' => true,
|
||||
'class_attributes_separation' => ['elements' => ['method']],
|
||||
'compact_nullable_typehint' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'declare_equal_normalize' => ['space' => 'none'],
|
||||
'dir_constant' => true,
|
||||
'elseif' => true,
|
||||
'encoding' => true,
|
||||
'full_opening_tag' => true,
|
||||
'function_declaration' => true,
|
||||
'header_comment' => ['header' => $header, 'separate' => 'none'],
|
||||
'indentation_type' => true,
|
||||
'line_ending' => true,
|
||||
'list_syntax' => ['syntax' => 'short'],
|
||||
'lowercase_cast' => true,
|
||||
'lowercase_constants' => true,
|
||||
'lowercase_keywords' => true,
|
||||
'magic_constant_casing' => true,
|
||||
'method_argument_space' => ['ensure_fully_multiline' => true],
|
||||
'modernize_types_casting' => true,
|
||||
'native_function_casing' => true,
|
||||
'native_function_invocation' => true,
|
||||
'no_alias_functions' => true,
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_closing_tag' => true,
|
||||
'no_empty_comment' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_empty_statement' => true,
|
||||
'no_extra_blank_lines' => true,
|
||||
'no_homoglyph_names' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
'no_mixed_echo_print' => ['use' => 'print'],
|
||||
'no_null_property_initialization' => true,
|
||||
'no_short_bool_cast' => true,
|
||||
'no_short_echo_tag' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'no_spaces_after_function_name' => true,
|
||||
'no_spaces_inside_parenthesis' => true,
|
||||
'no_superfluous_elseif' => true,
|
||||
'no_trailing_comma_in_list_call' => true,
|
||||
'no_trailing_comma_in_singleline_array' => true,
|
||||
'no_trailing_whitespace' => true,
|
||||
'no_trailing_whitespace_in_comment' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unneeded_curly_braces' => true,
|
||||
'no_unneeded_final_method' => true,
|
||||
'no_unreachable_default_argument_value' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_useless_else' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'non_printable_character' => true,
|
||||
'normalize_index_brace' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'ordered_class_elements' => [
|
||||
'order' => [
|
||||
'use_trait',
|
||||
'constant_public',
|
||||
'constant_protected',
|
||||
'constant_private',
|
||||
'property_public_static',
|
||||
'property_protected_static',
|
||||
'property_private_static',
|
||||
'property_public',
|
||||
'property_protected',
|
||||
'property_private',
|
||||
'method_public_static',
|
||||
'construct',
|
||||
'destruct',
|
||||
'magic',
|
||||
'phpunit',
|
||||
'method_public',
|
||||
'method_protected',
|
||||
'method_private',
|
||||
'method_protected_static',
|
||||
'method_private_static',
|
||||
],
|
||||
],
|
||||
'ordered_imports' => true,
|
||||
'phpdoc_add_missing_param_annotation' => true,
|
||||
'phpdoc_align' => true,
|
||||
'phpdoc_annotation_without_dot' => true,
|
||||
'phpdoc_indent' => true,
|
||||
'phpdoc_no_access' => true,
|
||||
'phpdoc_no_empty_return' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_order' => true,
|
||||
'phpdoc_return_self_reference' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_separation' => true,
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_to_comment' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_types' => true,
|
||||
'phpdoc_types_order' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'pow_to_exponentiation' => true,
|
||||
'protected_to_private' => true,
|
||||
'return_type_declaration' => ['space_before' => 'none'],
|
||||
'self_accessor' => true,
|
||||
'short_scalar_cast' => true,
|
||||
'simplified_null_return' => true,
|
||||
'single_blank_line_at_eof' => true,
|
||||
'single_import_per_statement' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'single_quote' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'ternary_to_null_coalescing' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'visibility_required' => true,
|
||||
'void_return' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
]
|
||||
)
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->files()
|
||||
->in(__DIR__ . '/src')
|
||||
->notName('*.phpt')
|
||||
);
|
22
vendor/phpunit/php-file-iterator/ChangeLog.md
vendored
22
vendor/phpunit/php-file-iterator/ChangeLog.md
vendored
@@ -2,6 +2,26 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [2.0.1] - 2018-06-11
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#46](https://github.com/sebastianbergmann/php-file-iterator/issues/46): Regression with hidden parent directory
|
||||
|
||||
## [2.0.0] - 2018-05-28
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#30](https://github.com/sebastianbergmann/php-file-iterator/issues/30): Exclude is not considered if it is a parent of the base path
|
||||
|
||||
### Changed
|
||||
|
||||
* This component now uses namespaces
|
||||
|
||||
### Removed
|
||||
|
||||
* This component is no longer supported on PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, and PHP 7.0
|
||||
|
||||
## [1.4.5] - 2017-11-27
|
||||
|
||||
### Fixed
|
||||
@@ -34,6 +54,8 @@ No changes
|
||||
|
||||
* [Added support for wildcards (glob) in exclude](https://github.com/sebastianbergmann/php-file-iterator/pull/23)
|
||||
|
||||
[2.0.1]: https://github.com/sebastianbergmann/php-file-iterator/compare/2.0.0...2.0.1
|
||||
[2.0.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4...master
|
||||
[1.4.5]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4.4...1.4.5
|
||||
[1.4.4]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4.3...1.4.4
|
||||
[1.4.3]: https://github.com/sebastianbergmann/php-file-iterator/compare/1.4.2...1.4.3
|
||||
|
4
vendor/phpunit/php-file-iterator/LICENSE
vendored
4
vendor/phpunit/php-file-iterator/LICENSE
vendored
@@ -1,6 +1,6 @@
|
||||
File_Iterator
|
||||
php-file-iterator
|
||||
|
||||
Copyright (c) 2009-2015, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
Copyright (c) 2009-2018, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
2
vendor/phpunit/php-file-iterator/README.md
vendored
2
vendor/phpunit/php-file-iterator/README.md
vendored
@@ -1,4 +1,4 @@
|
||||
# File_Iterator
|
||||
# php-file-iterator
|
||||
|
||||
## Installation
|
||||
|
||||
|
@@ -11,16 +11,15 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sb@sebastian-bergmann.de",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
|
||||
"irc": "irc://irc.freenode.net/phpunit"
|
||||
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
"php": "^7.1"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
@@ -29,7 +28,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4.x-dev"
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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;
|
||||
}
|
||||
}
|
||||
|
82
vendor/phpunit/php-file-iterator/src/Factory.php
vendored
82
vendor/phpunit/php-file-iterator/src/Factory.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,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
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