@inheritdoc

@return Generator|PackageInterface[]
509942
public function getIterator(): Generator
    {
        foreach ($this->packageRoots as $root) {
            $rootPaths = [];
            $packages = [];

            // Search each namespace we've been provided.
            foreach ($this->namespaces as $namespace) {

                // Try to find the root within this namespace.
                // If we find it, aggregate the paths to scan for packages later.
                $package = $namespace->findNamespace($root);
                if ($package) {
                    $rootPaths = array_merge($rootPaths, $package->getPaths());
                }

                // If the namespace itself is actually a package within the root we're searching for,
                // aggregate it's path to scan as a package for later.
                if ($namespace->getParentId() === $root) {
                    if (!array_key_exists($namespace->getId(), $packages)) {
                        $packages[$namespace->getId()] = [];
                    }
                    $packages[$namespace->getId()] = array_merge(
                        $packages[$namespace->getId()],
                        $namespace->getPaths()
                    );
                }
            }

            // If we found any root paths, scan them for packages.
            if ($rootPaths) {
                $namespace = new Psr4Namespace($root, ...$rootPaths);
                yield from $this->scanRoot($namespace);
            }

            // If we found any package paths, scan them.
            foreach ($packages as $id => $paths) {
                $namespace = new Psr4Namespace($id, ...$paths);
                yield from $this->loadPackage($namespace);
            }
        }
    }
337970
public static function getPackagesAndDependencies($packagesArray)
    {
        foreach ($packagesArray as $key => $value) {
            $packageFile = base_path("/vendor/{$key}/composer.json");

            if ($key !== 'php' && file_exists($packageFile)) {
                $json2 = file_get_contents($packageFile);
                $dependenciesArray = json_decode($json2, true);
                $dependencies = array_key_exists('require', $dependenciesArray) ? $dependenciesArray['require'] : 'No dependencies';
                $devDependencies = array_key_exists('require-dev', $dependenciesArray) ? $dependenciesArray['require-dev'] : 'No dependencies';

                $packages[] = [
                    'name' => $key,
                    'version' => $value,
                    'dependencies' => $dependencies,
                    'dev-dependencies' => $devDependencies
                ];
            }
        }

        return $packages;
    }
1030749
protected function getEntryFileLocations(PackageInterface $package)
    {
        $muPluginsDir = dirname($this->composer->getInstallationManager()->getInstallPath($package));

        return array_reduce(
            $this->getPackageEntryPoints($package),
            function ($locations, $entryPoint) use ($muPluginsDir) {
                $locations[ $entryPoint ] =  $muPluginsDir . DIRECTORY_SEPARATOR . basename($entryPoint);

                return $locations;
            },
            []
        );
    }
1266276
protected function packageTranslations()
    {
        return collect($this->app['translator']->getLoader()->namespaces())->flatMap(function ($path, $namespace) {
            return [
                ($namespace .= '::') => collect($this->getFiles($path))->flatMap(function ($file) use ($namespace) {
                    return [
                        ($translation = $file->getBasename('.php')) => trans($namespace . $translation),
                    ];
                }),
            ];
        })->filter(function ($translations) {
            return $translations->isNotEmpty();
        });
    }
118825
public function package()
    {
        $package = [];
        $package['responses'] = [];
        if (!empty($this->_bundles)) {
            foreach ($this->_bundles as $bundleId => $bundle) {
                if (is_object($bundle)) {
                    $bundle = $bundle->package();
                }
                $package['responses'][$bundleId] = $bundle;
            }
        }

        return $package;
    }
1275292
private function getPackageByName(iterable $packages, string $name): ?PackageInterface
    {
        foreach ($packages as $package) {
            if ($package->getName() === $name) {
                return $package;
            }
        }

        return null;
    }
421940
protected function collectPatchesFromPackage(PackageInterface $package)
    {
        $collectedPatches = new PatchCollection();
        $extra = $package->getExtra();
        if (isset($extra['patches'])) {
            $this->io->write('<info>Gathering patches from '.$package->getName().' (extra.patches).</info>');
            $collectedPatches->merge($this->resolveExplicitList($package, $extra['patches']));
        }
        if (isset($extra['patches-file'])) {
            $this->io->write('<info>Gathering patches from '.$package->getName().' (extra.patches-file).</info>');
            $collectedPatches->merge($this->resolveJsonFile($package, $extra['patches-file']));
        }

        return $collectedPatches;
    }
