function FixtureManipulator::removePackage

Removes a package.

Parameters

string $name: The name of the package to remove.

bool $is_dev_requirement: Whether the package is a developer requirement.

File

core/modules/package_manager/tests/modules/fixture_manipulator/src/FixtureManipulator.php, line 236

Class

FixtureManipulator
Manipulates a test fixture using Composer commands.

Namespace

Drupal\fixture_manipulator

Code

public function removePackage(string $name, bool $is_dev_requirement = FALSE) : self {
    if (!$this->committingChanges) {
        $this->queueManipulation('removePackage', func_get_args());
        return $this;
    }
    $output = $this->runComposerCommand(array_filter([
        'remove',
        $name,
        $is_dev_requirement ? '--dev' : NULL,
    ]));
    // `composer remove` will not set exit code 1 whenever a non-required
    // package is being removed.
    // @see \Composer\Command\RemoveCommand
    if (str_contains($output->stderr, 'not required in your composer.json and has not been removed')) {
        $output->stderr = str_replace("./composer.json has been updated\n", '', $output->stderr);
        throw new \LogicException($output->stderr);
    }
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.