1
0
Fork 0

Merge pull request #7605 from lamp-of-god/check-requirements-no-dev

Add --no-dev option to check-platform-reqs command (#7314)
pull/7623/merge
Jordi Boggiano 2018-09-10 13:52:13 +02:00 committed by GitHub
commit b99ac8505b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 9 deletions

View File

@ -17,6 +17,7 @@ use Composer\Package\PackageInterface;
use Composer\Semver\Constraint\Constraint;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\Repository\PlatformRepository;
@ -26,6 +27,9 @@ class CheckPlatformReqsCommand extends BaseCommand
{
$this->setName('check-platform-reqs')
->setDescription('Check that platform requirements are satisfied.')
->setDefinition(array(
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
))
->setHelp(
<<<EOT
Checks that your PHP and extensions versions match the platform requirements of the installed packages.
@ -40,22 +44,22 @@ EOT
{
$composer = $this->getComposer();
$repos = $composer->getRepositoryManager()->getLocalRepository();
$allPackages = array_merge(array($composer->getPackage()), $repos->getPackages());
$requires = $composer->getPackage()->getDevRequires();
$requires = $composer->getPackage()->getRequires();
if (!$input->getOption('no-dev')) {
$requires += $composer->getPackage()->getDevRequires();
}
foreach ($requires as $require => $link) {
$requires[$require] = array($link);
}
/**
* @var PackageInterface $package
*/
foreach ($allPackages as $package) {
$locker = $composer->getLocker()
->getLockedRepository(!$input->getOption('no-dev'));
foreach ($locker->getPackages() as $package) {
foreach ($package->getRequires() as $require => $link) {
$requires[$require][] = $link;
}
}
ksort($requires);
$platformRepo = new PlatformRepository(array(), array());
@ -74,7 +78,7 @@ EOT
$exitCode = 0;
/**
* @var Link $require
* @var Link[] $links
*/
foreach ($requires as $require => $links) {
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $require)) {