|
24 | 24 | use Composer\Plugin\PluginInterface; |
25 | 25 | use Composer\Script\Event as ScriptEvent; |
26 | 26 | use Composer\Script\ScriptEvents; |
| 27 | +use Symfony\Component\Console\Input\ArgvInput; |
27 | 28 |
|
28 | 29 | /** |
29 | 30 | * Composer plugin that allows merging multiple composer.json files. |
@@ -373,13 +374,32 @@ public function onPostInstallOrUpdate(ScriptEvent $event) |
373 | 374 | $installer->setUpdate(true); |
374 | 375 |
|
375 | 376 | if ($this->state->isComposer1()) { |
376 | | - // setUpdateWhitelist() only exists in composer 1.x. Configure as to run phan against composer 2.x |
| 377 | + // setUpdateWhitelist() only exists in composer 1.x. |
| 378 | + // Configure as to run phan against composer 2.x |
377 | 379 | // @phan-suppress-next-line PhanUndeclaredMethod |
378 | 380 | $installer->setUpdateWhitelist($requirements); |
379 | 381 | } else { |
380 | 382 | $installer->setUpdateAllowList($requirements); |
381 | 383 | } |
382 | 384 |
|
| 385 | + // Respect --ignore-platform-reqs option from input or |
| 386 | + // COMPOSER_IGNORE_PLATFORM_REQS environment variable. |
| 387 | + $input = new ArgvInput(); |
| 388 | + if ($this->state->isComposer1()) { |
| 389 | + // setIgnorePlatformRequirements only exists in composer 1.x. |
| 390 | + // Configure as to run phan against composer 2.x |
| 391 | + // @phan-suppress-next-line PhanUndeclaredMethod |
| 392 | + $installer->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')); |
| 393 | + } else { |
| 394 | + $ignore_platform_reqs = getenv('COMPOSER_IGNORE_PLATFORM_REQS') ?? |
| 395 | + $input->getOption('ignore-platform-reqs'); |
| 396 | + $ignore_platform_reqs = |
| 397 | + \Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory::fromBoolOrList( |
| 398 | + $ignore_platform_reqs |
| 399 | + ); |
| 400 | + $installer->setPlatformRequirementFilter($ignore_platform_reqs); |
| 401 | + } |
| 402 | + |
383 | 403 | $status = $installer->run(); |
384 | 404 | if (( $status !== 0 ) && $lockBackup && $lock && !$this->state->isComposer1()) { |
385 | 405 | $this->logger->log( |
|
0 commit comments