diff --git a/.travis.yml b/.travis.yml index 6d486b56..1e22edf4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,7 @@ matrix: - php: 7.2 env: SYMFONY_VERSION="~4.2.0" WITH_LIIP_IMAGINE=true - php: 7.3 - env: SYMFONY_VERSION="~4.2.0" WITH_LIIP_IMAGINE=true + env: SYMFONY_VERSION="~4.3.0" WITH_LIIP_IMAGINE=true allow_failures: - php: nightly @@ -33,7 +33,6 @@ before_install: - composer self-update - phpenv config-rm xdebug.ini || true - if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony:${SYMFONY_VERSION}; fi - - if [ "$SYMFONY_VERSION" = "~3.4.0" ]; then composer remove symfony/event-dispatcher-contracts; fi - if [ "$WITH_LIIP_IMAGINE" = true ] ; then composer require --no-update liip/imagine-bundle:"^1.7|^2.0"; fi; - if [ "$VALIDATE_DOCS" = true ]; then composer require --dev --no-update kphoen/rusty dev-master; fi diff --git a/Event/Event.php b/Event/Event.php index 9e37a66b..4eb937d5 100644 --- a/Event/Event.php +++ b/Event/Event.php @@ -3,6 +3,7 @@ namespace Vich\UploaderBundle\Event; use Symfony\Component\EventDispatcher\Event as BaseEvent; +use Symfony\Component\HttpKernel\Kernel; use Symfony\Contracts\EventDispatcher\Event as ContractEvent; use Vich\UploaderBundle\Mapping\PropertyMapping; @@ -11,7 +12,7 @@ * * @author Kévin Gomez */ -if (class_exists(ContractEvent::class)) { +if ('42' !== Kernel::MAJOR_VERSION.Kernel::MINOR_VERSION && class_exists(ContractEvent::class)) { class Event extends ContractEvent { protected $object; diff --git a/Handler/UploadHandler.php b/Handler/UploadHandler.php index 2831e641..c56e6430 100644 --- a/Handler/UploadHandler.php +++ b/Handler/UploadHandler.php @@ -3,8 +3,9 @@ namespace Vich\UploaderBundle\Handler; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpKernel\Kernel; +use Symfony\Contracts\EventDispatcher\Event as ContractEvent; +use Symfony\Component\HttpFoundation\File\UploadedFile; use Vich\UploaderBundle\Event\Event; use Vich\UploaderBundle\Event\Events; use Vich\UploaderBundle\Injector\FileInjectorInterface; @@ -105,7 +106,7 @@ public function remove($obj, string $fieldName): void protected function dispatch(string $eventName, Event $event): void { - if (Kernel::VERSION_ID >= 40300) { + if ('42' !== Kernel::MAJOR_VERSION.Kernel::MINOR_VERSION && class_exists(ContractEvent::class)) { $this->dispatcher->dispatch($event, $eventName); } else { $this->dispatcher->dispatch($eventName, $event); diff --git a/Tests/Handler/UploadHandlerTest.php b/Tests/Handler/UploadHandlerTest.php index 7dedfaf6..5f2e5d97 100644 --- a/Tests/Handler/UploadHandlerTest.php +++ b/Tests/Handler/UploadHandlerTest.php @@ -4,6 +4,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpKernel\Kernel; +use Symfony\Contracts\EventDispatcher\Event as ContractEvent; use Vich\TestBundle\Entity\Article; use Vich\UploaderBundle\Event\Event; use Vich\UploaderBundle\Event\Events; @@ -238,7 +239,7 @@ protected function validEvent() protected function expectEvents(array $events): void { foreach ($events as $i => $event) { - if (Kernel::VERSION_ID >= 40300) { + if ('42' !== Kernel::MAJOR_VERSION.Kernel::MINOR_VERSION && class_exists(ContractEvent::class)) { $this->dispatcher ->expects($this->at($i)) ->method('dispatch') diff --git a/composer.json b/composer.json index ece16aad..b59996e4 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,6 @@ "symfony/config": "^3.4 || ^4.0", "symfony/dependency-injection": "^3.4 || ^4.0", "symfony/event-dispatcher": "^3.4 || ^4.0", - "symfony/event-dispatcher-contracts": "^1.1", "symfony/form": "^3.4.19 || ^4.0", "symfony/http-foundation": "^3.4 || ^4.0", "symfony/http-kernel": "^3.4 || ^4.0",