the middle of the idiots
This commit is contained in:
		
							
								
								
									
										80
									
								
								qwen/php/vendor/phpunit/php-file-iterator/src/ExcludeIterator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								qwen/php/vendor/phpunit/php-file-iterator/src/ExcludeIterator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,80 @@
 | 
			
		||||
<?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 assert;
 | 
			
		||||
use function str_starts_with;
 | 
			
		||||
use RecursiveDirectoryIterator;
 | 
			
		||||
use RecursiveFilterIterator;
 | 
			
		||||
use SplFileInfo;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal This class is not covered by the backward compatibility promise for phpunit/php-file-iterator
 | 
			
		||||
 */
 | 
			
		||||
final class ExcludeIterator extends RecursiveFilterIterator
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-var list<string>
 | 
			
		||||
     */
 | 
			
		||||
    private array $exclude;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-param list<string> $exclude
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(RecursiveDirectoryIterator $iterator, array $exclude)
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct($iterator);
 | 
			
		||||
 | 
			
		||||
        $this->exclude = $exclude;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function accept(): bool
 | 
			
		||||
    {
 | 
			
		||||
        $current = $this->current();
 | 
			
		||||
 | 
			
		||||
        assert($current instanceof SplFileInfo);
 | 
			
		||||
 | 
			
		||||
        $path = $current->getRealPath();
 | 
			
		||||
 | 
			
		||||
        if ($path === false) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach ($this->exclude as $exclude) {
 | 
			
		||||
            if (str_starts_with($path, $exclude)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function hasChildren(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->getInnerIterator()->hasChildren();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getChildren(): self
 | 
			
		||||
    {
 | 
			
		||||
        return new self(
 | 
			
		||||
            $this->getInnerIterator()->getChildren(),
 | 
			
		||||
            $this->exclude
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getInnerIterator(): RecursiveDirectoryIterator
 | 
			
		||||
    {
 | 
			
		||||
        $innerIterator = parent::getInnerIterator();
 | 
			
		||||
 | 
			
		||||
        assert($innerIterator instanceof RecursiveDirectoryIterator);
 | 
			
		||||
 | 
			
		||||
        return $innerIterator;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										52
									
								
								qwen/php/vendor/phpunit/php-file-iterator/src/Facade.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								qwen/php/vendor/phpunit/php-file-iterator/src/Facade.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
<?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_unique;
 | 
			
		||||
use function assert;
 | 
			
		||||
use function sort;
 | 
			
		||||
use SplFileInfo;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
 | 
			
		||||
 */
 | 
			
		||||
final class Facade
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-param list<non-empty-string>|non-empty-string $paths
 | 
			
		||||
     * @psalm-param list<non-empty-string>|string $suffixes
 | 
			
		||||
     * @psalm-param list<non-empty-string>|string $prefixes
 | 
			
		||||
     * @psalm-param list<non-empty-string> $exclude
 | 
			
		||||
     *
 | 
			
		||||
     * @psalm-return list<non-empty-string>
 | 
			
		||||
     */
 | 
			
		||||
    public function getFilesAsArray(array|string $paths, array|string $suffixes = '', array|string $prefixes = '', array $exclude = []): array
 | 
			
		||||
    {
 | 
			
		||||
        $iterator = (new Factory)->getFileIterator($paths, $suffixes, $prefixes, $exclude);
 | 
			
		||||
 | 
			
		||||
        $files = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($iterator as $file) {
 | 
			
		||||
            assert($file instanceof SplFileInfo);
 | 
			
		||||
 | 
			
		||||
            $file = $file->getRealPath();
 | 
			
		||||
 | 
			
		||||
            if ($file) {
 | 
			
		||||
                $files[] = $file;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $files = array_unique($files);
 | 
			
		||||
 | 
			
		||||
        sort($files);
 | 
			
		||||
 | 
			
		||||
        return $files;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										106
									
								
								qwen/php/vendor/phpunit/php-file-iterator/src/Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								qwen/php/vendor/phpunit/php-file-iterator/src/Factory.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,106 @@
 | 
			
		||||
<?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 array_values;
 | 
			
		||||
use function glob;
 | 
			
		||||
use function is_dir;
 | 
			
		||||
use function is_string;
 | 
			
		||||
use function realpath;
 | 
			
		||||
use AppendIterator;
 | 
			
		||||
use FilesystemIterator;
 | 
			
		||||
use RecursiveDirectoryIterator;
 | 
			
		||||
use RecursiveIteratorIterator;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @internal This class is not covered by the backward compatibility promise for phpunit/php-file-iterator
 | 
			
		||||
 */
 | 
			
		||||
final class Factory
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-param list<non-empty-string>|non-empty-string $paths
 | 
			
		||||
     * @psalm-param list<non-empty-string>|string $suffixes
 | 
			
		||||
     * @psalm-param list<non-empty-string>|string $prefixes
 | 
			
		||||
     * @psalm-param list<non-empty-string> $exclude
 | 
			
		||||
     */
 | 
			
		||||
    public function getFileIterator(array|string $paths, array|string $suffixes = '', array|string $prefixes = '', array $exclude = []): AppendIterator
 | 
			
		||||
    {
 | 
			
		||||
        if (is_string($paths)) {
 | 
			
		||||
            $paths = [$paths];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $paths   = $this->resolveWildcards($paths);
 | 
			
		||||
        $exclude = $this->resolveWildcards($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 ExcludeIterator(
 | 
			
		||||
                                new RecursiveDirectoryIterator($path, FilesystemIterator::FOLLOW_SYMLINKS | FilesystemIterator::SKIP_DOTS),
 | 
			
		||||
                                $exclude,
 | 
			
		||||
                            ),
 | 
			
		||||
                        ),
 | 
			
		||||
                        $suffixes,
 | 
			
		||||
                        $prefixes,
 | 
			
		||||
                    )
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $iterator;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-param list<non-empty-string> $paths
 | 
			
		||||
     *
 | 
			
		||||
     * @psalm-return list<non-empty-string>
 | 
			
		||||
     */
 | 
			
		||||
    private function resolveWildcards(array $paths): array
 | 
			
		||||
    {
 | 
			
		||||
        $_paths = [[]];
 | 
			
		||||
 | 
			
		||||
        foreach ($paths as $path) {
 | 
			
		||||
            if ($locals = glob($path, GLOB_ONLYDIR)) {
 | 
			
		||||
                $_paths[] = array_map('\realpath', $locals);
 | 
			
		||||
            } else {
 | 
			
		||||
                // @codeCoverageIgnoreStart
 | 
			
		||||
                $_paths[] = [realpath($path)];
 | 
			
		||||
                // @codeCoverageIgnoreEnd
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return array_values(array_filter(array_merge(...$_paths)));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										114
									
								
								qwen/php/vendor/phpunit/php-file-iterator/src/Iterator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								qwen/php/vendor/phpunit/php-file-iterator/src/Iterator.php
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,114 @@
 | 
			
		||||
<?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 assert;
 | 
			
		||||
use function preg_match;
 | 
			
		||||
use function realpath;
 | 
			
		||||
use function str_ends_with;
 | 
			
		||||
use function str_replace;
 | 
			
		||||
use function str_starts_with;
 | 
			
		||||
use AppendIterator;
 | 
			
		||||
use FilterIterator;
 | 
			
		||||
use SplFileInfo;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @template-extends FilterIterator<int, string, AppendIterator>
 | 
			
		||||
 *
 | 
			
		||||
 * @internal This class is not covered by the backward compatibility promise for phpunit/php-file-iterator
 | 
			
		||||
 */
 | 
			
		||||
final class Iterator extends FilterIterator
 | 
			
		||||
{
 | 
			
		||||
    public const PREFIX = 0;
 | 
			
		||||
    public const SUFFIX = 1;
 | 
			
		||||
    private string|false $basePath;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-var list<string>
 | 
			
		||||
     */
 | 
			
		||||
    private array $suffixes;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-var list<string>
 | 
			
		||||
     */
 | 
			
		||||
    private array $prefixes;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-param list<string> $suffixes
 | 
			
		||||
     * @psalm-param list<string> $prefixes
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(string $basePath, \Iterator $iterator, array $suffixes = [], array $prefixes = [])
 | 
			
		||||
    {
 | 
			
		||||
        $this->basePath = realpath($basePath);
 | 
			
		||||
        $this->prefixes = $prefixes;
 | 
			
		||||
        $this->suffixes = $suffixes;
 | 
			
		||||
 | 
			
		||||
        parent::__construct($iterator);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function accept(): bool
 | 
			
		||||
    {
 | 
			
		||||
        $current = $this->getInnerIterator()->current();
 | 
			
		||||
 | 
			
		||||
        assert($current instanceof SplFileInfo);
 | 
			
		||||
 | 
			
		||||
        $filename = $current->getFilename();
 | 
			
		||||
        $realPath = $current->getRealPath();
 | 
			
		||||
 | 
			
		||||
        if ($realPath === false) {
 | 
			
		||||
            // @codeCoverageIgnoreStart
 | 
			
		||||
            return false;
 | 
			
		||||
            // @codeCoverageIgnoreEnd
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        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((string) $this->basePath, '', $path))) {
 | 
			
		||||
            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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @psalm-param list<string> $subStrings
 | 
			
		||||
     */
 | 
			
		||||
    private function acceptSubString(string $filename, array $subStrings, int $type): bool
 | 
			
		||||
    {
 | 
			
		||||
        if (empty($subStrings)) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        foreach ($subStrings as $string) {
 | 
			
		||||
            if (($type === self::PREFIX && str_starts_with($filename, $string)) ||
 | 
			
		||||
                ($type === self::SUFFIX && str_ends_with($filename, $string))) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user