Skip to content
Snippets Groups Projects
Commit d99e81a5 authored by David Prévot's avatar David Prévot
Browse files

New upstream version 5.1.0

parents b6ac0f41 118cfaaa
No related branches found
No related tags found
No related merge requests found
...@@ -73,15 +73,21 @@ jobs: ...@@ -73,15 +73,21 @@ jobs:
uses: "shivammathur/setup-php@v2" uses: "shivammathur/setup-php@v2"
with: with:
php-version: "${{ matrix.php-version }}" php-version: "${{ matrix.php-version }}"
coverage: "pcov" coverage: "xdebug"
- name: "Install dependencies with Composer" - name: "Install dependencies with Composer"
run: "./tools/composer update --no-ansi --no-interaction --no-progress" run: "./tools/composer update --no-ansi --no-interaction --no-progress"
- name: "Run tests with PHPUnit" - name: "Run tests with PHPUnit"
run: "vendor/bin/phpunit --coverage-clover=coverage.xml" run: "vendor/bin/phpunit --log-junit junit.xml --coverage-clover=coverage.xml"
- name: "Send code coverage report to Codecov.io" - name: Upload test results to Codecov.io
env: if: ${{ !cancelled() }}
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}" uses: codecov/test-results-action@v1
run: "bash <(curl -s https://codecov.io/bash) || true" with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload code coverage data to Codecov.io
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive"> <phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.59" installed="3.59.3" location="./tools/php-cs-fixer" copy="true"/> <phar name="php-cs-fixer" version="^3.59" installed="3.63.1" location="./tools/php-cs-fixer" copy="true"/>
<phar name="composer" version="^2.7" installed="2.7.7" location="./tools/composer" copy="true"/> <phar name="composer" version="^2.7" installed="2.7.8" location="./tools/composer" copy="true"/>
<phar name="phpstan" version="^1.11" installed="1.11.5" location="./tools/phpstan" copy="true"/> <phar name="phpstan" version="^1.11" installed="1.11.11" location="./tools/phpstan" copy="true"/>
</phive> </phive>
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
## [5.1.0] - 2024-08-27
### Added
* [#83](https://github.com/sebastianbergmann/php-file-iterator/pull/83): Support for "Globstar" pattern
## [5.0.1] - 2024-07-03 ## [5.0.1] - 2024-07-03
### Changed ### Changed
...@@ -162,6 +168,7 @@ No changes ...@@ -162,6 +168,7 @@ No changes
* [#23](https://github.com/sebastianbergmann/php-file-iterator/pull/23): Added support for wildcards (glob) in exclude * [#23](https://github.com/sebastianbergmann/php-file-iterator/pull/23): Added support for wildcards (glob) in exclude
[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.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 [5.0.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/4.1...5.0.0
[4.1.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/4.0.2...4.1.0 [4.1.0]: https://github.com/sebastianbergmann/php-file-iterator/compare/4.0.2...4.1.0
......
[![Latest Stable Version](https://poser.pugx.org/phpunit/php-file-iterator/v/stable.png)](https://packagist.org/packages/phpunit/php-file-iterator) [![Latest Stable Version](https://poser.pugx.org/phpunit/php-file-iterator/v)](https://packagist.org/packages/phpunit/php-file-iterator)
[![CI Status](https://github.com/sebastianbergmann/php-file-iterator/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/php-file-iterator/actions) [![CI Status](https://github.com/sebastianbergmann/php-file-iterator/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/php-file-iterator/actions)
[![Type Coverage](https://shepherd.dev/github/sebastianbergmann/php-file-iterator/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/php-file-iterator) [![Type Coverage](https://shepherd.dev/github/sebastianbergmann/php-file-iterator/coverage.svg)](https://shepherd.dev/github/sebastianbergmann/php-file-iterator)
[![codecov](https://codecov.io/gh/sebastianbergmann/php-file-iterator/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/php-file-iterator) [![codecov](https://codecov.io/gh/sebastianbergmann/php-file-iterator/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/php-file-iterator)
......
...@@ -13,11 +13,15 @@ use const GLOB_ONLYDIR; ...@@ -13,11 +13,15 @@ use const GLOB_ONLYDIR;
use function array_filter; use function array_filter;
use function array_map; use function array_map;
use function array_merge; use function array_merge;
use function array_unique;
use function array_values; use function array_values;
use function glob; use function glob;
use function is_dir; use function is_dir;
use function is_string; use function is_string;
use function realpath; use function realpath;
use function sort;
use function stripos;
use function substr;
use AppendIterator; use AppendIterator;
use FilesystemIterator; use FilesystemIterator;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
...@@ -92,7 +96,7 @@ final class Factory ...@@ -92,7 +96,7 @@ final class Factory
$_paths = [[]]; $_paths = [[]];
foreach ($paths as $path) { foreach ($paths as $path) {
if ($locals = glob($path, GLOB_ONLYDIR)) { if ($locals = $this->globstar($path)) {
$_paths[] = array_map('\realpath', $locals); $_paths[] = array_map('\realpath', $locals);
} else { } else {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
...@@ -103,4 +107,48 @@ final class Factory ...@@ -103,4 +107,48 @@ final class Factory
return array_values(array_filter(array_merge(...$_paths))); return array_values(array_filter(array_merge(...$_paths)));
} }
/**
* @see https://gist.github.com/funkjedi/3feee27d873ae2297b8e2370a7082aad
*
* @return list<string>
*/
private function globstar(string $pattern)
{
if (stripos($pattern, '**') === false) {
$files = glob($pattern, GLOB_ONLYDIR);
} else {
$position = stripos($pattern, '**');
$rootPattern = substr($pattern, 0, $position - 1);
$restPattern = substr($pattern, $position + 2);
$patterns = [$rootPattern . $restPattern];
$rootPattern .= '/*';
while ($dirs = glob($rootPattern, GLOB_ONLYDIR)) {
$rootPattern .= '/*';
foreach ($dirs as $dir) {
$patterns[] = $dir . $restPattern;
}
}
$files = [];
foreach ($patterns as $pat) {
$files = array_merge($files, $this->globstar($pat));
}
}
if ($files !== false) {
$files = array_unique($files);
sort($files);
return $files;
}
// @codeCoverageIgnoreStart
return [];
// @codeCoverageIgnoreEnd
}
} }
<?php declare(strict_types=1);
/*
* 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.
*/
<?php declare(strict_types=1);
/*
* 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.
*/
<?php declare(strict_types=1);
/*
* 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.
*/
<?php declare(strict_types=1);
/*
* 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.
*/
...@@ -41,11 +41,15 @@ final class FacadeTest extends TestCase ...@@ -41,11 +41,15 @@ final class FacadeTest extends TestCase
$fixtureDirectoryRealpath . '/a/c/d/Prefix.php', $fixtureDirectoryRealpath . '/a/c/d/Prefix.php',
$fixtureDirectoryRealpath . '/a/c/d/PrefixSuffix.php', $fixtureDirectoryRealpath . '/a/c/d/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/a/c/d/Suffix.php', $fixtureDirectoryRealpath . '/a/c/d/Suffix.php',
$fixtureDirectoryRealpath . '/a/c/d/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/e/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/e/g/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/f/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/h/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/f/h/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/h/i/PrefixSuffix.php',
], ],
__DIR__ . '/../fixture', __DIR__ . '/../fixture',
'', '',
...@@ -59,6 +63,8 @@ final class FacadeTest extends TestCase ...@@ -59,6 +63,8 @@ final class FacadeTest extends TestCase
$fixtureDirectoryRealpath . '/b/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/e/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/e/g/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/i/PrefixSuffix.php',
], ],
__DIR__ . '/../fixture', __DIR__ . '/../fixture',
'', '',
...@@ -76,11 +82,15 @@ final class FacadeTest extends TestCase ...@@ -76,11 +82,15 @@ final class FacadeTest extends TestCase
$fixtureDirectoryRealpath . '/a/c/PrefixSuffix.php', $fixtureDirectoryRealpath . '/a/c/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/a/c/d/Prefix.php', $fixtureDirectoryRealpath . '/a/c/d/Prefix.php',
$fixtureDirectoryRealpath . '/a/c/d/PrefixSuffix.php', $fixtureDirectoryRealpath . '/a/c/d/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/a/c/d/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/e/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/e/g/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/f/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/h/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/f/h/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/h/i/PrefixSuffix.php',
], ],
__DIR__ . '/../fixture', __DIR__ . '/../fixture',
'', '',
...@@ -95,11 +105,15 @@ final class FacadeTest extends TestCase ...@@ -95,11 +105,15 @@ final class FacadeTest extends TestCase
$fixtureDirectoryRealpath . '/a/c/Suffix.php', $fixtureDirectoryRealpath . '/a/c/Suffix.php',
$fixtureDirectoryRealpath . '/a/c/d/PrefixSuffix.php', $fixtureDirectoryRealpath . '/a/c/d/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/a/c/d/Suffix.php', $fixtureDirectoryRealpath . '/a/c/d/Suffix.php',
$fixtureDirectoryRealpath . '/a/c/d/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/e/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/e/g/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/f/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/h/PrefixSuffix.php', $fixtureDirectoryRealpath . '/b/f/h/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/h/i/PrefixSuffix.php',
], ],
__DIR__ . '/../fixture', __DIR__ . '/../fixture',
'Suffix.php', 'Suffix.php',
...@@ -115,12 +129,33 @@ final class FacadeTest extends TestCase ...@@ -115,12 +129,33 @@ final class FacadeTest extends TestCase
$fixtureDirectoryRealpath . '/a/c/d/Prefix.php', $fixtureDirectoryRealpath . '/a/c/d/Prefix.php',
$fixtureDirectoryRealpath . '/a/c/d/PrefixSuffix.php', $fixtureDirectoryRealpath . '/a/c/d/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/a/c/d/Suffix.php', $fixtureDirectoryRealpath . '/a/c/d/Suffix.php',
$fixtureDirectoryRealpath . '/a/c/d/i/PrefixSuffix.php',
], ],
__DIR__ . '/../fixture/*/c', __DIR__ . '/../fixture/*/c',
'', '',
'', '',
[], [],
], ],
'globstar, filter prefix: no, filter suffix: no, excludes: none' => [
[
$fixtureDirectoryRealpath . '/a/c/d/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/g/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/e/i/PrefixSuffix.php',
$fixtureDirectoryRealpath . '/b/f/h/i/PrefixSuffix.php',
],
__DIR__ . '/../fixture/**/i',
'',
'',
[],
],
'invalid path, filter prefix: no, filter suffix: no, excludes: none' => [
[],
__DIR__ . '/../fixture/**/this/path/does/not/exists',
'',
'',
[],
],
]; ];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment