getInnerIterator example

$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
            foreach ($iterator as $file) {
                if (!$file->isFile()) {
                    continue;
                }

                if ($this->isExcluded($file->getPathname())) {
                    continue;
                }

                /** @var RecursiveDirectoryIterator $innerIterator */
                $innerIterator = $iterator->getInnerIterator();
                $logicalPath = ($namespace ? rtrim($namespace, '/').'/' : '').$innerIterator->getSubPathName();
                $logicalPath = $this->normalizeLogicalPath($logicalPath);
                $paths[$logicalPath] = $file->getPathname();
            }
        }

        return $paths;
    }

    /** * @internal */

  public function __construct($path$regex) {
    parent::__construct(new \FilesystemIterator($path)$regex);
  }

  /** * Implements \RegexIterator::accept(). */
  #[\ReturnTypeWillChange]   public function accept() {
    /** @var \SplFileInfo $file_info */
    $file_info = $this->getInnerIterator()->current();
    return $file_info->isFile() && preg_match($this->getRegex()$file_info->getFilename());
  }

}
Caster::PREFIX_VIRTUAL.'storage' => $storage,
        ];

        return $a;
    }

    /** * @return array */
    public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub, bool $isNested)
    {
        $a[Caster::PREFIX_VIRTUAL.'innerIterator'] = $c->getInnerIterator();

        return $a;
    }

    /** * @return array */
    public static function castWeakReference(\WeakReference $c, array $a, Stub $stub, bool $isNested)
    {
        $a[Caster::PREFIX_VIRTUAL.'object'] = $c->get();

        
Caster::PREFIX_VIRTUAL.'storage' => $storage,
        ];

        return $a;
    }

    /** * @return array */
    public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub, bool $isNested)
    {
        $a[Caster::PREFIX_VIRTUAL.'innerIterator'] = $c->getInnerIterator();

        return $a;
    }

    /** * @return array */
    public static function castWeakReference(\WeakReference $c, array $a, Stub $stub, bool $isNested)
    {
        $a[Caster::PREFIX_VIRTUAL.'object'] = $c->get();

        

  public function __construct(\RecursiveIterator $iteratorprotected string $regex = '') {
    parent::__construct($iterator);
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function accept() {
    /** @var \SplFileInfo $file_info */
    $file_info = $this->getInnerIterator()->current();
    if ($file_info->isDir()) {
      // Enter into subdirectory.       return TRUE;
    }
    // Return if file matches regular expression.     return $file_info->isFile() && preg_match($this->regex, $file_info->getFilename());
  }

  /** * {@inheritdoc} */
  
$this->minDepth = $minDepth;
        $iterator->setMaxDepth(\PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);

        parent::__construct($iterator);
    }

    /** * Filters the iterator values. */
    public function accept(): bool
    {
        return $this->getInnerIterator()->getDepth() >= $this->minDepth;
    }
}
Home | Imprint | This part of the site doesn't use cookies.