diff --git a/composer.json b/composer.json index e09bd51..b9d955f 100644 --- a/composer.json +++ b/composer.json @@ -22,12 +22,12 @@ "php": "^7.4 || ^8.0", "ext-mongodb": "^1.6", "mongodb/mongodb": "^1.5", - "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0" + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { "matthiasnoback/symfony-dependency-injection-test": "^4", - "symfony/web-profiler-bundle": "^4.4 || ^5.0 || ^6.0", - "symfony/console": "^4.4 || ^5.0 || ^6.0", + "symfony/web-profiler-bundle": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/console": "^4.4 || ^5.0 || ^6.0 || ^7.0", "phpunit/phpunit": "^9.6.13", "symfony/phpunit-bridge": "^7.0", "facile-it/facile-coding-standard": "1.2.0", diff --git a/src/Capsule/Collection.php b/src/Capsule/Collection.php index c1e0529..3a1a7eb 100644 --- a/src/Capsule/Collection.php +++ b/src/Capsule/Collection.php @@ -10,7 +10,6 @@ use MongoDB\Driver\Manager; use MongoDB\Driver\ReadPreference; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\Kernel; /** * @internal @@ -230,12 +229,7 @@ private function notifyQueryExecution(Query $queryLog) { $queryLog->setExecutionTime(microtime(true) - $queryLog->getStart()); - $event = new QueryEvent($queryLog); - if (Kernel::VERSION_ID >= 40_300) { - $this->eventDispatcher->dispatch($event, QueryEvent::QUERY_EXECUTED); - } else { - $this->eventDispatcher->dispatch($event, QueryEvent::QUERY_EXECUTED); - } + $this->eventDispatcher->dispatch(new QueryEvent($queryLog), QueryEvent::QUERY_EXECUTED); } public function getClientName(): string diff --git a/src/Command/AbstractCommand.php b/src/Command/AbstractCommand.php index 9a6fba7..7a60a83 100644 --- a/src/Command/AbstractCommand.php +++ b/src/Command/AbstractCommand.php @@ -43,7 +43,7 @@ protected function getContainer(): ContainerInterface /** * @inheritDoc */ - protected function configure() + protected function configure(): void { parent::configure(); $this @@ -53,7 +53,7 @@ protected function configure() /** * @inheritDoc */ - protected function initialize(InputInterface $input, OutputInterface $output) + protected function initialize(InputInterface $input, OutputInterface $output): void { parent::initialize($input, $output); $this->io = new SymfonyStyle($input, $output); diff --git a/src/Command/DropCollectionCommand.php b/src/Command/DropCollectionCommand.php index 5f815f0..5ff3c2c 100644 --- a/src/Command/DropCollectionCommand.php +++ b/src/Command/DropCollectionCommand.php @@ -13,7 +13,7 @@ class DropCollectionCommand extends AbstractCommand /** * @inheritDoc */ - protected function configure() + protected function configure(): void { parent::configure(); $this diff --git a/src/Command/DropDatabaseCommand.php b/src/Command/DropDatabaseCommand.php index 17b78ea..718a3c1 100644 --- a/src/Command/DropDatabaseCommand.php +++ b/src/Command/DropDatabaseCommand.php @@ -12,7 +12,7 @@ class DropDatabaseCommand extends AbstractCommand /** * @inheritDoc */ - protected function configure() + protected function configure(): void { parent::configure(); $this diff --git a/src/Command/LoadFixturesCommand.php b/src/Command/LoadFixturesCommand.php index b274187..4b0f75d 100644 --- a/src/Command/LoadFixturesCommand.php +++ b/src/Command/LoadFixturesCommand.php @@ -24,7 +24,7 @@ class LoadFixturesCommand extends AbstractCommand /** * @inheritDoc */ - protected function configure() + protected function configure(): void { parent::configure(); $this @@ -33,7 +33,7 @@ protected function configure() ->setDescription('Load fixtures and applies them'); } - protected function initialize(InputInterface $input, OutputInterface $output) + protected function initialize(InputInterface $input, OutputInterface $output): void { parent::initialize($input, $output); $this->loader = new MongoFixturesLoader($this->getContainer()); @@ -68,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - private function loadFixture(MongoFixtureInterface $indexList) + private function loadFixture(MongoFixtureInterface $indexList): void { $indexList->loadData(); $indexList->loadIndexes(); @@ -90,7 +90,7 @@ private function prepareSearchPaths(InputInterface $input, KernelInterface $kern return $paths; } - private function loadPaths(array $paths) + private function loadPaths(array $paths): void { foreach ($paths as $path) { if (is_dir($path)) { diff --git a/src/DataCollector/MongoDbDataCollector.php b/src/DataCollector/MongoDbDataCollector.php index d5efdb1..5d305e6 100644 --- a/src/DataCollector/MongoDbDataCollector.php +++ b/src/DataCollector/MongoDbDataCollector.php @@ -26,15 +26,12 @@ class MongoDbDataCollector extends DataCollector /** @var DataCollectorLoggerInterface */ private $logger; - /** @var array */ - protected $data; - public function __construct() { $this->reset(); } - public function reset() + public function reset(): void { $this->data = [ self::QUERY_KEYWORD => [], @@ -43,12 +40,12 @@ public function reset() ]; } - public function setLogger(DataCollectorLoggerInterface $logger) + public function setLogger(DataCollectorLoggerInterface $logger): void { $this->logger = $logger; } - public function collect(Request $request, Response $response, $exception = null) + public function collect(Request $request, Response $response, $exception = null): void { if ($exception && ! $exception instanceof \Throwable) { throw new \InvalidArgumentException('Expecting \Throwable, got ' . get_debug_type($exception)); @@ -101,7 +98,7 @@ public function getConnections(): array /** * @inheritDoc */ - public function getName() + public function getName(): string { return 'mongodb'; } diff --git a/src/DependencyInjection/MongoDbBundleExtension.php b/src/DependencyInjection/MongoDbBundleExtension.php index dd53814..31beb44 100644 --- a/src/DependencyInjection/MongoDbBundleExtension.php +++ b/src/DependencyInjection/MongoDbBundleExtension.php @@ -26,7 +26,7 @@ final class MongoDbBundleExtension extends Extension /** @var ContainerBuilder */ private $containerBuilder; - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $this->containerBuilder = $container; $config = $this->processConfiguration(new Configuration(), $configs); @@ -42,8 +42,6 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('profiler.xml'); $this->attachDataCollectionListenerToEventManager(); } - - return $config; } private function mustCollectData(array $config): bool diff --git a/tests/Functional/Capsule/CollectionTest.php b/tests/Functional/Capsule/CollectionTest.php index a77959a..eb0bb23 100644 --- a/tests/Functional/Capsule/CollectionTest.php +++ b/tests/Functional/Capsule/CollectionTest.php @@ -10,7 +10,6 @@ use MongoDB\Driver\Manager; use Prophecy\Argument; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\Kernel; class CollectionTest extends AppTestCase { @@ -190,12 +189,7 @@ public function test_distinct() protected function assertEventsDispatching($ev) { - if (Kernel::VERSION_ID >= 40_300) { - $ev->dispatch(Argument::type(QueryEvent::class), QueryEvent::QUERY_PREPARED)->shouldBeCalled(); - $ev->dispatch(Argument::type(QueryEvent::class), QueryEvent::QUERY_EXECUTED)->shouldBeCalled(); - } else { - $ev->dispatch(QueryEvent::QUERY_PREPARED, Argument::type(QueryEvent::class))->shouldBeCalled(); - $ev->dispatch(QueryEvent::QUERY_EXECUTED, Argument::type(QueryEvent::class))->shouldBeCalled(); - } + $ev->dispatch(Argument::type(QueryEvent::class), QueryEvent::QUERY_PREPARED)->shouldBeCalled(); + $ev->dispatch(Argument::type(QueryEvent::class), QueryEvent::QUERY_EXECUTED)->shouldBeCalled(); } } diff --git a/tests/Functional/Command/AbstractCommandTest.php b/tests/Functional/Command/AbstractCommandTest.php index 5247b77..241b5bc 100644 --- a/tests/Functional/Command/AbstractCommandTest.php +++ b/tests/Functional/Command/AbstractCommandTest.php @@ -62,7 +62,7 @@ private function addCommandToApplication() class FakeCommand extends AbstractCommand { - protected function configure() + protected function configure(): void { parent::configure(); $this diff --git a/tests/Unit/Services/ClientRegistryTest.php b/tests/Unit/Services/ClientRegistryTest.php index 9be8e70..1dfe2f4 100644 --- a/tests/Unit/Services/ClientRegistryTest.php +++ b/tests/Unit/Services/ClientRegistryTest.php @@ -9,7 +9,6 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\Kernel; class ClientRegistryTest extends TestCase { @@ -107,15 +106,9 @@ private function createEventDispatcherMock(): EventDispatcherInterface return true; }); - if (Kernel::VERSION_ID >= 40_300) { - $eventDispatcher->dispatch($event, ConnectionEvent::CLIENT_CREATED) - ->shouldBeCalledOnce() - ->willReturnArgument(0); - } else { - $eventDispatcher->dispatch(ConnectionEvent::CLIENT_CREATED, $event) - ->shouldBeCalledOnce() - ->willReturnArgument(1); - } + $eventDispatcher->dispatch($event, ConnectionEvent::CLIENT_CREATED) + ->shouldBeCalledOnce() + ->willReturnArgument(0); return $eventDispatcher->reveal(); }