iterator_to_array

Supported Versions: PHP 5 >= 5.1.0, PHP 7, PHP 8
Copy the iterator into an array
<?php iterator_to_array(Traversable|array $iterator, bool $preserve_keys = true): array
<?php     public function check(array $parameters): array

    {

        $filesOrDirectories = iterator_to_array(Finder::create()

            ->notPath(NotPaths::get($parameters['directory'], $this->config->whitelistedPaths))

            ->ignoreDotFiles(true)

            ->ignoreUnreadableDirs()

            ->ignoreVCSIgnored(true)

            ->in($parameters['directory'])

            ->getIterator());



        usort($filesOrDirectories, fn (SplFileInfo $a, SplFileInfo $b): int => $a->getRealPath() <=> $b->getRealPath());
<?php     public function check(array $parameters): array

    {

        $sourceFiles = iterator_to_array(Finder::create()

            ->files()

            ->notPath(NotPaths::get($parameters['directory'], $this->config->whitelistedPaths))

            ->ignoreDotFiles(true)

            ->ignoreVCS(true)

            ->ignoreUnreadableDirs()

            ->ignoreVCSIgnored(true)

            ->in($parameters['directory'])

            ->name('*.php')

            ->getIterator());



        usort($sourceFiles, fn (SplFileInfo $a, SplFileInfo $b): int => $a->getRealPath() <=> $b->getRealPath());
<?php     private function getMisspellings(string $text): array

    {

        $misspellings = iterator_to_array($this->run($text));



        $this->cache->set($text, $misspellings);