returns all FilesystemFile instances in folder
when $extension is specified, only files with extension are returned

@param $extension
@return array of FilesystemFile instances
174928
public function getFiles($extension = NULL) {

		$result = [];
		$glob = $this->path . '*';

		if(!is_null($extension)) {
			$glob .= ".$extension";
		}

		foreach(array_filter(glob($glob), 'is_file') as $f) {
			$result[] = FilesystemFile::getInstance($f, $this);
		}

		return $result;
	}
56566
public static function create(string $extension = ''): array
    {
        static::init();
        $filePath = $fileName = '';
        if (static::verifyPath(static::$hashFileDir)) {
            $exists = true;
            while ($exists === true) {
                $hash = Random::hash();
                $hashDir = \implode('/', \str_split(\substr($hash, 0, static::$hashFileDirDepth), 1));
                $filePath = static::normalizePath(\sprintf('%s%s', static::$hashFileDir, $hashDir));
                $filePath .= DIRECTORY_SEPARATOR;
                $fileName = \sprintf('%s.%s', $hash, $extension);
                $exists = File::exists($filePath.$fileName);
            }
        }
        return ['path' => $filePath, 'name' => $fileName];
    }
1209235
public function withExtensions(Extensions $extensions): self
    {
        $obj = clone $this;
        $obj->_extensions = $extensions;
        return $obj;
    }
591946
public static List<File> getFilesByExtension(File dir, String[] extensions)
    {
        if (!dir.isDirectory() || extensions == null)
            return Collections.emptyList();
        List<File> files = new ArrayList<File>();
        addFilesByExtension(files, dir, extensions);
        return files;
    }
676625
public function cacheExtension($extension = null)
    {
        if (empty($extension)) {
            return $this->cache_extension;
        }

        $this->cache_extension = $extension;

        return $this;
    }
189583
public static List<File> listFileWithExtension(final File rootDir, final String extension) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir).filter(new FileExtensionFilter(extension)).toList();
	}
820076
public static function fromExtension($extension)
	{
		$extension = strtolower($extension);

		return isset(static::$mimetypes[$extension])
			? static::$mimetypes[$extension]
			: null;
	}
240393
public function getExtensionsByType()
  {
    $ext = array();

    foreach ($this->Config->get('file-extensions') as $key => $value)
    {
      $ext[$key] = $value['extensions'];
    }

    return $ext;
  }
192845
protected function getParser($extension)
	{
		$parser = null;

		$extension = strtolower($extension);

		foreach (Processor::all() as $fileParser)
		{
			if (in_array($extension, $fileParser->getSupportedExtensions()))
			{
				$parser = $fileParser;
				break;
			}
		}

		// If none exist, then throw an exception
		if ($parser === null)
		{
			throw new UnsupportedFormatException(sprintf('Unsupported configuration format "%s"', $extension));
		}

		return $parser;
	}
56662
public function files($directory, $pattern = '*', $extensions = '')
    {
        $all = array_filter($this->listDirectory($directory), function ($path) {
            return $this->type($path) == 'file';
        });

        $extensions = $extensions ? (array)$extensions : [];

        return $this->filterPaths($all, $pattern, $extensions);

    }
276804
protected function getCascadingFilePaths(string $file, ?string $extension = null, ?string $suffix = null): array
	{
		$paths = [];

		if(strpos($file, '::') === false)
		{
			// No namespace so we'll just have add a single file

			$paths[] = $this->getFilePath($file, $extension, $suffix);
		}
		else
		{
			// Add the namespaced file first

			$paths[] = $this->getFilePath($file, $extension, $suffix);

			// Prepend the cascading file

			[$package, $file] = explode('::', $file);

			$suffix = 'packages' . DIRECTORY_SEPARATOR . $package . (($suffix !== null) ? DIRECTORY_SEPARATOR . $suffix : '');

			array_unshift($paths, $this->getFilePath($file, $extension, $suffix));
		}

		return $paths;
	}
559476
public function withExtension($extension)
    {
        $clone = clone $this;
        $clone->info['extension'] = $extension;

        if (empty($clone->info['file'])) {
            $clone->info['file'] = array_pop($clone->info['path']);
        }

        return $clone;
    }
857806
public function getFiles($onlySuccessful = true)
    {
        $context = $this->_context;

        $files = [];

        /** @var $_FILES array */
        foreach ($context->_FILES as $key => $file) {
            if (is_int($file['error'])) {
                if (!$onlySuccessful || $file['error'] === UPLOAD_ERR_OK) {
                    $fileInfo = [
                        'name' => $file['name'],
                        'type' => $file['type'],
                        'tmp_name' => $file['tmp_name'],
                        'error' => $file['error'],
                        'size' => $file['size'],
                    ];
                    $files[] = new File($key, $fileInfo);
                }
            } else {
                $countFiles = count($file['error']);
                /** @noinspection ForeachInvariantsInspection */
                for ($i = 0; $i < $countFiles; $i++) {
                    if (!$onlySuccessful || $file['error'][$i] === UPLOAD_ERR_OK) {
                        $fileInfo = [
                            'name' => $file['name'][$i],
                            'type' => $file['type'][$i],
                            'tmp_name' => $file['tmp_name'][$i],
                            'error' => $file['error'][$i],
                            'size' => $file['size'][$i],
                        ];
                        $files[] = new File($key, $fileInfo);
                    }
                }
            }
        }

        return $files;
    }
1220132
function extensions()
    {
        if (! $this->files->isDir(VALET_HOME_PATH.'/Extensions')) {
            return [];
        }

        return collect($this->files->scandir(VALET_HOME_PATH.'/Extensions'))
                    ->reject(function ($file) {
                        return is_dir($file);
                    })
                    ->map(function ($file) {
                        return VALET_HOME_PATH.'/Extensions/'.$file;
                    })
                    ->values()->all();
    }
361161
public static function checkExtList(array $extensions = [])
    {
        $allTotal = [];

        foreach ($extensions as $extension) {
            if (!\extension_loaded($extension)) {
                $allTotal['no'][] = $extension;
            } else {
                $allTotal['yes'][] = $extension;
            }
        }

        return $allTotal;
    }
1240240
public function getBundles($extension = null)
    {
        if ($extension === null) {
            return $this->bundles;
        }
        elseif (isset($this->bundles[$extension])) {
            return $this->bundles[$extension];
        }
        else {
            return null;
        }
    }
960280
protected function getMimesByExtensions(array $extensions)
    {
        $output = [];
        foreach ($extensions as $ext) {
            if (($mime = $this->getMimeByExtension($ext)) === false) {
                return false;
            }
            if (is_array($mime)) {
                $output = array_merge($output, $mime);
            } else {
                $output[] = $mime;
            }
        }

        return $output;
    }