From e12f08132f6c4db71c8c1e71f6c8d22426243ee4 Mon Sep 17 00:00:00 2001 From: Stanislav Aliferovich Date: Sun, 22 Dec 2019 13:40:30 +0300 Subject: [PATCH] Fix compatibility with sf event dispatcher ^4.3. --- .travis.yml | 8 -------- composer.json | 4 ++-- .../WildcardEventDispatcher/WildcardEventDispatcher.php | 6 +++++- .../WildcardEventDispatcherTest.php | 3 ++- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 64b381d..a4f9ddd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,6 @@ dist: trusty sudo: false php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - 7.1 - 7.2 - 7.3 @@ -17,10 +13,6 @@ cache: matrix: fast_finish: true - include: - - php: 5.3 - dist: precise - env: COMPOSER_FLAGS="--prefer-lowest" before_script: - phpenv config-rm xdebug.ini diff --git a/composer.json b/composer.json index a7d42b9..4b442b8 100644 --- a/composer.json +++ b/composer.json @@ -9,8 +9,8 @@ { "name": "Jeremy Mikola", "email": "jmikola@gmail.com" } ], "require": { - "php": ">=5.3.2", - "symfony/event-dispatcher": "^2.3 || ^3.0 || ^4.0" + "php": ">=7.1.3", + "symfony/event-dispatcher": "^4.3" }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^6.4" diff --git a/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php b/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php index 5d53d57..3986f78 100644 --- a/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php +++ b/src/Jmikola/WildcardEventDispatcher/WildcardEventDispatcher.php @@ -33,7 +33,11 @@ class WildcardEventDispatcher implements EventDispatcherInterface { $this->bindPatterns($eventName); - return $this->dispatcher->dispatch($eventName, $event); + if ($event === null) { + $event = new Event(); + } + + return $this->dispatcher->dispatch($event, $eventName); } /** diff --git a/tests/Jmikola/Tests/WildcardEventDispatcher/WildcardEventDispatcherTest.php b/tests/Jmikola/Tests/WildcardEventDispatcher/WildcardEventDispatcherTest.php index f746787..6907b1e 100644 --- a/tests/Jmikola/Tests/WildcardEventDispatcher/WildcardEventDispatcherTest.php +++ b/tests/Jmikola/Tests/WildcardEventDispatcher/WildcardEventDispatcherTest.php @@ -3,6 +3,7 @@ namespace Jmikola\Tests\WildcardEventDispatcher; use Jmikola\WildcardEventDispatcher\WildcardEventDispatcher; +use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use PHPUnit\Framework\TestCase; @@ -66,7 +67,7 @@ class EventDispatcherTest extends TestCase $this->innerDispatcher->expects($this->once()) ->after('listener-is-added') ->method('dispatch') - ->with('core.request'); + ->with(new Event(), 'core.request'); $this->dispatcher->addListener('core.*', 'callback', 0); $this->dispatcher->dispatch('core.request');