src/File.php
private function listAllIterator($recursive = false, $showHidden = false)
	{
		if (!$this->isDirectory()) {
			return new \ArrayIterator([]);
		}

		$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO;

		if (!$showHidden) {
			$flags = $flags | \FilesystemIterator::SKIP_DOTS;
		}

		if ($recursive) {
			return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->path, $flags), \RecursiveIteratorIterator::SELF_FIRST);
		}

		return new \FilesystemIterator($this->path, $flags);
	}
private function listAllIterator($recursive = false, $showHidden = false)
	{
		if (!$this->isDirectory()) {
			return new \ArrayIterator([]);
		}

		$flags = \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO;

		if (!$showHidden) {
			$flags = $flags | \FilesystemIterator::SKIP_DOTS;
		}

		if ($recursive) {
			return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->path, $flags), \RecursiveIteratorIterator::SELF_FIRST);
		}

		return new \FilesystemIterator($this->path, $flags);
	}
Returns an iterator with the files and directories in the current directory.

@param bool $recursive = false
@param bool $showHidden = false
@return \ArrayIterator|\FilesystemIterator|\RecursiveIteratorIterator an iterator with the files and directories in the current directory.