diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php
index 0242afcd3..7bf3fed15 100644
--- a/src/Composer/Command/CreateProjectCommand.php
+++ b/src/Composer/Command/CreateProjectCommand.php
@@ -149,7 +149,7 @@ EOT
if ($noScripts === false) {
// dispatch event
- $composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
+ $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
}
$rootPackageConfig = $composer->getConfig();
@@ -217,7 +217,7 @@ EOT
if ($noScripts === false) {
// dispatch event
- $composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
+ $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
}
chdir($oldCwd);
diff --git a/src/Composer/Command/RunScriptCommand.php b/src/Composer/Command/RunScriptCommand.php
index 91a9b2abe..7e9fe6845 100644
--- a/src/Composer/Command/RunScriptCommand.php
+++ b/src/Composer/Command/RunScriptCommand.php
@@ -27,7 +27,7 @@ class RunScriptCommand extends Command
/**
* @var array Array with command events
*/
- protected $commandEvents = array(
+ protected $scriptEvents = array(
ScriptEvents::PRE_INSTALL_CMD,
ScriptEvents::POST_INSTALL_CMD,
ScriptEvents::PRE_UPDATE_CMD,
@@ -35,17 +35,11 @@ class RunScriptCommand extends Command
ScriptEvents::PRE_STATUS_CMD,
ScriptEvents::POST_STATUS_CMD,
ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
- ScriptEvents::POST_CREATE_PROJECT_CMD
- );
-
- /**
- * @var array Array with script events
- */
- protected $scriptEvents = array(
+ ScriptEvents::POST_CREATE_PROJECT_CMD,
ScriptEvents::PRE_ARCHIVE_CMD,
ScriptEvents::POST_ARCHIVE_CMD,
ScriptEvents::PRE_AUTOLOAD_DUMP,
- ScriptEvents::POST_AUTOLOAD_DUMP
+ ScriptEvents::POST_AUTOLOAD_DUMP,
);
protected function configure()
@@ -78,7 +72,7 @@ EOT
}
$script = $input->getArgument('script');
- if (!in_array($script, $this->commandEvents) && !in_array($script, $this->scriptEvents)) {
+ if (!in_array($script, $this->scriptEvents)) {
if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
}
@@ -98,10 +92,6 @@ EOT
$args = $input->getArgument('args');
- if (in_array($script, $this->commandEvents)) {
- return $composer->getEventDispatcher()->dispatchCommandEvent($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args);
- }
-
return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args);
}
diff --git a/src/Composer/Command/StatusCommand.php b/src/Composer/Command/StatusCommand.php
index 65662c048..e458c8fb9 100644
--- a/src/Composer/Command/StatusCommand.php
+++ b/src/Composer/Command/StatusCommand.php
@@ -57,7 +57,7 @@ EOT
$im = $composer->getInstallationManager();
// Dispatch pre-status-command
- $composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::PRE_STATUS_CMD, true);
+ $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
$errors = array();
@@ -98,7 +98,7 @@ EOT
}
// Dispatch post-status-command
- $composer->getEventDispatcher()->dispatchCommandEvent(ScriptEvents::POST_STATUS_CMD, true);
+ $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
return $errors ? 1 : 0;
}
diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php
index dff5456e1..71fa01a41 100644
--- a/src/Composer/EventDispatcher/EventDispatcher.php
+++ b/src/Composer/EventDispatcher/EventDispatcher.php
@@ -21,7 +21,6 @@ use Composer\Composer;
use Composer\DependencyResolver\Operation\OperationInterface;
use Composer\Repository\CompositeRepository;
use Composer\Script;
-use Composer\Script\CommandEvent;
use Composer\Script\PackageEvent;
use Composer\Util\ProcessExecutor;
@@ -95,36 +94,28 @@ class EventDispatcher
/**
* Dispatch a package event.
*
- * @param string $eventName The constant in ScriptEvents
- * @param boolean $devMode Whether or not we are in dev mode
- * @param OperationInterface $operation The package being installed/updated/removed
- * @return int return code of the executed script if any, for php scripts a false return
- * value is changed to 1, anything else to 0
- */
- public function dispatchPackageEvent($eventName, $devMode, OperationInterface $operation)
- {
- return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $operation));
- }
-
- /**
- * Dispatch a command event.
+ * @param string $eventName The constant in PackageEvents
+ * @param bool $devMode Whether or not we are in dev mode
+ * @param PolicyInterface $policy The policy
+ * @param Pool $pool The pool
+ * @param CompositeRepository $installedRepo The installed repository
+ * @param Request $request The request
+ * @param array $operations The list of operations
+ * @param OperationInterface $operation The package being installed/updated/removed
*
- * @param string $eventName The constant in ScriptEvents
- * @param boolean $devMode Whether or not we are in dev mode
- * @param array $additionalArgs Arguments passed by the user
- * @param array $flags Optional flags to pass data not as argument
- * @return int return code of the executed script if any, for php scripts a false return
- * value is changed to 1, anything else to 0
+ * @return int return code of the executed script if any, for php scripts a false return
+ * value is changed to 1, anything else to 0
*/
- public function dispatchCommandEvent($eventName, $devMode, $additionalArgs = array(), $flags = array())
+ public function dispatchPackageEvent($eventName, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations, OperationInterface $operation)
{
- return $this->doDispatch(new CommandEvent($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
+ return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $policy, $pool, $installedRepo, $request, $operations, $operation));
}
/**
* Dispatch a installer event.
*
* @param string $eventName The constant in InstallerEvents
+ * @param bool $devMode Whether or not we are in dev mode
* @param PolicyInterface $policy The policy
* @param Pool $pool The pool
* @param CompositeRepository $installedRepo The installed repository
@@ -134,9 +125,9 @@ class EventDispatcher
* @return int return code of the executed script if any, for php scripts a false return
* value is changed to 1, anything else to 0
*/
- public function dispatchInstallerEvent($eventName, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations = array())
+ public function dispatchInstallerEvent($eventName, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations = array())
{
- return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $policy, $pool, $installedRepo, $request, $operations));
+ return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $policy, $pool, $installedRepo, $request, $operations));
}
/**
@@ -232,8 +223,18 @@ class EventDispatcher
$expected = $typehint->getName();
+ // BC support
if (!$event instanceof $expected && $expected === 'Composer\Script\CommandEvent') {
- $event = new CommandEvent($event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(), $event->getArguments());
+ $event = new \Composer\Script\CommandEvent(
+ $event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(), $event->getArguments()
+ );
+ }
+ if (!$event instanceof $expected && $expected === 'Composer\Script\PackageEvent') {
+ $event = new \Composer\Script\PackageEvent(
+ $event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(),
+ $event->getPolicy(), $event->getPool(), $event->getInstalledRepo(), $event->getRequest(),
+ $event->getOperations(), $event->getOperation()
+ );
}
return $event;
diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php
index 518f6c20d..d852cc589 100644
--- a/src/Composer/Installer.php
+++ b/src/Composer/Installer.php
@@ -192,7 +192,7 @@ class Installer
if ($this->runScripts) {
// dispatch pre event
$eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
- $this->eventDispatcher->dispatchCommandEvent($eventName, $this->devMode);
+ $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
}
$this->downloadManager->setPreferSource($this->preferSource);
@@ -289,10 +289,10 @@ class Installer
$request->install($link->getTarget(), $link->getConstraint());
}
- $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request);
+ $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request);
$solver = new Solver($policy, $pool, $installedRepo);
$ops = $solver->solve($request, $this->ignorePlatformReqs);
- $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request, $ops);
+ $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request, $ops);
foreach ($ops as $op) {
if ($op->getJobType() === 'uninstall') {
$devPackages[] = $op->getPackage();
@@ -334,7 +334,7 @@ class Installer
if ($this->runScripts) {
// dispatch post event
$eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
- $this->eventDispatcher->dispatchCommandEvent($eventName, $this->devMode);
+ $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
}
$vendorDir = $this->config->get('vendor-dir');
@@ -498,11 +498,11 @@ class Installer
$this->processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, 'force-links');
// solve dependencies
- $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request);
+ $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request);
$solver = new Solver($policy, $pool, $installedRepo);
try {
$operations = $solver->solve($request, $this->ignorePlatformReqs);
- $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request, $operations);
+ $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request, $operations);
} catch (SolverProblemsException $e) {
$this->io->write('Your requirements could not be resolved to an installable set of packages.');
$this->io->write($e->getMessage());
@@ -562,9 +562,9 @@ class Installer
}
}
- $event = 'Composer\Script\ScriptEvents::PRE_PACKAGE_'.strtoupper($operation->getJobType());
+ $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($operation->getJobType());
if (defined($event) && $this->runScripts) {
- $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $operation);
+ $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
}
// output non-alias ops in dry run, output alias ops in debug verbosity
@@ -595,9 +595,9 @@ class Installer
}
}
- $event = 'Composer\Script\ScriptEvents::POST_PACKAGE_'.strtoupper($operation->getJobType());
+ $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($operation->getJobType());
if (defined($event) && $this->runScripts) {
- $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $operation);
+ $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
}
if (!$this->dryRun) {
diff --git a/src/Composer/Installer/InstallerEvent.php b/src/Composer/Installer/InstallerEvent.php
index a9f5a728a..87153bd51 100644
--- a/src/Composer/Installer/InstallerEvent.php
+++ b/src/Composer/Installer/InstallerEvent.php
@@ -38,6 +38,11 @@ class InstallerEvent extends Event
*/
private $io;
+ /**
+ * @var bool
+ */
+ private $devMode;
+
/**
* @var PolicyInterface
*/
@@ -69,18 +74,20 @@ class InstallerEvent extends Event
* @param string $eventName
* @param Composer $composer
* @param IOInterface $io
+ * @param bool $devMode
* @param PolicyInterface $policy
* @param Pool $pool
* @param CompositeRepository $installedRepo
* @param Request $request
* @param OperationInterface[] $operations
*/
- public function __construct($eventName, Composer $composer, IOInterface $io, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations = array())
+ public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations = array())
{
parent::__construct($eventName);
$this->composer = $composer;
$this->io = $io;
+ $this->devMode = $devMode;
$this->policy = $policy;
$this->pool = $pool;
$this->installedRepo = $installedRepo;
@@ -104,6 +111,14 @@ class InstallerEvent extends Event
return $this->io;
}
+ /**
+ * @return bool
+ */
+ public function isDevMode()
+ {
+ return $this->devMode;
+ }
+
/**
* @return PolicyInterface
*/
diff --git a/src/Composer/Installer/PackageEvent.php b/src/Composer/Installer/PackageEvent.php
new file mode 100644
index 000000000..527a5b6a2
--- /dev/null
+++ b/src/Composer/Installer/PackageEvent.php
@@ -0,0 +1,69 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Installer;
+
+use Composer\Composer;
+use Composer\IO\IOInterface;
+use Composer\DependencyResolver\Operation\OperationInterface;
+
+/**
+ * The Package Event.
+ *
+ * @author Jordi Boggiano
+ */
+class PackageEvent extends InstallerEvent
+{
+ /**
+ * @var OperationInterface The package instance
+ */
+ private $operation;
+
+ /**
+ * Constructor.
+ *
+ * @param string $eventName
+ * @param Composer $composer
+ * @param IOInterface $io
+ * @param bool $devMode
+ * @param PolicyInterface $policy
+ * @param Pool $pool
+ * @param CompositeRepository $installedRepo
+ * @param Request $request
+ * @param OperationInterface[] $operations
+ * @param OperationInterface $operation
+ */
+ public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations, OperationInterface $operation)
+ {
+ parent::__construct($eventName);
+
+ $this->composer = $composer;
+ $this->io = $io;
+ $this->devMode = $devMode;
+ $this->policy = $policy;
+ $this->pool = $pool;
+ $this->installedRepo = $installedRepo;
+ $this->request = $request;
+ $this->operations = $operations;
+ $this->operation = $operation;
+ }
+
+ /**
+ * Returns the package instance.
+ *
+ * @return OperationInterface
+ */
+ public function getOperation()
+ {
+ return $this->operation;
+ }
+}
diff --git a/src/Composer/Installer/PackageEvents.php b/src/Composer/Installer/PackageEvents.php
new file mode 100644
index 000000000..637b7fb45
--- /dev/null
+++ b/src/Composer/Installer/PackageEvents.php
@@ -0,0 +1,75 @@
+
+ * Jordi Boggiano
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Installer;
+
+/**
+ * Package Events.
+ *
+ * @author Jordi Boggiano
+ */
+class PackageEvents
+{
+ /**
+ * The PRE_PACKAGE_INSTALL event occurs before a package is installed.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @var string
+ */
+ const PRE_PACKAGE_INSTALL = 'pre-package-install';
+
+ /**
+ * The POST_PACKAGE_INSTALL event occurs after a package is installed.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @var string
+ */
+ const POST_PACKAGE_INSTALL = 'post-package-install';
+
+ /**
+ * The PRE_PACKAGE_UPDATE event occurs before a package is updated.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @var string
+ */
+ const PRE_PACKAGE_UPDATE = 'pre-package-update';
+
+ /**
+ * The POST_PACKAGE_UPDATE event occurs after a package is updated.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @var string
+ */
+ const POST_PACKAGE_UPDATE = 'post-package-update';
+
+ /**
+ * The PRE_PACKAGE_UNINSTALL event occurs before a package has been uninstalled.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @var string
+ */
+ const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
+
+ /**
+ * The POST_PACKAGE_UNINSTALL event occurs after a package has been uninstalled.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @var string
+ */
+ const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
+}
diff --git a/src/Composer/Script/CommandEvent.php b/src/Composer/Script/CommandEvent.php
index 48ea2246a..84c52008c 100644
--- a/src/Composer/Script/CommandEvent.php
+++ b/src/Composer/Script/CommandEvent.php
@@ -15,7 +15,7 @@ namespace Composer\Script;
/**
* The Command Event.
*
- * @author François Pluchino
+ * @deprecated use Composer\Script\Event instead
*/
class CommandEvent extends Event
{
diff --git a/src/Composer/Script/PackageEvent.php b/src/Composer/Script/PackageEvent.php
index 735de0021..531b86a40 100644
--- a/src/Composer/Script/PackageEvent.php
+++ b/src/Composer/Script/PackageEvent.php
@@ -12,44 +12,13 @@
namespace Composer\Script;
-use Composer\Composer;
-use Composer\IO\IOInterface;
-use Composer\DependencyResolver\Operation\OperationInterface;
+use Composer\Installer\PackageEvent as BasePackageEvent;
/**
* The Package Event.
*
- * @author Jordi Boggiano
+ * @deprecated Use Composer\Installer\PackageEvent instead
*/
-class PackageEvent extends Event
+class PackageEvent extends BasePackageEvent
{
- /**
- * @var OperationInterface The package instance
- */
- private $operation;
-
- /**
- * Constructor.
- *
- * @param string $name The event name
- * @param Composer $composer The composer object
- * @param IOInterface $io The IOInterface object
- * @param boolean $devMode Whether or not we are in dev mode
- * @param OperationInterface $operation The operation object
- */
- public function __construct($name, Composer $composer, IOInterface $io, $devMode, OperationInterface $operation)
- {
- parent::__construct($name, $composer, $io, $devMode);
- $this->operation = $operation;
- }
-
- /**
- * Returns the package instance.
- *
- * @return OperationInterface
- */
- public function getOperation()
- {
- return $this->operation;
- }
}
diff --git a/src/Composer/Script/ScriptEvents.php b/src/Composer/Script/ScriptEvents.php
index 616b2b97e..65baf2cc4 100644
--- a/src/Composer/Script/ScriptEvents.php
+++ b/src/Composer/Script/ScriptEvents.php
@@ -74,59 +74,7 @@ class ScriptEvents
*/
const POST_STATUS_CMD = 'post-status-cmd';
- /**
- * The PRE_PACKAGE_INSTALL event occurs before a package is installed.
- *
- * The event listener method receives a Composer\Script\PackageEvent instance.
- *
- * @var string
- */
- const PRE_PACKAGE_INSTALL = 'pre-package-install';
-
- /**
- * The POST_PACKAGE_INSTALL event occurs after a package is installed.
- *
- * The event listener method receives a Composer\Script\PackageEvent instance.
- *
- * @var string
- */
- const POST_PACKAGE_INSTALL = 'post-package-install';
-
- /**
- * The PRE_PACKAGE_UPDATE event occurs before a package is updated.
- *
- * The event listener method receives a Composer\Script\PackageEvent instance.
- *
- * @var string
- */
- const PRE_PACKAGE_UPDATE = 'pre-package-update';
-
- /**
- * The POST_PACKAGE_UPDATE event occurs after a package is updated.
- *
- * The event listener method receives a Composer\Script\PackageEvent instance.
- *
- * @var string
- */
- const POST_PACKAGE_UPDATE = 'post-package-update';
-
- /**
- * The PRE_PACKAGE_UNINSTALL event occurs before a package has been uninstalled.
- *
- * The event listener method receives a Composer\Script\PackageEvent instance.
- *
- * @var string
- */
- const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
-
- /**
- * The POST_PACKAGE_UNINSTALL event occurs after a package has been uninstalled.
- *
- * The event listener method receives a Composer\Script\PackageEvent instance.
- *
- * @var string
- */
- const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
+ /** Deprecated constants below */
/**
* The PRE_AUTOLOAD_DUMP event occurs before the autoload file is generated.
@@ -182,4 +130,64 @@ class ScriptEvents
* @var string
*/
const POST_ARCHIVE_CMD = 'post-archive-cmd';
+
+ /**
+ * The PRE_PACKAGE_INSTALL event occurs before a package is installed.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @deprecated Use Composer\Installer\PackageEvents::PRE_PACKAGE_INSTALL instead.
+ * @var string
+ */
+ const PRE_PACKAGE_INSTALL = 'pre-package-install';
+
+ /**
+ * The POST_PACKAGE_INSTALL event occurs after a package is installed.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @deprecated Use Composer\Installer\PackageEvents::POST_PACKAGE_INSTALL instead.
+ * @var string
+ */
+ const POST_PACKAGE_INSTALL = 'post-package-install';
+
+ /**
+ * The PRE_PACKAGE_UPDATE event occurs before a package is updated.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @deprecated Use Composer\Installer\PackageEvents::PRE_PACKAGE_UPDATE instead.
+ * @var string
+ */
+ const PRE_PACKAGE_UPDATE = 'pre-package-update';
+
+ /**
+ * The POST_PACKAGE_UPDATE event occurs after a package is updated.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @deprecated Use Composer\Installer\PackageEvents::POST_PACKAGE_UPDATE instead.
+ * @var string
+ */
+ const POST_PACKAGE_UPDATE = 'post-package-update';
+
+ /**
+ * The PRE_PACKAGE_UNINSTALL event occurs before a package has been uninstalled.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @deprecated Use Composer\Installer\PackageEvents::PRE_PACKAGE_UNINSTALL instead.
+ * @var string
+ */
+ const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
+
+ /**
+ * The POST_PACKAGE_UNINSTALL event occurs after a package has been uninstalled.
+ *
+ * The event listener method receives a Composer\Script\PackageEvent instance.
+ *
+ * @deprecated Use Composer\Installer\PackageEvents::POST_PACKAGE_UNINSTALL instead.
+ * @var string
+ */
+ const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
}
diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php
index aaf8b6267..c750e82a9 100644
--- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php
+++ b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php
@@ -36,7 +36,7 @@ class EventDispatcherTest extends TestCase
->method('write')
->with('Script Composer\Test\EventDispatcher\EventDispatcherTest::call handling the post-install-cmd event terminated with an exception');
- $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
+ $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
}
public function testDispatcherCanConvertScriptEventToCommandEventForListener()
@@ -48,7 +48,7 @@ class EventDispatcherTest extends TestCase
$this->assertEquals(1, $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false));
}
-
+
public function testDispatcherDoesNotAttemptConversionForListenerWithoutTypehint()
{
$io = $this->getMock('Composer\IO\IOInterface');
@@ -85,7 +85,7 @@ class EventDispatcherTest extends TestCase
->with($command)
->will($this->returnValue(0));
- $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
+ $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
}
public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack()
@@ -121,7 +121,7 @@ class EventDispatcherTest extends TestCase
->with('Composer\Test\EventDispatcher\EventDispatcherTest', 'someMethod')
->will($this->returnValue(true));
- $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
+ $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
}
private function getDispatcherStubForListenersTest($listeners, $io)
@@ -167,7 +167,7 @@ class EventDispatcherTest extends TestCase
->will($this->returnValue($listener));
ob_start();
- $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
+ $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
$this->assertEquals('foo', trim(ob_get_clean()));
}
@@ -193,7 +193,7 @@ class EventDispatcherTest extends TestCase
->with($this->equalTo('Script '.$code.' handling the post-install-cmd event returned with an error'));
$this->setExpectedException('RuntimeException');
- $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
+ $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false);
}
public function testDispatcherInstallerEvents()
@@ -217,8 +217,8 @@ class EventDispatcherTest extends TestCase
$installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock();
$request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock();
- $dispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request);
- $dispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request, array());
+ $dispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, true, $policy, $pool, $installedRepo, $request);
+ $dispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, true, $policy, $pool, $installedRepo, $request, array());
}
public static function call()
diff --git a/tests/Composer/Test/Installer/InstallerEventTest.php b/tests/Composer/Test/Installer/InstallerEventTest.php
index 7cd63f6b5..1489f5f0e 100644
--- a/tests/Composer/Test/Installer/InstallerEventTest.php
+++ b/tests/Composer/Test/Installer/InstallerEventTest.php
@@ -25,11 +25,12 @@ class InstallerEventTest extends \PHPUnit_Framework_TestCase
$installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock();
$request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock();
$operations = array($this->getMock('Composer\DependencyResolver\Operation\OperationInterface'));
- $event = new InstallerEvent('EVENT_NAME', $composer, $io, $policy, $pool, $installedRepo, $request, $operations);
+ $event = new InstallerEvent('EVENT_NAME', $composer, $io, true, $policy, $pool, $installedRepo, $request, $operations);
$this->assertSame('EVENT_NAME', $event->getName());
$this->assertInstanceOf('Composer\Composer', $event->getComposer());
$this->assertInstanceOf('Composer\IO\IOInterface', $event->getIO());
+ $this->assertTrue($event->isDevMode());
$this->assertInstanceOf('Composer\DependencyResolver\PolicyInterface', $event->getPolicy());
$this->assertInstanceOf('Composer\DependencyResolver\Pool', $event->getPool());
$this->assertInstanceOf('Composer\Repository\CompositeRepository', $event->getInstalledRepo());