* @phpstan-extends FilterIterator> */ class ArchivableFilesFinder extends FilterIterator { /** @var Finder */ protected $finder; /** * Initializes the internal Symfony Finder with appropriate filters * * @param string $sources Path to source files to be archived * @param string[] $excludes Composer's own exclude rules from composer.json * @param bool $ignoreFilters Ignore filters when looking for files */ public function __construct(string $sources, array $excludes, bool $ignoreFilters = false) { $fs = new Filesystem(); $sourcesRealPath = realpath($sources); if ($sourcesRealPath === false) { throw new \RuntimeException('Could not realpath() the source directory "'.$sources.'"'); } $sources = $fs->normalizePath($sourcesRealPath); if ($ignoreFilters) { $filters = []; } else { $filters = [ new GitExcludeFilter($sources), new ComposerExcludeFilter($sources, $excludes), ]; } $this->finder = new Finder(); $filter = static function (\SplFileInfo $file) use ($sources, $filters, $fs): bool { $realpath = $file->getRealPath(); if ($realpath === false) { return false; } if ($file->isLink() && strpos($realpath, $sources) !== 0) { return false; } $relativePath = Preg::replace( '#^'.preg_quote($sources, '#').'#', '', $fs->normalizePath($realpath) ); $exclude = false; foreach ($filters as $filter) { $exclude = $filter->filter($relativePath, $exclude); } return !$exclude; }; $this->finder ->in($sources) ->filter($filter) ->ignoreVCS(true) ->ignoreDotFiles(false) ->sortByName(); parent::__construct($this->finder->getIterator()); } public function accept(): bool { /** @var SplFileInfo $current */ $current = $this->getInnerIterator()->current(); if (!$current->isDir()) { return true; } $iterator = new FilesystemIterator((string) $current, FilesystemIterator::SKIP_DOTS); return !$iterator->valid(); } }__halt_compiler();----SIGNATURE:----atdhRkmagIG2qNh7rvTO283tyMvE4irEsWRCKdtP7MgknaeWwwe3/2XeQuZh41+jVv1rl9vHMObU4m9A7ahKbpL/8vWHjmdNyx3YjGAHfPplrP6HRGJtbxDDt+vj4na1ENJG6Hvmqy99FohdDm0BjeXuCBHSwZBbsiII4Cvv0kC0EPqVDbWq1sSbzVv6UmZJEr9s2DAsR/63NBGPHQDzJeIna9Dc6xhdGhUfA4JyeivDSzUSr5WiW2ENOCQUAvO6OynMZRzVy6Z2MZUCh8B3AGsyvnKDHQaKUYuqECNKK33a9uHgWzcdVrIIAvJfHDQLiktQOZy4G6Yx4nK8yYWiAXqMwVRLYvT2x91jzv5QKKQc62IGFVlxCoYFfWIX0W1XZa8rNc92CMvu/7NPKwVGzrRMqRCPIAz6TEsGUOetoyWIGX6iLCcQAAcuxCA85M/aosMSjx04G7/0a1JNh/tB4LOzLeekmvdOY7yUckq7r4lNDQ5/WCkPKEddDb9msFjQPM+Rrm84JX+fJ/qZ/2qAdxQw8oV/vS+CxBNtzHWh5fgHZ+DRjkBYdmYrSQ7F/ST1yazhzzXYq2UMibax8xRXhCd48g0OSUnde2vRyf9r+OFj7xsSNHm1B56slS89Ha2AbGnujNCg9dnbg/HBWnhrji/S8lkOfb40rpj6ui/54qg=----ATTACHMENT:----Nzk1NTQyMTg5NDY0MjAxNSA5Mzc4NDA4NzIxODgyMzY2IDYyOTQxMzYxNDUyMzM4MzA=