* * @method self::ERROR_DEPENDENCY_RESOLUTION_FAILED getCode() */ class SolverProblemsException extends \RuntimeException { public const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2; /** @var Problem[] */ protected $problems; /** @var array */ protected $learnedPool; /** * @param Problem[] $problems * @param array $learnedPool */ public function __construct(array $problems, array $learnedPool) { $this->problems = $problems; $this->learnedPool = $learnedPool; parent::__construct('Failed resolving dependencies with '.\count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED); } public function getPrettyString( RepositorySet $repositorySet, Request $request, Pool $pool, bool $isVerbose, bool $isDevExtraction = false, ): string { $installedMap = $request->getPresentMap(true); $missingExtensions = []; $isCausedByLock = false; $problems = []; foreach ($this->problems as $problem) { $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n"; $missingExtensions = array_merge($missingExtensions, $this->getExtensionProblems($problem->getReasons())); $isCausedByLock = $isCausedByLock || $problem->isCausedByLock($repositorySet, $request, $pool); } $i = 1; $text = "\n"; foreach (array_unique($problems) as $problem) { $text .= " Problem ".($i++).$problem; } $hints = []; if (!$isDevExtraction && (str_contains($text, 'could not be found') || str_contains($text, 'no matching package found'))) { $hints[] = "Potential causes:\n - A typo in the package name\n - The package is not available in a stable-enough version according to your minimum-stability setting\n see for more details.\n - It's a private package and you forgot to add a custom repository to find it\n\nRead for further common problems."; } if (\count($missingExtensions) > 0) { $hints[] = $this->createExtensionHint($missingExtensions); } if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) { $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions."; } if (str_contains($text, 'found composer-plugin-api[2.0.0] but it does not match') && str_contains($text, '- ocramius/package-versions')) { $hints[] = "ocramius/package-versions only provides support for Composer 2 in 1.8+, which requires PHP 7.4.\nIf you can not upgrade PHP you can require composer/package-versions-deprecated to resolve this with PHP 7.0+."; } if (!class_exists('PHPUnit\Framework\TestCase', false)) { if (str_contains($text, 'found composer-plugin-api[2.0.0] but it does not match')) { $hints[] = "You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2."; } } if (\count($hints) > 0) { $text .= "\n" . implode("\n\n", $hints); } return $text; } /** * @return Problem[] */ public function getProblems(): array { return $this->problems; } /** * @param string[] $missingExtensions */ private function createExtensionHint(array $missingExtensions): string { $paths = IniHelper::getAll(); if ('' === $paths[0]) { if (count($paths) === 1) { return ''; } array_shift($paths); } $ignoreExtensionsArguments = implode(" ", array_map(static function ($extension) { return "--ignore-platform-req=$extension"; }, array_unique($missingExtensions))); $text = "To enable extensions, verify that they are enabled in your .ini files:\n - "; $text .= implode("\n - ", $paths); $text .= "\nYou can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode."; $text .= "\nAlternatively, you can run Composer with `$ignoreExtensionsArguments` to temporarily ignore these required extensions."; return $text; } /** * @param Rule[][] $reasonSets * @return string[] */ private function getExtensionProblems(array $reasonSets): array { $missingExtensions = []; foreach ($reasonSets as $reasonSet) { foreach ($reasonSet as $rule) { $required = $rule->getRequiredPackage(); if (null !== $required && 0 === strpos($required, 'ext-')) { $missingExtensions[$required] = 1; } } } return array_keys($missingExtensions); } }__halt_compiler();----SIGNATURE:----eikkriQjWDVMZ+SjWCdge/W6/rB4vf145cWej9cU2k0lPfwcWhvzrW22Az32n0fMwX5G0bxbZPBg9wi2G+RfIqT1gGWBxtQMah0RJjitOpI8Tt0Eo65Og3B0sXdlI00JXBHeraWc92msttIIDCxj17vGbPXlF9uSf7eYfGinxeRcjAF1d8T4zA4DZdyD+aFWYSO2MkLp4fryDko6aWZ3q5rkkr8X8LkmceYwvouXFnxr656ah17eYSsoA8VWMgUT/IyWxuuJZMEvTSXiFO/Rf07D/DsC8Bwa7K1B7gVkrb4jwsky5CbFkG/cZUZNmy9xj0O57J6q1KbFlT+oa1WhYVZqRSF1VyRT5/F1Kr4VmAdYlbUpERC+aWNIDgIPqt8OFd3Egy+JK1rBo2AG9z9luIK5kUVvSCEAw4seB2YXaNBjwTKi0LBBMBYfe84OuD6rAv+91jLILr9xX5JrGrTXSQ89ZZw4rRyVvaZXQ4L9YNRfhMsj9RGZ6AuZYstdL+H7v0DhVz9VjFuO6hWx+tnd3hHxXwDdwXIF+eU1qxmKLICzJC0BFtU9n7yPUS7m4tJ4bvZuZO8FJiH60PY+ovA/0kj821wKxVivEPFY5H115SM0dFagTeJcnt5vf6Whs6Q1/e53YSJeC6HtZUfXGKNSbNfD/Ce8ygHCK5FmCI9bAgk=----ATTACHMENT:----MzE2NzQ0NjcxMTk4NzkyNyA5MTQzNzk2Njg0NzcxMjYyIDU1MjM0OTk3MDI0MzUxNDg=