This commit is contained in:
2025-02-04 12:40:43 +03:00
parent 4bcb4c60dd
commit 50343d5a87
372 changed files with 9019 additions and 6684 deletions

View File

@@ -2,12 +2,6 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
## [6.0.0] - 2025-02-07
### Removed
* This component is no longer supported on PHP 8.2
## [5.1.0] - 2024-08-27
### Added
@@ -174,7 +168,6 @@ No changes
* [#23](https://github.com/sebastianbergmann/php-file-iterator/pull/23): Added support for wildcards (glob) in exclude
[6.0.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/5.1...main
[5.1.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/5.0.1...5.1.0
[5.0.1]: https://github.com/sebastianbergmann/php-file-iterator/compare/5.0.0...5.0.1
[5.0.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/4.1...5.0.0

View File

@@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2009-2025, Sebastian Bergmann
Copyright (c) 2009-2024, Sebastian Bergmann
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -21,18 +21,17 @@
},
"config": {
"platform": {
"php": "8.3.0"
"php": "8.2.0"
},
"optimize-autoloader": true,
"sort-packages": true
},
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": ">=8.3"
"php": ">=8.2"
},
"require-dev": {
"phpunit/phpunit": "^12.0"
"phpunit/phpunit": "^11.0"
},
"autoload": {
"classmap": [
@@ -41,7 +40,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "6.0-dev"
"dev-main": "5.0-dev"
}
}
}

View File

@@ -37,8 +37,6 @@ final class Factory
* @param list<non-empty-string>|string $suffixes
* @param list<non-empty-string>|string $prefixes
* @param list<non-empty-string> $exclude
*
* @phpstan-ignore missingType.generics
*/
public function getFileIterator(array|string $paths, array|string $suffixes = '', array|string $prefixes = '', array $exclude = []): AppendIterator
{
@@ -115,7 +113,7 @@ final class Factory
*
* @return list<string>
*/
private function globstar(string $pattern): array
private function globstar(string $pattern)
{
if (stripos($pattern, '**') === false) {
$files = glob($pattern, GLOB_ONLYDIR);
@@ -127,24 +125,23 @@ final class Factory
$patterns = [$rootPattern . $restPattern];
$rootPattern .= '/*';
while ($directories = glob($rootPattern, GLOB_ONLYDIR)) {
while ($dirs = glob($rootPattern, GLOB_ONLYDIR)) {
$rootPattern .= '/*';
foreach ($directories as $directory) {
$patterns[] = $directory . $restPattern;
foreach ($dirs as $dir) {
$patterns[] = $dir . $restPattern;
}
}
$files = [];
foreach ($patterns as $_pattern) {
$files = array_merge($files, $this->globstar($_pattern));
foreach ($patterns as $pat) {
$files = array_merge($files, $this->globstar($pat));
}
}
if ($files !== false) {
$files = array_unique($files);
sort($files);
return $files;

View File

@@ -9,6 +9,7 @@
*/
namespace SebastianBergmann\FileIterator;
use function assert;
use function preg_match;
use function realpath;
use function str_ends_with;
@@ -24,8 +25,8 @@ use SplFileInfo;
*/
final class Iterator extends FilterIterator
{
public const int PREFIX = 0;
public const int SUFFIX = 1;
public const PREFIX = 0;
public const SUFFIX = 1;
private false|string $basePath;
/**
@@ -55,6 +56,8 @@ final class Iterator extends FilterIterator
{
$current = $this->getInnerIterator()->current();
assert($current instanceof SplFileInfo);
$filename = $current->getFilename();
$realPath = $current->getRealPath();