upgrade to laravel 8.0

This commit is contained in:
Attila Kerekes
2022-11-13 17:05:03 +01:00
committed by Attila Jozsef Kerekes
parent 43f894b58d
commit 27f58c0866
3895 changed files with 150576 additions and 124482 deletions

View File

@@ -1 +0,0 @@
*.php diff=php

View File

@@ -1,7 +0,0 @@
build/api
build/code-browser
build/coverage
build/logs
build/pdepend
cache.properties
phpunit.xml

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<file src="src/Iterator.php">
<UndefinedInterfaceMethod occurrences="1">
<code>current</code>
</UndefinedInterfaceMethod>
</file>
</files>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
resolveFromConfigFile="false"
totallyTyped="false"
errorBaseline=".psalm/baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>

View File

@@ -2,23 +2,113 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
## [3.0.6] - 2021-12-02
### Changed
* [#73](https://github.com/sebastianbergmann/php-file-iterator/pull/73): Micro performance improvements on parsing paths
## [3.0.5] - 2020-09-28
### Changed
* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
## [3.0.4] - 2020-07-11
### Fixed
* [#67](https://github.com/sebastianbergmann/php-file-iterator/issues/67): `TypeError` in `SebastianBergmann\FileIterator\Iterator::accept()`
## [3.0.3] - 2020-06-26
### Added
* This component is now supported on PHP 8
## [3.0.2] - 2020-06-15
### Changed
* Tests etc. are now ignored for archive exports
## [3.0.1] - 2020-04-18
### Fixed
* [#64](https://github.com/sebastianbergmann/php-file-iterator/issues/64): Release tarball contains Composer PHAR
## [3.0.0] - 2020-02-07
### Removed
* This component is no longer supported on PHP 7.1 and PHP 7.2
## [2.0.5] - 2021-12-02
### Changed
* [#73](https://github.com/sebastianbergmann/php-file-iterator/pull/73): Micro performance improvements on parsing paths
### Fixed
* [#74](https://github.com/sebastianbergmann/php-file-iterator/pull/74): Document return type of `SebastianBergmann\FileIterator\Iterator::accept()` so that Symfony's `DebugClassLoader` does not trigger a deprecation warning
## [2.0.4] - 2021-07-19
### Changed
* Added `ReturnTypeWillChange` attribute to `SebastianBergmann\FileIterator\Iterator::accept()` because the return type of `\FilterIterator::accept()` will change in PHP 8.1
## [2.0.3] - 2020-11-30
### Changed
* Changed PHP version constraint in `composer.json` from `^7.1` to `>=7.1`
## [2.0.2] - 2018-09-13
### Fixed
* [#48](https://github.com/sebastianbergmann/php-file-iterator/issues/48): Excluding an array that contains false ends up excluding the current working directory
## [2.0.1] - 2018-06-11
### Fixed
* [#46](https://github.com/sebastianbergmann/php-file-iterator/issues/46): Regression with hidden parent directory
## [2.0.0] - 2018-05-28
### 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
* Fixed [#37](https://github.com/sebastianbergmann/php-file-iterator/issues/37): Regression caused by fix for [#30](https://github.com/sebastianbergmann/php-file-iterator/issues/30)
* [#37](https://github.com/sebastianbergmann/php-file-iterator/issues/37): Regression caused by fix for [#30](https://github.com/sebastianbergmann/php-file-iterator/issues/30)
## [1.4.4] - 2017-11-27
### 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
* [#30](https://github.com/sebastianbergmann/php-file-iterator/issues/30): Exclude is not considered if it is a parent of the base path
## [1.4.3] - 2017-11-25
### Fixed
* Fixed [#34](https://github.com/sebastianbergmann/php-file-iterator/issues/34): Factory should use canonical directory names
* [#34](https://github.com/sebastianbergmann/php-file-iterator/issues/34): Factory should use canonical directory names
## [1.4.2] - 2016-11-26
@@ -32,8 +122,21 @@ No changes
### Added
* [Added support for wildcards (glob) in exclude](https://github.com/sebastianbergmann/php-file-iterator/pull/23)
* [#23](https://github.com/sebastianbergmann/php-file-iterator/pull/23): Added support for wildcards (glob) in exclude
[3.0.6]: https://github.com/sebastianbergmann/php-file-iterator/compare/3.0.5...3.0.6
[3.0.5]: https://github.com/sebastianbergmann/php-file-iterator/compare/3.0.4...3.0.5
[3.0.4]: https://github.com/sebastianbergmann/php-file-iterator/compare/3.0.3...3.0.4
[3.0.3]: https://github.com/sebastianbergmann/php-file-iterator/compare/3.0.2...3.0.3
[3.0.2]: https://github.com/sebastianbergmann/php-file-iterator/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/sebastianbergmann/php-file-iterator/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/2.0.5...3.0.0
[2.0.5]: https://github.com/sebastianbergmann/php-file-iterator/compare/2.0.4...2.0.5
[2.0.4]: https://github.com/sebastianbergmann/php-file-iterator/compare/2.0.3...2.0.4
[2.0.3]: https://github.com/sebastianbergmann/php-file-iterator/compare/2.0.2...2.0.3
[2.0.2]: https://github.com/sebastianbergmann/php-file-iterator/compare/2.0.1...2.0.2
[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.5...2.0.0
[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

View File

@@ -1,6 +1,6 @@
File_Iterator
php-file-iterator
Copyright (c) 2009-2015, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2009-2021, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -1,4 +1,6 @@
# File_Iterator
[![Build Status](https://travis-ci.org/sebastianbergmann/php-file-iterator.svg?branch=master)](https://travis-ci.org/sebastianbergmann/php-file-iterator)
# php-file-iterator
## Installation

View File

@@ -11,16 +11,26 @@
"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"
},
"config": {
"platform": {
"php": "7.3.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"prefer-stable": true,
"require": {
"php": ">=5.3.3"
"php": ">=7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.3"
},
"autoload": {
"classmap": [
@@ -29,8 +39,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
"dev-master": "3.0-dev"
}
}
}

View File

@@ -1,43 +1,40 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the File_Iterator package.
* This file is part of phpunit/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.
*/
namespace SebastianBergmann\FileIterator;
/**
* 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
use const DIRECTORY_SEPARATOR;
use function array_unique;
use function count;
use function dirname;
use function explode;
use function is_file;
use function is_string;
use function realpath;
use function sort;
class Facade
{
/**
* @param array|string $paths
* @param array|string $suffixes
* @param array|string $prefixes
* @param array $exclude
* @param bool $commonPath
* @return array
* @param array|string $paths
* @param array|string $suffixes
* @param array|string $prefixes
*/
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);
$paths = [$paths];
}
$factory = new File_Iterator_Factory;
$iterator = $factory->getFileIterator(
$paths, $suffixes, $prefixes, $exclude
);
$iterator = (new Factory)->getFileIterator($paths, $suffixes, $prefixes, $exclude);
$files = array();
$files = [];
foreach ($iterator as $file) {
$file = $file->getRealPath();
@@ -57,34 +54,28 @@ class File_Iterator_Facade
sort($files);
if ($commonPath) {
return array(
'commonPath' => $this->getCommonPath($files),
'files' => $files
);
} else {
return $files;
return [
'commonPath' => $this->getCommonPath($files),
'files' => $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);
if ($count == 0) {
if ($count === 0) {
return '';
}
if ($count == 1) {
if ($count === 1) {
return dirname($files[0]) . DIRECTORY_SEPARATOR;
}
$_files = array();
$_files = [];
foreach ($files as $file) {
$_files[] = $_fileParts = explode(DIRECTORY_SEPARATOR, $file);
@@ -95,14 +86,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,51 +1,55 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the File_Iterator package.
* This file is part of phpunit/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.
*/
namespace SebastianBergmann\FileIterator;
/**
* 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
use const GLOB_ONLYDIR;
use function array_filter;
use function array_map;
use function array_merge;
use function glob;
use function is_dir;
use function is_string;
use function realpath;
use AppendIterator;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
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
*/
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);
$paths = [$paths];
}
$paths = $this->getPathsAfterResolvingWildcards($paths);
$exclude = $this->getPathsAfterResolvingWildcards($exclude);
if (is_string($prefixes)) {
if ($prefixes != '') {
$prefixes = array($prefixes);
if ($prefixes !== '') {
$prefixes = [$prefixes];
} else {
$prefixes = array();
$prefixes = [];
}
}
if (is_string($suffixes)) {
if ($suffixes != '') {
$suffixes = array($suffixes);
if ($suffixes !== '') {
$suffixes = [$suffixes];
} else {
$suffixes = array();
$suffixes = [];
}
}
@@ -54,15 +58,15 @@ class File_Iterator_Factory
foreach ($paths as $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,22 +74,18 @@ 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));
$_paths[] = array_map('\realpath', $locals);
} else {
$_paths[] = realpath($path);
$_paths[] = [realpath($path)];
}
}
return $_paths;
return array_filter(array_merge(...$_paths));
}
}

View File

@@ -1,154 +1,115 @@
<?php
<?php declare(strict_types=1);
/*
* This file is part of the File_Iterator package.
* This file is part of phpunit/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.
*/
namespace SebastianBergmann\FileIterator;
/**
* 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
use function array_filter;
use function array_map;
use function preg_match;
use function realpath;
use function str_replace;
use function strlen;
use function strpos;
use function substr;
use FilterIterator;
class Iterator extends FilterIterator
{
const PREFIX = 0;
const SUFFIX = 1;
public const PREFIX = 0;
/**
* @var array
*/
protected $suffixes = array();
/**
* @var array
*/
protected $prefixes = array();
/**
* @var array
*/
protected $exclude = array();
public const SUFFIX = 1;
/**
* @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 = [];
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()
public function accept(): bool
{
$current = $this->getInnerIterator()->current();
$filename = $current->getFilename();
$realpath = $current->getRealPath();
$realPath = $current->getRealPath();
if ($this->basepath !== NULL) {
$realpath = str_replace($this->basepath, '', $realpath);
if ($realPath === false) {
return false;
}
// 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;
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;
}
}