class Composer
Provides static functions for composer script events.
Hierarchy
- class \Drupal\Core\Composer\Composer
Expanded class hierarchy of Composer
See also
https://getcomposer.org/doc/articles/scripts.md
17 string references to 'Composer'
- ComposerInspector::getVersion in core/
modules/ package_manager/ src/ ComposerInspector.php - Returns the current Composer version.
- ComposerInspectorTest::mockComposerRunner in core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerInspectorTest.php - Mocks the Composer runner service to return a particular version string.
- ComposerRequirementTest::testComposerInfoShown in core/
modules/ package_manager/ tests/ src/ Functional/ ComposerRequirementTest.php - Tests that Composer version and path are listed on the status report.
- ComposerRunner::run in core/
modules/ package_manager/ src/ ComposerRunner.php - ExecutableFinder::find in core/
modules/ package_manager/ src/ ExecutableFinder.php
File
-
core/
lib/ Drupal/ Core/ Composer/ Composer.php, line 14
Namespace
Drupal\Core\ComposerView source
class Composer {
/**
* Add vendor classes to Composer's static classmap.
*
* @param \Composer\Script\Event $event
* The event.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Use
* \Drupal\Composer\Plugin\Scaffold\Plugin::preAutoloadDump() instead.
*
* @see https://www.drupal.org/node/3531162
*/
public static function preAutoloadDump(Event $event) {
@trigger_error('\\Drupal\\Core\\Composer\\Composer::preAutoloadDump() is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Use \\Drupal\\Composer\\Plugin\\Scaffold\\Plugin::preAutoloadDump() instead. See https://www.drupal.org/node/3531162', E_USER_DEPRECATED);
Plugin::preAutoloadDump($event);
}
/**
* Fires the drupal-phpunit-upgrade script event if necessary.
*
* @param \Composer\Script\Event $event
* The event.
*
* @internal
*/
public static function upgradePHPUnit(Event $event) {
$repository = $event->getComposer()
->getRepositoryManager()
->getLocalRepository();
// This is, essentially, a null constraint. We only care whether the package
// is present in the vendor directory yet, but findPackage() requires it.
$constraint = new Constraint('>', '');
$phpunit_package = $repository->findPackage('phpunit/phpunit', $constraint);
if (!$phpunit_package) {
// There is nothing to do. The user is probably installing using the
// --no-dev flag.
return;
}
// If the PHP version is 8.4 or above and PHPUnit is less than version 11
// call the drupal-phpunit-upgrade script to upgrade PHPUnit.
if (!static::upgradePHPUnitCheck($phpunit_package->getVersion())) {
$event->getComposer()
->getEventDispatcher()
->dispatchScript('drupal-phpunit-upgrade');
}
}
/**
* Determines if PHPUnit needs to be upgraded.
*
* This method is located in this file because it is possible that it is
* called before the autoloader is available.
*
* @param string $phpunit_version
* The PHPUnit version string.
*
* @return bool
* TRUE if the PHPUnit needs to be upgraded, FALSE if not.
*
* @internal
*/
public static function upgradePHPUnitCheck($phpunit_version) {
return !(version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '8.4') >= 0 && version_compare($phpunit_version, '11.0') < 0);
}
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary |
|---|---|---|---|---|
| Composer::preAutoloadDump | Deprecated | public static | function | Add vendor classes to Composer's static classmap. |
| Composer::upgradePHPUnit | public static | function | Fires the drupal-phpunit-upgrade script event if necessary. | |
| Composer::upgradePHPUnitCheck | public static | function | Determines if PHPUnit needs to be upgraded. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.