OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
API
/
vendor
/
symfony
/
finder
/
Tests
/
Iterator
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2024 04:34:19 AM
rwxr-xr-x
📄
CustomFilterIteratorTest.php
1.19 KB
08/07/2024 04:34:19 AM
rw-r--r--
📄
DateRangeFilterIteratorTest.php
2.51 KB
08/07/2024 04:34:19 AM
rw-r--r--
📄
DepthRangeFilterIteratorTest.php
2.8 KB
08/07/2024 04:34:19 AM
rw-r--r--
📄
ExcludeDirectoryFilterIteratorTest.php
2.92 KB
08/07/2024 04:34:19 AM
rw-r--r--
📄
FileTypeFilterIteratorTest.php
1.99 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
FilecontentFilterIteratorTest.php
2.56 KB
08/07/2024 04:34:19 AM
rw-r--r--
📄
FilenameFilterIteratorTest.php
1.19 KB
08/07/2024 04:34:19 AM
rw-r--r--
📄
InnerNameIterator.php
555 bytes
08/07/2024 04:34:20 AM
rw-r--r--
📄
Iterator.php
1.1 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
IteratorTestCase.php
3.4 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
LazyIteratorTest.php
1.22 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
MockFileListIterator.php
553 bytes
08/07/2024 04:34:20 AM
rw-r--r--
📄
MockSplFileInfo.php
3.21 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
MultiplePcreFilterIteratorTest.php
2.36 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
PathFilterIteratorTest.php
3.03 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
RealIteratorTestCase.php
4.81 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
RecursiveDirectoryIteratorTest.php
1.56 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
SizeRangeFilterIteratorTest.php
1.63 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
SortableIteratorTest.php
8.22 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
VcsIgnoredFilterIteratorTest.php
10.18 KB
08/07/2024 04:34:20 AM
rw-r--r--
📄
VfsIteratorTestTrait.php
5.36 KB
08/07/2024 04:34:20 AM
rw-r--r--
Editing: VfsIteratorTestTrait.php
Close
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Finder\Tests\Iterator; trait VfsIteratorTestTrait { private static int $vfsNextSchemeIndex = 0; /** @var array<string, \Closure(string, 'list_dir_open'|'list_dir_rewind'|'is_dir'): (list<string>|bool)> */ public static array $vfsProviders; protected string $vfsScheme; /** @var list<array{string, string, mixed}> */ protected array $vfsLog = []; protected function setUp(): void { parent::setUp(); $this->vfsScheme = 'symfony-finder-vfs-test-'.++self::$vfsNextSchemeIndex; $vfsWrapperClass = \get_class(new class() { /** @var array<string, \Closure(string, 'list_dir_open'|'list_dir_rewind'|'is_dir'): (list<string>|bool)> */ public static array $vfsProviders = []; /** @var resource */ public $context; private string $scheme; private string $dirPath; /** @var list<string> */ private array $dirData; private function parsePathAndSetScheme(string $url): string { $urlArr = parse_url($url); \assert(\is_array($urlArr)); \assert(isset($urlArr['scheme'])); \assert(isset($urlArr['host'])); $this->scheme = $urlArr['scheme']; return str_replace(\DIRECTORY_SEPARATOR, '/', $urlArr['host'].($urlArr['path'] ?? '')); } public function processListDir(bool $fromRewind): bool { $providerFx = self::$vfsProviders[$this->scheme]; $data = $providerFx($this->dirPath, 'list_dir'.($fromRewind ? '_rewind' : '_open')); \assert(\is_array($data)); $this->dirData = $data; return true; } public function dir_opendir(string $url): bool { $this->dirPath = $this->parsePathAndSetScheme($url); return $this->processListDir(false); } public function dir_readdir(): string|false { return array_shift($this->dirData) ?? false; } public function dir_closedir(): bool { unset($this->dirPath); unset($this->dirData); return true; } public function dir_rewinddir(): bool { return $this->processListDir(true); } /** * @return array<string, mixed> */ public function stream_stat(): array { return []; } /** * @return array<string, mixed> */ public function url_stat(string $url): array { $path = $this->parsePathAndSetScheme($url); $providerFx = self::$vfsProviders[$this->scheme]; $isDir = $providerFx($path, 'is_dir'); \assert(\is_bool($isDir)); return ['mode' => $isDir ? 0040755 : 0100644]; } }); self::$vfsProviders = &$vfsWrapperClass::$vfsProviders; stream_wrapper_register($this->vfsScheme, $vfsWrapperClass); } protected function tearDown(): void { stream_wrapper_unregister($this->vfsScheme); parent::tearDown(); } /** * @param array<string, mixed> $data */ protected function setupVfsProvider(array $data): void { self::$vfsProviders[$this->vfsScheme] = function (string $path, string $op) use ($data) { $pathArr = explode('/', $path); $fileEntry = $data; while (($name = array_shift($pathArr)) !== null) { if (!isset($fileEntry[$name])) { $fileEntry = false; break; } $fileEntry = $fileEntry[$name]; } if ('list_dir_open' === $op || 'list_dir_rewind' === $op) { /** @var list<string> $res */ $res = array_keys($fileEntry); } elseif ('is_dir' === $op) { $res = \is_array($fileEntry); } else { throw new \Exception('Unexpected operation type'); } $this->vfsLog[] = [$path, $op, $res]; return $res; }; } protected function stripSchemeFromVfsPath(string $url): string { $urlArr = parse_url($url); \assert(\is_array($urlArr)); \assert($urlArr['scheme'] === $this->vfsScheme); \assert(isset($urlArr['host'])); return str_replace(\DIRECTORY_SEPARATOR, '/', $urlArr['host'].($urlArr['path'] ?? '')); } protected function assertSameVfsIterator(array $expected, \Traversable $iterator) { $values = array_map(fn (\SplFileInfo $fileinfo) => $this->stripSchemeFromVfsPath($fileinfo->getPathname()), iterator_to_array($iterator)); $this->assertEquals($expected, array_values($values)); } }