Infer the name of the loaded packages
from their service provider.

@param string|string[] $packages

@return string[]
510828
protected function gatherLoadedPackagesHandles($packages)
    {
        $packages = (array) $packages;
        if (!$packages) {
            $plugins = $this->container->getPlugins();
            foreach ($plugins as $plugin) {
                $path = (new ReflectionClass($plugin))->getFileName();
                preg_match('/vendor\/([^\/]+)\/([^\/]+)/', $path, $handle);
                if (count($handle) !== 3) {
                    continue;
                }

                $packages[] = $handle[1].'/'.$handle[2];
            }
        }

        return $packages;
    }
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;
    }
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()];
        }
    }
702620
public function loadPackages($packages)
    {
        foreach ($packages as $package => $files) {
            if (is_string($files)) {
                $this->loadPackage($files);
            } elseif (is_array($files)) {
                $this->loadPackage($package, $files);
            } elseif (is_object($files)) {
                $this->loadPackage($package, get_object_vars($files));
            }
        }
    }
131108
private function findPackages($slugs)
    {
        $packages = [];

        foreach ($slugs as $package_slug) {
            $packageDir = $this->workingDir . '/vendor/' . $package_slug .'/';

            if (! is_dir($packageDir)) {
                continue;
            }

            $package = new Package($packageDir);
            $package->findAutoloaders();

            $config = json_decode(file_get_contents($packageDir . 'composer.json'));

            $dependencies = [];
            if (isset($config->require)) {
                $dependencies = array_keys((array)$config->require);
            }

            $package->dependencies = $this->findPackages($dependencies);
            $packages[] = $package;
        }

        return $packages;
    }
43393
public function getAvailablePackageStats(Package $package)
    {
        $result = [];
        $languagesDir = $package->getPackagePath() . '/' . DIRNAME_LANGUAGES;
        if ($this->fs->isDirectory($languagesDir)) {
            foreach ($this->fs->directories($languagesDir) as $localeDirectory) {
                $localeID = basename($localeDirectory);
                if (preg_match('/^[a-z]{2,3}($|_)/', $localeID)) {
                    $mo = $languagesDir . '/' . $localeID . '/LC_MESSAGES/messages.mo';
                    if ($this->fs->isFile($mo)) {
                        $result[$localeID] = $this->getMoFileStats($mo);
                    }
                }
            }
        }

        return $result;
    }
1221117
private function get_packages()
    {
        if ($this->input->getOption('all') === true) {
            $packages = [];
            
            // Add all package files to $packages array.
            foreach (Config::get('services.providers') as $package) {
                $packages[ $package ] = $package::get_files_to_publish();
            }

            return $packages;
        }

        $package = $this->input->getOption('package');

        // If no package specified.
        if ($package === null) {
            $package = $this->package_prompt();
        }

        // If the package chosen does not exist.
        if (! \class_exists($package)) {
            $this->output->writeln("<error>The package [$package] could not be found.</error>");
            exit;
        }

        // When running publish via the theme installer, the current theme isn't active yet.
        // We need to trick WP into thinking it is.
        if (isset($this->root)) {
            $parts = \explode('/', $this->root);

            if ($parts[0] == $this->root) {
                $parts = \explode('\\', $this->root);
            }

            $theme_name = \end($parts);

            \add_filter(
                'stylesheet',
                function () use ($theme_name) {
                    return $theme_name;
                }
            );
            \add_filter(
                'template',
                function () use ($theme_name) {
                    return $theme_name;
                }
            );

            // Resolve the package manually.
            $provider = Container::resolve($package);
            $provider->register();
        }

        return [
            $package => $package::get_files_to_publish(),
        ];
    }
1094883
protected function getPackages()
	{
		if ( ! is_null($package = $this->input->getArgument('package')))
		{
			return array($package);
		}
		elseif ( ! is_null($bench = $this->input->getOption('bench')))
		{
			return array($bench);
		}

		return $this->findAllAssetPackages();
	}
43684
public function getManifest($package)
    {
        if (is_array($package['extra'][self::EXTRA_FIELD])) {
            return $package['extra'][self::EXTRA_FIELD];
        } else if (is_string($package['extra'][self::EXTRA_FIELD])) {
            $manifestFile = $this->vendorPath . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $package['extra'][self::EXTRA_FIELD];
            if (is_file($manifestFile)) {
                return include($manifestFile);
            }
        }
        return [];
    }
181938
public function setPackages(array $packages) {
		$this->resetPackages();
		
		foreach ($packages as $package) {
			$this->appendPackage($package);
		}
		
		return $this;
	}
1311651
private function resolveGraph(array ...$packages): array
    {
        $graph = array_reduce(
            $packages,
            function (array $carry, array $package): array {
                foreach (array_keys($package['require'] ?? []) as $link) {
                    if (!preg_match('/^[^\/]+\/[^\/]+$/', $link)) {
                        // Most likely a platform requirement.
                        // E.g.: php
                        // E.g.: ext-openssl
                        continue;
                    }

                    if (!array_key_exists($link, $carry)) {
                        $carry[$link] = [];
                    }

                    if (!in_array($package['name'], $carry[$link], true)) {
                        $carry[$link][] = $package['name'];
                    }
                }

                return $carry;
            },
            []
        );

        // While the graph keeps receiving updates, keep on resolving.
        for ($previousGraph = []; $graph !== $previousGraph;) {
            // Do not update the previous graph before the current iteration
            // has started.
            $previousGraph = $graph;

            // For each package and its dependents in the graph ...
            foreach ($graph as $package => $dependents) {
                // ... Update the dependents of the package with grandparents.
                $graph[$package] = array_reduce(
                    // Determine grandparents by looking up the parents of the
                    // available dependents.
                    $dependents,
                    function (array $carry, string $parent) use ($graph): array {
                        foreach ($graph[$parent] ?? [] as $grandparent) {
                            if (!in_array($grandparent, $carry, true)) {
                                $carry[] = $grandparent;
                            }
                        }

                        return $carry;
                    },
                    // Start out with the current list of dependents.
                    $dependents
                );
            }
        }

        return $graph;
    }
375817
function getPackages() {
	var results = [];

	if (extensions && extensions.hasOwnProperty('packages')) {
		var sourceArray = extensions.packages;

		for (index = 0; index < sourceArray.length; ++index) {
		    results.push(sourceArray[index]);
		}
	}

	return results;
}
620060
private function packageRegistered($package)
    {
        $package_registered = array_key_exists($package, $this->packages);

        if ($package_registered) {
            $this->updateLog("info", "Package {$package} is registered");
        } else {
            $this->updateLog("info", "Package {$package} is not registered");
        }

        return $package_registered;
    }
56827
def get_canonical_names(packages):
    """"""
    from .vendor.packaging.utils import canonicalize_name

    if not isinstance(packages, Sequence):
        if not isinstance(packages, six.string_types):
            return packages
        packages = [packages]
    return set([canonicalize_name(pkg) for pkg in packages if pkg])
716985
public Blade scanPackages(@NonNull String... packages) {
        this.packages.addAll(Arrays.asList(packages));
        return this;
    }
1289849
public static function getListByPackage($pkg)
    {
        $db = Loader::db();
        $list = [];

        $q = $db->query('SELECT * FROM AuthenticationTypes WHERE pkgID=?', [$pkg->getPackageID()]);
        while ($row = $q->FetchRow()) {
            $list[] = self::load($row);
        }

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

        return null;
    }