summaryrefslogtreecommitdiff
path: root/vendor/phpunit/php-file-iterator/src
diff options
context:
space:
mode:
authorsupahgreg <supahgreg@users.noreply.github.com>2025-10-09 02:49:56 +0000
committersupahgreg <supahgreg@users.noreply.github.com>2025-10-09 03:08:30 +0000
commite41d6361221a30ca9d996cde7591111e626b7e1c (patch)
tree4572f61f37bbc76192ad60e0940c281483bc03af /vendor/phpunit/php-file-iterator/src
parentab0aabf8548c206f3f624de5451a9b6abbde90be (diff)
Remove dev dependencies and update the rest.
Diffstat (limited to 'vendor/phpunit/php-file-iterator/src')
-rw-r--r--vendor/phpunit/php-file-iterator/src/Facade.php115
-rw-r--r--vendor/phpunit/php-file-iterator/src/Factory.php91
-rw-r--r--vendor/phpunit/php-file-iterator/src/Iterator.php119
3 files changed, 0 insertions, 325 deletions
diff --git a/vendor/phpunit/php-file-iterator/src/Facade.php b/vendor/phpunit/php-file-iterator/src/Facade.php
deleted file mode 100644
index 87b6588dd..000000000
--- a/vendor/phpunit/php-file-iterator/src/Facade.php
+++ /dev/null
@@ -1,115 +0,0 @@
-<?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.
- */
-namespace SebastianBergmann\FileIterator;
-
-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
- */
- public function getFilesAsArray($paths, $suffixes = '', $prefixes = '', array $exclude = [], bool $commonPath = false): array
- {
- if (is_string($paths)) {
- $paths = [$paths];
- }
-
- $iterator = (new Factory)->getFileIterator($paths, $suffixes, $prefixes, $exclude);
-
- $files = [];
-
- foreach ($iterator as $file) {
- $file = $file->getRealPath();
-
- if ($file) {
- $files[] = $file;
- }
- }
-
- foreach ($paths as $path) {
- if (is_file($path)) {
- $files[] = realpath($path);
- }
- }
-
- $files = array_unique($files);
- sort($files);
-
- if ($commonPath) {
- return [
- 'commonPath' => $this->getCommonPath($files),
- 'files' => $files,
- ];
- }
-
- return $files;
- }
-
- protected function getCommonPath(array $files): string
- {
- $count = count($files);
-
- if ($count === 0) {
- return '';
- }
-
- if ($count === 1) {
- return dirname($files[0]) . DIRECTORY_SEPARATOR;
- }
-
- $_files = [];
-
- foreach ($files as $file) {
- $_files[] = $_fileParts = explode(DIRECTORY_SEPARATOR, $file);
-
- if (empty($_fileParts[0])) {
- $_fileParts[0] = DIRECTORY_SEPARATOR;
- }
- }
-
- $common = '';
- $done = false;
- $j = 0;
- $count--;
-
- while (!$done) {
- for ($i = 0; $i < $count; $i++) {
- if ($_files[$i][$j] != $_files[$i + 1][$j]) {
- $done = true;
-
- break;
- }
- }
-
- if (!$done) {
- $common .= $_files[0][$j];
-
- if ($j > 0) {
- $common .= DIRECTORY_SEPARATOR;
- }
- }
-
- $j++;
- }
-
- return DIRECTORY_SEPARATOR . $common;
- }
-}
diff --git a/vendor/phpunit/php-file-iterator/src/Factory.php b/vendor/phpunit/php-file-iterator/src/Factory.php
deleted file mode 100644
index 08f8de999..000000000
--- a/vendor/phpunit/php-file-iterator/src/Factory.php
+++ /dev/null
@@ -1,91 +0,0 @@
-<?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.
- */
-namespace SebastianBergmann\FileIterator;
-
-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
- */
- public function getFileIterator($paths, $suffixes = '', $prefixes = '', array $exclude = []): AppendIterator
- {
- if (is_string($paths)) {
- $paths = [$paths];
- }
-
- $paths = $this->getPathsAfterResolvingWildcards($paths);
- $exclude = $this->getPathsAfterResolvingWildcards($exclude);
-
- if (is_string($prefixes)) {
- if ($prefixes !== '') {
- $prefixes = [$prefixes];
- } else {
- $prefixes = [];
- }
- }
-
- if (is_string($suffixes)) {
- if ($suffixes !== '') {
- $suffixes = [$suffixes];
- } else {
- $suffixes = [];
- }
- }
-
- $iterator = new AppendIterator;
-
- foreach ($paths as $path) {
- if (is_dir($path)) {
- $iterator->append(
- new Iterator(
- $path,
- new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS | RecursiveDirectoryIterator::SKIP_DOTS)
- ),
- $suffixes,
- $prefixes,
- $exclude
- )
- );
- }
- }
-
- return $iterator;
- }
-
- protected function getPathsAfterResolvingWildcards(array $paths): array
- {
- $_paths = [[]];
-
- foreach ($paths as $path) {
- if ($locals = glob($path, GLOB_ONLYDIR)) {
- $_paths[] = array_map('\realpath', $locals);
- } else {
- $_paths[] = [realpath($path)];
- }
- }
-
- return array_filter(array_merge(...$_paths));
- }
-}
diff --git a/vendor/phpunit/php-file-iterator/src/Iterator.php b/vendor/phpunit/php-file-iterator/src/Iterator.php
deleted file mode 100644
index 7eb82ad68..000000000
--- a/vendor/phpunit/php-file-iterator/src/Iterator.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?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.
- */
-namespace SebastianBergmann\FileIterator;
-
-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
-{
- public const PREFIX = 0;
-
- public const SUFFIX = 1;
-
- /**
- * @var string
- */
- private $basePath;
-
- /**
- * @var array
- */
- private $suffixes = [];
-
- /**
- * @var array
- */
- private $prefixes = [];
-
- /**
- * @var array
- */
- private $exclude = [];
-
- public function __construct(string $basePath, \Iterator $iterator, array $suffixes = [], array $prefixes = [], array $exclude = [])
- {
- $this->basePath = realpath($basePath);
- $this->prefixes = $prefixes;
- $this->suffixes = $suffixes;
- $this->exclude = array_filter(array_map('realpath', $exclude));
-
- parent::__construct($iterator);
- }
-
- public function accept(): bool
- {
- $current = $this->getInnerIterator()->current();
- $filename = $current->getFilename();
- $realPath = $current->getRealPath();
-
- if ($realPath === false) {
- return false;
- }
-
- return $this->acceptPath($realPath) &&
- $this->acceptPrefix($filename) &&
- $this->acceptSuffix($filename);
- }
-
- 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 true;
- }
-
- private function acceptPrefix(string $filename): bool
- {
- return $this->acceptSubString($filename, $this->prefixes, self::PREFIX);
- }
-
- private function acceptSuffix(string $filename): bool
- {
- return $this->acceptSubString($filename, $this->suffixes, self::SUFFIX);
- }
-
- private function acceptSubString(string $filename, array $subStrings, int $type): bool
- {
- if (empty($subStrings)) {
- return true;
- }
-
- $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;
-
- break;
- }
- }
-
- return $matched;
- }
-}