本文整理匯總了PHP中Composer\Package\PackageInterface::getDevRequires方法的典型用法代碼示例。如果您正苦於以下問題:PHP PackageInterface::getDevRequires方法的具體用法?PHP PackageInterface::getDevRequires怎麽用?PHP PackageInterface::getDevRequires使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Package\PackageInterface
的用法示例。
在下文中一共展示了PackageInterface::getDevRequires方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: checkDependencies
/**
* @param \Composer\IO\IOInterface $io
* @param \Composer\Package\PackageInterface $package
* @return bool
*/
public static function checkDependencies(IOInterface $io, PackageInterface $package)
{
$search = 'wp-cli/wp-cli';
$requires = $package->getRequires();
$requiresDev = $package->getDevRequires();
if (isset($requires[$search]) or isset($requiresDev[$search])) {
return true;
}
$io->writeError('<info>This package is a dependency of `wp-cli/wp-cli`. Skipping.</info>');
return false;
}
示例2: collectDependencies
protected function collectDependencies(Pool $pool, array $collected, PackageInterface $package)
{
$requires = array_merge($package->getRequires(), $package->getDevRequires());
foreach ($requires as $requireLink) {
$requiredPackage = $this->lookupInstalledPackage($pool, $requireLink);
if ($requiredPackage && !isset($collected[$requiredPackage->getName()])) {
$collected[$requiredPackage->getName()] = $requiredPackage;
$collected = $this->collectDependencies($pool, $collected, $requiredPackage);
}
}
return $collected;
}
示例3: isDependentPackage
/**
* Indicate whether a package has the target package as a dependency
*
* @param PackageInterface $package
* @param bool $devMode
* @return bool
*/
private function isDependentPackage(PackageInterface $package, $devMode = false)
{
$packages = $package->getRequires();
if ($devMode) {
$packages = array_merge($packages, $package->getDevRequires());
}
foreach ($packages as $link) {
/** @var \Composer\Package\Link $link */
if ($this->targetPackage === $link->getTarget()) {
return true;
}
}
return false;
}
示例4: isDependantPackage
/**
* Returns true if the supplied package requires the Composer Grunt bridge.
*
* @param PackageInterface $package The package to inspect.
* @param boolean|null $includeDevDependencies True if the dev dependencies should also be inspected.
*
* @return boolean True if the package requires the bridge.
*/
public function isDependantPackage(PackageInterface $package, $includeDevDependencies = null)
{
if (null === $includeDevDependencies) {
$includeDevDependencies = false;
}
foreach ($package->getRequires() as $link) {
if ('johnpbloch/composer-grunt-bridge' === $link->getTarget()) {
return true;
}
}
if ($includeDevDependencies) {
foreach ($package->getDevRequires() as $link) {
if ('johnpbloch/composer-grunt-bridge' === $link->getTarget()) {
return true;
}
}
}
return false;
}
示例5: doInstall
protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = false)
{
$minimumStability = $this->package->getMinimumStability();
$stabilityFlags = $this->package->getStabilityFlags();
// initialize locker to create aliased packages
if (!$this->update && $this->locker->isLocked($devMode)) {
$lockedPackages = $this->locker->getLockedPackages($devMode);
$minimumStability = $this->locker->getMinimumStability();
$stabilityFlags = $this->locker->getStabilityFlags();
}
$this->whitelistUpdateDependencies($localRepo, $devMode, $this->package->getRequires(), $this->package->getDevRequires());
$this->io->write('<info>Loading composer repositories with package information</info>');
// creating repository pool
$pool = new Pool($minimumStability, $stabilityFlags);
$pool->addRepository($installedRepo);
foreach ($this->repositoryManager->getRepositories() as $repository) {
$pool->addRepository($repository);
}
// creating requirements request
$installFromLock = false;
$request = new Request($pool);
$constraint = new VersionConstraint('=', $this->package->getVersion());
$request->install($this->package->getName(), $constraint);
if ($this->update) {
$this->io->write('<info>Updating ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$request->updateAll();
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
} elseif ($this->locker->isLocked($devMode)) {
$installFromLock = true;
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies from lock file</info>');
if (!$this->locker->isFresh() && !$devMode) {
$this->io->write('<warning>Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies</warning>');
}
foreach ($lockedPackages as $package) {
$version = $package->getVersion();
foreach ($aliases as $alias) {
if ($alias['package'] === $package->getName() && $alias['version'] === $package->getVersion()) {
$version = $alias['alias_normalized'];
break;
}
}
$constraint = new VersionConstraint('=', $version);
$request->install($package->getName(), $constraint);
}
} else {
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
}
// fix the version of all installed packages (+ platform) that are not
// in the current local repo to prevent rogue updates (e.g. non-dev
// updating when in dev)
foreach ($installedRepo->getPackages() as $package) {
if ($package->getRepository() === $localRepo) {
continue;
}
$constraint = new VersionConstraint('=', $package->getVersion());
$request->install($package->getName(), $constraint);
}
// if the updateWhitelist is enabled, packages not in it are also fixed
// to the version specified in the lock, or their currently installed version
if ($this->update && $this->updateWhitelist) {
if ($this->locker->isLocked($devMode)) {
$currentPackages = $this->locker->getLockedPackages($devMode);
} else {
$currentPackages = $installedRepo->getPackages();
}
// collect links from composer as well as installed packages
$candidates = array();
foreach ($links as $link) {
$candidates[$link->getTarget()] = true;
}
foreach ($localRepo->getPackages() as $package) {
$candidates[$package->getName()] = true;
}
// fix them to the version in lock (or currently installed) if they are not updateable
foreach ($candidates as $candidate => $dummy) {
foreach ($currentPackages as $curPackage) {
if ($curPackage->getName() === $candidate) {
if ($this->isUpdateable($curPackage)) {
break;
}
$constraint = new VersionConstraint('=', $curPackage->getVersion());
$request->install($curPackage->getName(), $constraint);
}
}
}
}
// prepare solver
$policy = new DefaultPolicy();
$solver = new Solver($policy, $pool, $installedRepo);
// solve dependencies
try {
$operations = $solver->solve($request);
} catch (SolverProblemsException $e) {
//.........這裏部分代碼省略.........
示例6: getRequired
/**
* Gets the required Links if needed.
*
* @param PackageInterface $package A package
*
* @return Link[]
*/
private function getRequired(PackageInterface $package)
{
$required = array();
if ($this->requireDependencies) {
$required = $package->getRequires();
}
if ($this->requireDevDependencies) {
$required = array_merge($required, $package->getDevRequires());
}
return $required;
}
示例7: doInstall
protected function doInstall($localRepo, $installedRepo, $aliases, $devMode = false)
{
// creating repository pool
$pool = new Pool();
$pool->addRepository($installedRepo);
foreach ($this->repositoryManager->getRepositories() as $repository) {
$pool->addRepository($repository);
}
// creating requirements request
$installFromLock = false;
$request = new Request($pool);
if ($this->update) {
$this->io->write('<info>Updating ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$request->updateAll();
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
} elseif ($this->locker->isLocked($devMode)) {
$installFromLock = true;
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies from lock file</info>');
if (!$this->locker->isFresh() && !$devMode) {
$this->io->write('<warning>Your lock file is out of sync with your composer.json, run "composer.phar update" to update dependencies</warning>');
}
foreach ($this->locker->getLockedPackages($devMode) as $package) {
$version = $package->getVersion();
foreach ($aliases as $alias) {
if ($alias['package'] === $package->getName() && $alias['version'] === $package->getVersion()) {
$version = $alias['alias'];
break;
}
}
$constraint = new VersionConstraint('=', $version);
$request->install($package->getName(), $constraint);
}
} else {
$this->io->write('<info>Installing ' . ($devMode ? 'dev ' : '') . 'dependencies</info>');
$links = $devMode ? $this->package->getDevRequires() : $this->package->getRequires();
foreach ($links as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
}
// fix the version all installed packages that are not in the current local repo to prevent rogue updates
foreach ($installedRepo->getPackages() as $package) {
if ($package->getRepository() === $localRepo || $package->getRepository() instanceof PlatformRepository) {
continue;
}
$constraint = new VersionConstraint('=', $package->getVersion());
$request->install($package->getName(), $constraint);
}
// prepare solver
$policy = new DefaultPolicy();
$solver = new Solver($policy, $pool, $installedRepo);
// solve dependencies
try {
$operations = $solver->solve($request);
} catch (SolverProblemsException $e) {
$this->io->write('<error>Your requirements could not be solved to an installable set of packages.</error>');
$this->io->write($e->getMessage());
return false;
}
// force dev packages to be updated if we update or install from a (potentially new) lock
if ($this->update || $installFromLock) {
foreach ($localRepo->getPackages() as $package) {
// skip non-dev packages
if (!$package->isDev()) {
continue;
}
// skip packages that will be updated/uninstalled
foreach ($operations as $operation) {
if ('update' === $operation->getJobType() && $operation->getInitialPackage()->equals($package) || 'uninstall' === $operation->getJobType() && $operation->getPackage()->equals($package)) {
continue 2;
}
}
// force update to latest on update
if ($this->update) {
$newPackage = $this->repositoryManager->findPackage($package->getName(), $package->getVersion());
if ($newPackage && $newPackage->getSourceReference() !== $package->getSourceReference()) {
$operations[] = new UpdateOperation($package, $newPackage);
}
} elseif ($installFromLock) {
// force update to locked version if it does not match the installed version
$lockData = $this->locker->getLockData();
unset($lockedReference);
foreach ($lockData['packages'] as $lockedPackage) {
if (!empty($lockedPackage['source-reference']) && strtolower($lockedPackage['package']) === $package->getName()) {
$lockedReference = $lockedPackage['source-reference'];
break;
}
}
if (isset($lockedReference) && $lockedReference !== $package->getSourceReference()) {
// changing the source ref to update to will be handled in the operations loop below
$operations[] = new UpdateOperation($package, $package);
}
}
}
}
// anti-alias local repository to allow updates to work fine
foreach ($localRepo->getPackages() as $package) {
if ($package instanceof AliasPackage) {
//.........這裏部分代碼省略.........
示例8: getDevRequires
/**
* {@inheritdoc}
*/
public function getDevRequires()
{
return $this->package->getDevRequires();
}
示例9: isDependantPackage
/**
* Returns true if the supplied package requires the Composer NPM bridge.
*
* @param PackageInterface $package The package to inspect.
* @param boolean $includeDevDependencies True if the dev dependencies should also be inspected.
*
* @return boolean True if the package requires the bridge.
*/
public function isDependantPackage(PackageInterface $package, $includeDevDependencies = false)
{
foreach ($package->getRequires() as $link) {
if ('eloquent/composer-npm-bridge' === $link->getTarget()) {
return true;
}
}
if ($includeDevDependencies) {
foreach ($package->getDevRequires() as $link) {
if ('eloquent/composer-npm-bridge' === $link->getTarget()) {
return true;
}
}
}
return false;
}
示例10: isDependantPackage
/**
* Returns true if the supplied package requires the Composer NPM bridge.
*
* @param PackageInterface $package The package to inspect.
* @param bool|null $dev_mode True if the dev dependencies should also be inspected.
*
* @return bool True if the package requires the bridge.
*/
public function isDependantPackage(PackageInterface $package, $dev_mode = null)
{
if ($package->getName() === 'apishka/easy-extend') {
return true;
}
foreach ($package->getRequires() as $link) {
if ($link->getTarget() === 'apishka/easy-extend') {
return true;
}
}
if ($dev_mode) {
foreach ($package->getDevRequires() as $link) {
if ($link->getTarget() === 'apishka/easy-extend') {
return true;
}
}
}
return false;
}