From 678905bba210b5a20b5c06e6ffd7d1fbace650cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Mike=C5=A1?= Date: Sat, 9 Feb 2019 01:39:11 +0100 Subject: [PATCH] Fixed Contributte events namespaces and added missing --- ...enameEventNamesInEventSubscriberRector.php | 57 ++++++++++++++++--- .../Fixture/fixture.php.inc | 6 +- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/packages/NetteToSymfony/src/Rector/ClassMethod/RenameEventNamesInEventSubscriberRector.php b/packages/NetteToSymfony/src/Rector/ClassMethod/RenameEventNamesInEventSubscriberRector.php index 28a6d277547..9edf8cf4144 100644 --- a/packages/NetteToSymfony/src/Rector/ClassMethod/RenameEventNamesInEventSubscriberRector.php +++ b/packages/NetteToSymfony/src/Rector/ClassMethod/RenameEventNamesInEventSubscriberRector.php @@ -40,29 +40,70 @@ final class RenameEventNamesInEventSubscriberRector extends AbstractRector * @var string[][] */ private $netteClassConstToSymfonyClassConstMap = [ - 'Contributte\Events\Extra\Event\Application::NAME' => ['Symfony\Component\HttpKernel\KernelEvents', 'REQUEST'], - 'Contributte\Events\Extra\Event\ShutdownEvent::NAME' => [ + 'Contributte\Events\Extra\Event\Application\StartupEvent::NAME' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'REQUEST', + ], + 'Contributte\Events\Extra\Event\Application\PresenterShutdownEvent::NAME' => [ 'Symfony\Component\HttpKernel\KernelEvents', 'TERMINATE', ], - 'Contributte\Events\Extra\Event\RequestEvent::NAME' => ['Symfony\Component\HttpKernel\KernelEvents', 'REQUEST'], - 'Contributte\Events\Extra\Event\PresenterEvent::NAME' => [ + 'Contributte\Events\Extra\Event\Application\RequestEvent::NAME' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'REQUEST', + ], + 'Contributte\Events\Extra\Event\Application\PresenterEvent::NAME' => [ 'Symfony\Component\HttpKernel\KernelEvents', 'CONTROLLER', ], - 'Contributte\Events\Extra\Event\PresenterStartupEvent::NAME' => [ + 'Contributte\Events\Extra\Event\Application\PresenterStartupEvent::NAME' => [ 'Symfony\Component\HttpKernel\KernelEvents', 'CONTROLLER', ], - 'Contributte\Events\Extra\Event\PresenterShutdownEvent::NAME' => [ + 'Contributte\Events\Extra\Event\Application\PresenterShutdownEvent::NAME' => [ 'Symfony\Component\HttpKernel\KernelEvents', 'CONTROLLER', ], - 'Contributte\Events\Extra\Event\ResponseEvent::NAME' => [ + 'Contributte\Events\Extra\Event\Application\ResponseEvent::NAME' => [ 'Symfony\Component\HttpKernel\KernelEvents', 'RESPONSE', ], - 'Contributte\Events\Extra\Event\ErrorEvent::NAME' => ['Symfony\Component\HttpKernel\KernelEvents', 'EXCEPTION'], + 'Contributte\Events\Extra\Event\Application\ErrorEvent::NAME' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'EXCEPTION', + ], + 'Contributte\Events\Extra\Event\Application\ApplicationEvents::ON_STARTUP' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'REQUEST', + ], + 'Contributte\Events\Extra\Event\Application\ApplicationEvents::ON_SHUTDOWN' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'TERMINATE', + ], + 'Contributte\Events\Extra\Event\Application\ApplicationEvents::ON_REQUEST' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'REQUEST', + ], + 'Contributte\Events\Extra\Event\Application\ApplicationEvents::ON_PRESENTER' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'CONTROLLER', + ], + 'Contributte\Events\Extra\Event\Application\ApplicationEvents::ON_PRESENTER_STARTUP' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'CONTROLLER', + ], + 'Contributte\Events\Extra\Event\Application\ApplicationEvents::ON_PRESENTER_SHUTDOWN' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'CONTROLLER', + ], + 'Contributte\Events\Extra\Event\Application\ApplicationEvents::ON_RESPONSE' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'RESPONSE', + ], + 'Contributte\Events\Extra\Event\Application\ApplicationEvents::ON_ERROR' => [ + 'Symfony\Component\HttpKernel\KernelEvents', + 'EXCEPTION', + ], ]; /** diff --git a/packages/NetteToSymfony/tests/Rector/ClassMethod/RenameEventNamesInEventSubscriberRector/Fixture/fixture.php.inc b/packages/NetteToSymfony/tests/Rector/ClassMethod/RenameEventNamesInEventSubscriberRector/Fixture/fixture.php.inc index d76729b29f0..39cdc096e2f 100644 --- a/packages/NetteToSymfony/tests/Rector/ClassMethod/RenameEventNamesInEventSubscriberRector/Fixture/fixture.php.inc +++ b/packages/NetteToSymfony/tests/Rector/ClassMethod/RenameEventNamesInEventSubscriberRector/Fixture/fixture.php.inc @@ -3,7 +3,7 @@ namespace Rector\NetteToSymfony\Tests\Rector\ClassMethod\RenameEventNamesInEventSubscriberRector\Fixture; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Contributte\Events\Extra\Event\PresenterStartupEvent; +use Contributte\Events\Extra\Event\Application\PresenterStartupEvent; final class SomeClass implements EventSubscriberInterface { @@ -11,7 +11,7 @@ final class SomeClass implements EventSubscriberInterface { return [ 'nette.application.startup' => 'someMethod', - \Contributte\Events\Extra\Event\Application::NAME => 'someMethod', + \Contributte\Events\Extra\Event\Application\StartupEvent::NAME => 'someMethod', PresenterStartupEvent::NAME => 'someMethod', ]; } @@ -24,7 +24,7 @@ final class SomeClass implements EventSubscriberInterface namespace Rector\NetteToSymfony\Tests\Rector\ClassMethod\RenameEventNamesInEventSubscriberRector\Fixture; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Contributte\Events\Extra\Event\PresenterStartupEvent; +use Contributte\Events\Extra\Event\Application\PresenterStartupEvent; final class SomeClass implements EventSubscriberInterface {