1356432
private function getFileMap(PackageInterface $package, $directory)
    {
        $files = [];
        $root  = $this->getInstallPath($package);

        if (!file_exists($root . '/' . $directory)) {
            return [];
        }

        $iterator = new RecursiveDirectoryIterator($root . '/' . $directory, RecursiveDirectoryIterator::SKIP_DOTS);

        /** @var SplFileInfo $file */
        foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) {
            if ($file->isFile()) {
                $path = str_replace($root . '/' . $directory . '/', '', $file->getPathname());

                $files[$directory . '/' . $path] = $path;
            }
        }

        return $files;
    }
116
public function getPattern(PackageInterface $package)
    {
        if (isset($this->packages[$package->getName()])) {
            return $this->packages[$package->getName()];
        } elseif (isset($this->packages[$package->getPrettyName()])) {
            return $this->packages[$package->getPrettyName()];
        } elseif (isset($this->types[$package->getType()])) {
            return $this->types[$package->getType()];
        }
    }
386809
private function getHighestVersion(array $packages): ?PackageInterface
    {
        /** @var $highestVersion PackageInterface|null */
        $highestVersion = null;
        foreach ($packages as $package) {
            if (null === $highestVersion || version_compare($package->getVersion(), $highestVersion->getVersion(), '>=')) {
                $highestVersion = $package;
            }
        }

        return $highestVersion;
    }
881354
public function getLocalUpgradeablePackages()
    {
        $packages = $this->getAvailablePackages(false);
        $upgradeables = [];
        foreach ($packages as $p) {
            $entity = $this->getByHandle($p->getPackageHandle());
            if ($entity) {
                if (version_compare($p->getPackageVersion(), $entity->getPackageVersion(), '>')) {
                    $p->pkgCurrentVersion = $entity->getPackageVersion();
                    $upgradeables[] = $p;
                }
            }
        }

        return $upgradeables;
    }
808160
private function createPackages(array $packages)
    {
        $matcherPackages = [];

        foreach ($packages as $package) {
            $reflection = new ReflectionClass($package);

            if ($reflection->implementsInterface(self::PACKAGE_REGISTRAR) === false) {
                throw NotAvailableException::createForPackage(self::PACKAGE_REGISTRAR);
            }
            $matcherPackages[] = $reflection->newInstance();
        }

        return $matcherPackages;
    }
1308821
public function package()
    {
        $package = [];
        $package['id'] = $this->id;
        $package['instructions'] = $this->instructions;
        $package['filterQuery'] = $this->filterQuery;
        $package['type'] = $this->type;
        $package['typeOptions'] = $this->typeOptions;
        $package['total'] = $this->total;
        $package['bundle'] = false;
        $package['bundle'] = ['offset' => $this->offset, 'size' => count($this->_items), 'items' => []];
        foreach ($this->_items as $item) {
            $package['bundle']['items'][$item->id] = $item->package();
        }

        return $package;
    }
898208
public function getFileList( PackageInterface $package, $map ) {
    $directory = $this->getDirectory( $package );
    $result    = [];

    try {

      foreach( $map as $source => $destination ) {
        if( !is_dir( $directory . $source ) ) $result[ $directory . $source ] = Autoload::DIRECTORY . $destination;
        else {

          $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator( $directory . $source, \RecursiveDirectoryIterator::SKIP_DOTS ),
            \RecursiveIteratorIterator::SELF_FIRST
          );

          foreach( $iterator as $item ) {
            /** @var SplFileInfo $item */
            if( !$item->isDir() ) {
              $result[ $item->getRealPath() ] = Autoload::DIRECTORY . $destination . DIRECTORY_SEPARATOR . call_user_func( [ $iterator, 'getSubPathName' ] );
            }
          }
        }
      }

    } catch( \Throwable $e ) {
      $this->io->writeError( "Spoom\\Composer: Skip {$package->getPrettyName()} public copy, due to an error" );
    }

    return $result;
  }
649263
public function handleUninstall(): array
    {
        $result = [];

        $handlers = AbstractOperation::getOperationHandlers($this->composer);

        foreach ($this->projectType->getTypes() as $type) {
            if (isset($handlers[$type])) {
                $class = $handlers[$type];
                /** @var AbstractOperation $handler */
                $handler = new $class($this->package, $this->projectType, $this->composer);
                if ($handler instanceof AvailableOperationInterface) {
                    if (!$handler->isAvailable()) {
                        continue;
                    }
                }
                $result[] = $handler->uninstall();
            }
        }

        return $result;
    }
838407
public function keys(): CollectionInterface
    {
        return $this->wrap(function (Iterator $data) {
            foreach ($data as $key => $value) {
                yield $key;
            }
        });
    }
1327094
public function getPatchesFor(PackageInterface $package)
    {
        $patches = array();
        foreach ($this->getPatches() as $patch) {
            if ($patch->isForPackage($package)) {
                $patches[] = $patch;
            }
        }
        $result = new static();
        $result->patches = $patches;

        return $result;
    }