From 5a56bb69710cbc2d8fd8fc83fc0654de11059e7f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 12 Nov 2018 15:57:44 +0100 Subject: [PATCH] Remove BC event and constraint classes --- .../EventDispatcher/EventDispatcher.php | 38 ------------------ .../LinkConstraint/EmptyConstraint.php | 24 ------------ .../LinkConstraintInterface.php | 24 ------------ .../LinkConstraint/MultiConstraint.php | 24 ------------ .../LinkConstraint/SpecificConstraint.php | 24 ------------ .../LinkConstraint/VersionConstraint.php | 24 ------------ src/Composer/Script/CommandEvent.php | 22 ----------- src/Composer/Script/PackageEvent.php | 24 ------------ src/Composer/Util/SpdxLicense.php | 24 ------------ src/Composer/XdebugHandler.php | 31 --------------- .../EventDispatcher/EventDispatcherTest.php | 39 ++----------------- 11 files changed, 3 insertions(+), 295 deletions(-) delete mode 100644 src/Composer/Package/LinkConstraint/EmptyConstraint.php delete mode 100644 src/Composer/Package/LinkConstraint/LinkConstraintInterface.php delete mode 100644 src/Composer/Package/LinkConstraint/MultiConstraint.php delete mode 100644 src/Composer/Package/LinkConstraint/SpecificConstraint.php delete mode 100644 src/Composer/Package/LinkConstraint/VersionConstraint.php delete mode 100644 src/Composer/Script/CommandEvent.php delete mode 100644 src/Composer/Script/PackageEvent.php delete mode 100644 src/Composer/Util/SpdxLicense.php delete mode 100644 src/Composer/XdebugHandler.php diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index f0fcdaef6..324190f19 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -321,44 +321,6 @@ class EventDispatcher $expected = $typehint->getName(); - // BC support - if (!$event instanceof $expected && $expected === 'Composer\Script\CommandEvent') { - trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED); - $event = new \Composer\Script\CommandEvent( - $event->getName(), - $event->getComposer(), - $event->getIO(), - $event->isDevMode(), - $event->getArguments() - ); - } - if (!$event instanceof $expected && $expected === 'Composer\Script\PackageEvent') { - trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED); - $event = new \Composer\Script\PackageEvent( - $event->getName(), - $event->getComposer(), - $event->getIO(), - $event->isDevMode(), - $event->getPolicy(), - $event->getRepositorySet(), - $event->getInstalledRepo(), - $event->getRequest(), - $event->getOperations(), - $event->getOperation() - ); - } - if (!$event instanceof $expected && $expected === 'Composer\Script\Event') { - trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED); - $event = new \Composer\Script\Event( - $event->getName(), - $event->getComposer(), - $event->getIO(), - $event->isDevMode(), - $event->getArguments(), - $event->getFlags() - ); - } - return $event; } diff --git a/src/Composer/Package/LinkConstraint/EmptyConstraint.php b/src/Composer/Package/LinkConstraint/EmptyConstraint.php deleted file mode 100644 index 33f9e2e82..000000000 --- a/src/Composer/Package/LinkConstraint/EmptyConstraint.php +++ /dev/null @@ -1,24 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Package\LinkConstraint; - -use Composer\Semver\Constraint\EmptyConstraint as SemverEmptyConstraint; - -trigger_error('The ' . __NAMESPACE__ . '\EmptyConstraint class is deprecated, use Composer\Semver\Constraint\EmptyConstraint instead.', E_USER_DEPRECATED); - -/** - * @deprecated use Composer\Semver\Constraint\EmptyConstraint instead - */ -class EmptyConstraint extends SemverEmptyConstraint implements LinkConstraintInterface -{ -} diff --git a/src/Composer/Package/LinkConstraint/LinkConstraintInterface.php b/src/Composer/Package/LinkConstraint/LinkConstraintInterface.php deleted file mode 100644 index b8903ea8f..000000000 --- a/src/Composer/Package/LinkConstraint/LinkConstraintInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Package\LinkConstraint; - -use Composer\Semver\Constraint\ConstraintInterface; - -trigger_error('The ' . __NAMESPACE__ . '\LinkConstraintInterface interface is deprecated, use Composer\Semver\Constraint\ConstraintInterface instead.', E_USER_DEPRECATED); - -/** - * @deprecated use Composer\Semver\Constraint\ConstraintInterface instead - */ -interface LinkConstraintInterface extends ConstraintInterface -{ -} diff --git a/src/Composer/Package/LinkConstraint/MultiConstraint.php b/src/Composer/Package/LinkConstraint/MultiConstraint.php deleted file mode 100644 index 10a996568..000000000 --- a/src/Composer/Package/LinkConstraint/MultiConstraint.php +++ /dev/null @@ -1,24 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Package\LinkConstraint; - -use Composer\Semver\Constraint\MultiConstraint as SemverMultiConstraint; - -trigger_error('The ' . __NAMESPACE__ . '\MultiConstraint class is deprecated, use Composer\Semver\Constraint\MultiConstraint instead.', E_USER_DEPRECATED); - -/** - * @deprecated use Composer\Semver\Constraint\MultiConstraint instead - */ -class MultiConstraint extends SemverMultiConstraint implements LinkConstraintInterface -{ -} diff --git a/src/Composer/Package/LinkConstraint/SpecificConstraint.php b/src/Composer/Package/LinkConstraint/SpecificConstraint.php deleted file mode 100644 index 12d3194b6..000000000 --- a/src/Composer/Package/LinkConstraint/SpecificConstraint.php +++ /dev/null @@ -1,24 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Package\LinkConstraint; - -use Composer\Semver\Constraint\AbstractConstraint; - -trigger_error('The ' . __NAMESPACE__ . '\SpecificConstraint abstract class is deprecated, there is no replacement for it.', E_USER_DEPRECATED); - -/** - * @deprecated use Composer\Semver\Constraint\AbstractConstraint instead - */ -abstract class SpecificConstraint extends AbstractConstraint implements LinkConstraintInterface -{ -} diff --git a/src/Composer/Package/LinkConstraint/VersionConstraint.php b/src/Composer/Package/LinkConstraint/VersionConstraint.php deleted file mode 100644 index d6b1cbe1d..000000000 --- a/src/Composer/Package/LinkConstraint/VersionConstraint.php +++ /dev/null @@ -1,24 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Package\LinkConstraint; - -use Composer\Semver\Constraint\Constraint; - -trigger_error('The ' . __NAMESPACE__ . '\VersionConstraint class is deprecated, use Composer\Semver\Constraint\Constraint instead.', E_USER_DEPRECATED); - -/** - * @deprecated use Composer\Semver\Constraint\Constraint instead - */ -class VersionConstraint extends Constraint implements LinkConstraintInterface -{ -} diff --git a/src/Composer/Script/CommandEvent.php b/src/Composer/Script/CommandEvent.php deleted file mode 100644 index 84c52008c..000000000 --- a/src/Composer/Script/CommandEvent.php +++ /dev/null @@ -1,22 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Script; - -/** - * The Command Event. - * - * @deprecated use Composer\Script\Event instead - */ -class CommandEvent extends Event -{ -} diff --git a/src/Composer/Script/PackageEvent.php b/src/Composer/Script/PackageEvent.php deleted file mode 100644 index 531b86a40..000000000 --- a/src/Composer/Script/PackageEvent.php +++ /dev/null @@ -1,24 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Script; - -use Composer\Installer\PackageEvent as BasePackageEvent; - -/** - * The Package Event. - * - * @deprecated Use Composer\Installer\PackageEvent instead - */ -class PackageEvent extends BasePackageEvent -{ -} diff --git a/src/Composer/Util/SpdxLicense.php b/src/Composer/Util/SpdxLicense.php deleted file mode 100644 index be4efdc54..000000000 --- a/src/Composer/Util/SpdxLicense.php +++ /dev/null @@ -1,24 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Util; - -use Composer\Spdx\SpdxLicenses; - -trigger_error('The ' . __NAMESPACE__ . '\SpdxLicense class is deprecated, use Composer\Spdx\SpdxLicenses instead.', E_USER_DEPRECATED); - -/** - * @deprecated use Composer\Spdx\SpdxLicenses instead - */ -class SpdxLicense extends SpdxLicenses -{ -} diff --git a/src/Composer/XdebugHandler.php b/src/Composer/XdebugHandler.php deleted file mode 100644 index eb94e93f4..000000000 --- a/src/Composer/XdebugHandler.php +++ /dev/null @@ -1,31 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer; - -use Symfony\Component\Console\Output\OutputInterface; - -trigger_error('The ' . __NAMESPACE__ . '\XdebugHandler class is deprecated, use Composer\XdebugHandler\XdebugHandler instead,', E_USER_DEPRECATED); - -/** - * @deprecated use Composer\XdebugHandler\XdebugHandler instead - */ -class XdebugHandler extends XdebugHandler\XdebugHandler -{ - const ENV_ALLOW = 'COMPOSER_ALLOW_XDEBUG'; - const ENV_VERSION = 'COMPOSER_XDEBUG_VERSION'; - - public function __construct(OutputInterface $output) - { - parent::__construct('composer', '--ansi'); - } -} diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php index 54460d705..590711d79 100644 --- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php +++ b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php @@ -20,7 +20,7 @@ use Composer\Composer; use Composer\TestCase; use Composer\IO\BufferIO; use Composer\Script\ScriptEvents; -use Composer\Script\CommandEvent; +use Composer\Script\Event as ScriptEvent; use Composer\Util\ProcessExecutor; use Symfony\Component\Console\Output\OutputInterface; @@ -51,29 +51,6 @@ class EventDispatcherTest extends TestCase $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false); } - /** - * @expectedException PHPUnit_Framework_Error_Deprecated - */ - public function testDispatcherCanConvertScriptEventToCommandEventForListener() - { - $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); - $dispatcher = $this->getDispatcherStubForListenersTest(array( - 'Composer\Test\EventDispatcher\EventDispatcherTest::expectsCommandEvent', - ), $io); - - $this->assertEquals(1, $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false)); - } - - public function testDispatcherDoesNotAttemptConversionForListenerWithoutTypehint() - { - $io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock(); - $dispatcher = $this->getDispatcherStubForListenersTest(array( - 'Composer\Test\EventDispatcher\EventDispatcherTest::expectsVariableEvent', - ), $io); - - $this->assertEquals(1, $dispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, false)); - } - /** * @dataProvider getValidCommands * @param string $command @@ -265,7 +242,7 @@ class EventDispatcherTest extends TestCase return array(); })); - $dispatcher->dispatch('root', new CommandEvent('root', $composer, $io)); + $dispatcher->dispatch('root', new ScriptEvent('root', $composer, $io)); $expected = '> root: @group'.PHP_EOL. '> group: echo -n foo'.PHP_EOL. '> group: @subgroup'.PHP_EOL. @@ -305,7 +282,7 @@ class EventDispatcherTest extends TestCase return array(); })); - $dispatcher->dispatch('root', new CommandEvent('root', $composer, $io)); + $dispatcher->dispatch('root', new ScriptEvent('root', $composer, $io)); } private function getDispatcherStubForListenersTest($listeners, $io) @@ -424,16 +401,6 @@ class EventDispatcherTest extends TestCase throw new \RuntimeException(); } - public static function expectsCommandEvent(CommandEvent $event) - { - return false; - } - - public static function expectsVariableEvent($event) - { - return false; - } - public static function someMethod() { return true;