* @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(); $sources = $fs->normalizePath(realpath($sources)); 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 { if ($file->isLink() && ($file->getRealPath() === false || strpos($file->getRealPath(), $sources) !== 0)) { return false; } $relativePath = Preg::replace( '#^'.preg_quote($sources, '#').'#', '', $fs->normalizePath($file->getRealPath()) ); $exclude = false; foreach ($filters as $filter) { $exclude = $filter->filter($relativePath, $exclude); } return !$exclude; }; if (method_exists($filter, 'bindTo')) { $filter = $filter->bindTo(null); } $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:----Zqs+KkCItGwyr7ar4N5P5i7DuOeXc9T9QCL3bFREo/pMCO27KTwxTh/Z73DiV98YPSgIob6huXLDuQxyYUdITUld9X7lM+95bdiB2atIHG4h/Ipkz3n4Ij3mnAkFxTgT092C4Wygc3Pyza/Tl5NuHWLZe5w8E+zyng+UTtNTP/6aGCglHLka2k7mNPrQuftIflMWm139FJHkysKOQ8Oc2mzWdY+CRj6oYhkB4lw0kXIOnUuDI70R5iDAPbQdf2yg5UWxw95iRRBGl+eTUR37tjrQ8NQl9Rp7anDR7kdw0tOYk7/MmPIQa1ZfDlVtWnTwilVHB9vljvry7I2fjupKI16P+0H7iSnWs0uINH3MMCGpLZJBeKkE02I/lQnNB2mkM1Qc3bYfXZuG3ErL3SOnKViDyG5AXYeJkY2XRdoKrxnpYt99IS62PVnSVwarhoOSxWbeVRvVbJ7cRN/lxpQ4pvI6Webncgviy7W41w5Z9FZAZkIuJQ1UPtZR+ahOCkk9vxPZU40YarwAqOKrguIZaMbani96BRV6IKJfiN/Apjfc7bqcXtgj0qf7maB1px6/QVKORwvTk6bMcUY2N9oaqCEXDGJzwQim+nNSykbYr6C6wvaUFVI381cw3lAPrqrkALMTlBT3qpDyrvbCiWfFiRsxW+2xQrLFDbXOUFUAIrg=----ATTACHMENT:----NTkwNTIwMzUwNDUyMTgzNiA5MzI0MDQyOTI0OTE0MzY1IDUzMjMyODI4MDYyMzcxOTE=