From af60a9359058409487bda8967779dc584f66e8f0 Mon Sep 17 00:00:00 2001 From: Dennis Riehle Date: Thu, 3 Aug 2023 18:33:54 +0200 Subject: [PATCH] upgraded to Doctrine coding standard v12 --- composer.json | 6 +- src/Collector/MongoLoggerCollector.php | 12 +-- src/Logging/EchoLogger.php | 2 +- src/Module.php | 16 ++-- src/Options/Configuration.php | 78 +++++++------------ src/Options/Connection.php | 44 +++++------ src/Options/MongoLoggerCollector.php | 10 +-- src/Service/AbstractFactory.php | 10 +-- src/Service/ConfigurationFactory.php | 6 +- src/Service/ConnectionFactory.php | 4 +- src/Service/DoctrineObjectHydratorFactory.php | 2 +- src/Service/DocumentManagerFactory.php | 2 +- src/Service/MongoLoggerCollectorFactory.php | 3 +- tests/AbstractTest.php | 2 +- tests/Assets/CustomRepositoryFactory.php | 10 +-- tests/Doctrine/CliTest.php | 16 ++-- tests/Doctrine/ConfigurationFactoryTest.php | 14 ++-- tests/Doctrine/ConnectionFactoryTest.php | 5 +- tests/Doctrine/DocumentManagerTest.php | 1 + tests/ServiceManagerFactory.php | 8 +- 20 files changed, 103 insertions(+), 148 deletions(-) diff --git a/composer.json b/composer.json index 0ec5c14..078fb3d 100644 --- a/composer.json +++ b/composer.json @@ -60,15 +60,15 @@ "symfony/var-dumper": "^5.4.26 || ^6.3.2" }, "require-dev": { - "doctrine/coding-standard": "^9.0.2", + "doctrine/coding-standard": "^12.0.0", "doctrine/persistence": "^2.5.7 || ^3.2.0", "jangregor/phpstan-prophecy": "^1.0.0", "laminas/laminas-developer-tools": "^2.8.0", "laminas/laminas-hydrator": "^4.13.0", "laminas/laminas-session": "^2.16.0", "phpspec/prophecy-phpunit": "^2.0.2", - "phpstan/phpstan": "^1.9.1", - "phpunit/phpunit": "^9.5.26", + "phpstan/phpstan": "^1.10.26", + "phpunit/phpunit": "^9.6.10", "vimeo/psalm": "^4.30.0" }, "suggest": { diff --git a/src/Collector/MongoLoggerCollector.php b/src/Collector/MongoLoggerCollector.php index c741a03..90ad80b 100644 --- a/src/Collector/MongoLoggerCollector.php +++ b/src/Collector/MongoLoggerCollector.php @@ -24,14 +24,8 @@ class MongoLoggerCollector implements CollectorInterface, AutoHideInterface */ public const PRIORITY = 10; - protected DebugStack $mongoLogger; - - protected string $name; - - public function __construct(DebugStack $mongoLogger, string $name) + public function __construct(protected DebugStack $mongoLogger, protected string $name) { - $this->mongoLogger = $mongoLogger; - $this->name = $name; } public function getName(): string @@ -58,9 +52,7 @@ public function getQueryCount(): int return count($this->mongoLogger->queries); } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getQueries(): array { return $this->mongoLogger->queries; diff --git a/src/Logging/EchoLogger.php b/src/Logging/EchoLogger.php index 386e3e2..cedfc25 100644 --- a/src/Logging/EchoLogger.php +++ b/src/Logging/EchoLogger.php @@ -47,7 +47,7 @@ public function commandStarted(CommandStartedEvent $event): void [ 'command' => $event->getCommand(), 'db' => $event->getDatabaseName(), - ] + ], ); } diff --git a/src/Module.php b/src/Module.php index e7e0764..687d00f 100644 --- a/src/Module.php +++ b/src/Module.php @@ -33,7 +33,7 @@ public function init(ModuleManagerInterface $manager): void throw new InvalidArgumentException(sprintf( 'Expected %s, but received %s.', ModuleManager::class, - $manager::class + $manager::class, )); } @@ -64,8 +64,8 @@ public function loadCli(EventInterface $event): void 'documentmanager', null, InputOption::VALUE_OPTIONAL, - 'The name of the documentmanager to use. If none is provided, it will use odm_default.' - ) + 'The name of the documentmanager to use. If none is provided, it will use odm_default.', + ), ); } @@ -74,7 +74,7 @@ public function loadCli(EventInterface $event): void throw new InvalidArgumentException(sprintf( 'Expected %s as event target, received %s.', Application::class, - $cli::class + $cli::class, )); } @@ -89,17 +89,13 @@ public function loadCli(EventInterface $event): void $cli->getHelperSet()->set($documentHelper, 'dm'); } - /** - * @return array - */ + /** @return array */ public function getConfig(): array { return include __DIR__ . '/../config/module.config.php'; } - /** - * @return array - */ + /** @return array */ public function getServiceConfig(): array { return [ diff --git a/src/Options/Configuration.php b/src/Options/Configuration.php index 2958712..fd6722c 100644 --- a/src/Options/Configuration.php +++ b/src/Options/Configuration.php @@ -74,16 +74,16 @@ final class Configuration extends AbstractOptions /** * Persistent collection factory service name. */ - protected ?string $persistentCollectionFactory = null; + protected string|null $persistentCollectionFactory = null; /** * Persistent collection generator service name. */ - protected ?string $persistentCollectionGenerator = null; + protected string|null $persistentCollectionGenerator = null; - protected ?string $driver = null; + protected string|null $driver = null; - protected ?string $defaultDb = null; + protected string|null $defaultDb = null; /** * An array of filters. Array should be in the form @@ -96,11 +96,11 @@ final class Configuration extends AbstractOptions /** * service name of the Logger */ - protected ?string $logger = null; + protected string|null $logger = null; - protected ?string $classMetadataFactoryName = null; + protected string|null $classMetadataFactoryName = null; - protected ?string $repositoryFactory = null; + protected string|null $repositoryFactory = null; protected string $defaultDocumentRepositoryClassName = DefaultDocumentRepository::class; @@ -124,9 +124,7 @@ public function getDriver(): string return 'doctrine.driver.' . $this->driver; } - /** - * @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generateProxies - */ + /** @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generateProxies */ public function setGenerateProxies(int $generateProxies): self { $this->generateProxies = $generateProxies; @@ -134,9 +132,7 @@ public function setGenerateProxies(int $generateProxies): self return $this; } - /** - * @psalm-return MongoDbConfiguration::AUTOGENERATE_* - */ + /** @psalm-return MongoDbConfiguration::AUTOGENERATE_* */ public function getGenerateProxies(): int { return $this->generateProxies; @@ -178,17 +174,13 @@ public function getProxyNamespace(): string return $this->proxyNamespace; } - /** - * @psalm-return MongoDbConfiguration::AUTOGENERATE_* - */ + /** @psalm-return MongoDbConfiguration::AUTOGENERATE_* */ public function getGenerateHydrators(): int { return $this->generateHydrators; } - /** - * @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generateHydrators - */ + /** @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generateHydrators */ public function setGenerateHydrators(int $generateHydrators): self { $this->generateHydrators = $generateHydrators; @@ -220,17 +212,13 @@ public function setHydratorNamespace(string $hydratorNamespace): self return $this; } - /** - * @psalm-return MongoDbConfiguration::AUTOGENERATE_* - */ + /** @psalm-return MongoDbConfiguration::AUTOGENERATE_* */ public function getGeneratePersistentCollections(): int { return $this->generatePersistentCollections; } - /** - * @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generatePersistentCollections - */ + /** @psalm-param MongoDbConfiguration::AUTOGENERATE_* $generatePersistentCollections */ public function setGeneratePersistentCollections(int $generatePersistentCollections): self { $this->generatePersistentCollections = (int) $generatePersistentCollections; @@ -262,53 +250,49 @@ public function setPersistentCollectionNamespace(string $persistentCollectionNam return $this; } - public function getPersistentCollectionFactory(): ?string + public function getPersistentCollectionFactory(): string|null { return $this->persistentCollectionFactory; } - public function setPersistentCollectionFactory(?string $persistentCollectionFactory): self + public function setPersistentCollectionFactory(string|null $persistentCollectionFactory): self { $this->persistentCollectionFactory = $persistentCollectionFactory; return $this; } - public function getPersistentCollectionGenerator(): ?string + public function getPersistentCollectionGenerator(): string|null { return $this->persistentCollectionGenerator; } - public function setPersistentCollectionGenerator(?string $persistentCollectionGenerator): self + public function setPersistentCollectionGenerator(string|null $persistentCollectionGenerator): self { $this->persistentCollectionGenerator = (string) $persistentCollectionGenerator; return $this; } - public function getDefaultDb(): ?string + public function getDefaultDb(): string|null { return $this->defaultDb; } - public function setDefaultDb(?string $defaultDb): self + public function setDefaultDb(string|null $defaultDb): self { $this->defaultDb = $defaultDb; return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getFilters(): array { return $this->filters; } - /** - * @param mixed[] $filters - */ + /** @param mixed[] $filters */ public function setFilters(array $filters): self { $this->filters = $filters; @@ -316,50 +300,46 @@ public function setFilters(array $filters): self return $this; } - public function setLogger(?string $logger): self + public function setLogger(string|null $logger): self { $this->logger = $logger; return $this; } - public function getLogger(): ?string + public function getLogger(): string|null { return $this->logger; } - public function getClassMetadataFactoryName(): ?string + public function getClassMetadataFactoryName(): string|null { return $this->classMetadataFactoryName; } - public function setClassMetadataFactoryName(?string $classMetadataFactoryName): void + public function setClassMetadataFactoryName(string|null $classMetadataFactoryName): void { $this->classMetadataFactoryName = (string) $classMetadataFactoryName; } - /** - * @param mixed[] $types - */ + /** @param mixed[] $types */ public function setTypes(array $types): void { $this->types = $types; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getTypes(): array { return $this->types; } - public function getRepositoryFactory(): ?string + public function getRepositoryFactory(): string|null { return $this->repositoryFactory; } - public function setRepositoryFactory(?string $repositoryFactory): Configuration + public function setRepositoryFactory(string|null $repositoryFactory): Configuration { $this->repositoryFactory = (string) $repositoryFactory; diff --git a/src/Options/Connection.php b/src/Options/Connection.php index 9217441..1cb7929 100644 --- a/src/Options/Connection.php +++ b/src/Options/Connection.php @@ -24,22 +24,22 @@ final class Connection extends AbstractOptions /** * Username if using mongo auth */ - protected ?string $user = null; + protected string|null $user = null; /** * Password if using mongo auth */ - protected ?string $password = null; + protected string|null $password = null; /** * If you want to connect to a specific database */ - protected ?string $dbname = null; + protected string|null $dbname = null; /** * If you want to provide a custom connection string */ - protected ?string $connectionString = null; + protected string|null $connectionString = null; /** * Further connection options defined by mongodb-odm @@ -60,7 +60,7 @@ public function getServer(): string return $this->server; } - public function setServer(?string $server): self + public function setServer(string|null $server): self { $this->server = (string) $server; @@ -72,72 +72,68 @@ public function getPort(): string return $this->port; } - public function setPort(?string $port): self + public function setPort(string|null $port): self { $this->port = (string) $port; return $this; } - public function getUser(): ?string + public function getUser(): string|null { return $this->user; } - public function setUser(?string $user): self + public function setUser(string|null $user): self { $this->user = $user; return $this; } - public function getPassword(): ?string + public function getPassword(): string|null { return $this->password; } - public function setPassword(?string $password): self + public function setPassword(string|null $password): self { $this->password = $password; return $this; } - public function getDbname(): ?string + public function getDbname(): string|null { return $this->dbname; } - public function setDbname(?string $dbname): self + public function setDbname(string|null $dbname): self { $this->dbname = (string) $dbname; return $this; } - public function getConnectionString(): ?string + public function getConnectionString(): string|null { return $this->connectionString; } - public function setConnectionString(?string $connectionString): self + public function setConnectionString(string|null $connectionString): self { $this->connectionString = (string) $connectionString; return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getOptions(): array { return $this->options; } - /** - * @param mixed[] $options - */ + /** @param mixed[] $options */ public function setOptions(array $options): self { $this->options = $options; @@ -145,17 +141,13 @@ public function setOptions(array $options): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getDriverOptions(): array { return $this->driverOptions; } - /** - * @param mixed[] $driverOptions - */ + /** @param mixed[] $driverOptions */ public function setDriverOptions(array $driverOptions): self { $this->driverOptions = $driverOptions; diff --git a/src/Options/MongoLoggerCollector.php b/src/Options/MongoLoggerCollector.php index 2b32af9..a334c72 100644 --- a/src/Options/MongoLoggerCollector.php +++ b/src/Options/MongoLoggerCollector.php @@ -15,10 +15,10 @@ final class MongoLoggerCollector extends AbstractOptions protected string $name = 'odm_default'; /** @var string|null service name of the configuration where the logger has to be put */ - protected ?string $configuration = null; + protected string|null $configuration = null; /** @var string|null service name of the Logger to be used */ - protected ?string $mongoLogger = null; + protected string|null $mongoLogger = null; public function setName(string $name): void { @@ -33,7 +33,7 @@ public function getName(): string return $this->name; } - public function setConfiguration(?string $configuration): self + public function setConfiguration(string|null $configuration): self { $this->configuration = $configuration ?: null; @@ -48,7 +48,7 @@ public function getConfiguration(): string return $this->configuration ?? 'doctrine.configuration.odm_default'; } - public function setMongoLogger(?string $mongoLogger): self + public function setMongoLogger(string|null $mongoLogger): self { $this->mongoLogger = $mongoLogger ?: null; @@ -58,7 +58,7 @@ public function setMongoLogger(?string $mongoLogger): self /** * Logger service name */ - public function getMongoLogger(): ?string + public function getMongoLogger(): string|null { return $this->mongoLogger; } diff --git a/src/Service/AbstractFactory.php b/src/Service/AbstractFactory.php index 2caa228..70eee92 100644 --- a/src/Service/AbstractFactory.php +++ b/src/Service/AbstractFactory.php @@ -11,12 +11,10 @@ use function sprintf; -/** - * @internal - */ +/** @internal */ abstract class AbstractFactory extends DoctrineModuleAbstractFactory { - public function getOptions(ContainerInterface $container, string $key, ?string $name = null): AbstractOptions + public function getOptions(ContainerInterface $container, string $key, string|null $name = null): AbstractOptions { if ($name === null) { $name = $this->getName(); @@ -37,8 +35,8 @@ public function getOptions(ContainerInterface $container, string $key, ?string $ sprintf( 'Options with name "%s" could not be found in "doctrine.%s".', $name, - $key - ) + $key, + ), ); } diff --git a/src/Service/ConfigurationFactory.php b/src/Service/ConfigurationFactory.php index 0e90173..fbf941c 100644 --- a/src/Service/ConfigurationFactory.php +++ b/src/Service/ConfigurationFactory.php @@ -21,7 +21,7 @@ final class ConfigurationFactory extends AbstractFactory * * @return Configuration */ - public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, array|null $options = null) { $configurationOptions = $this->getOptions($container, 'configuration'); assert($configurationOptions instanceof Options\Configuration); @@ -51,13 +51,13 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $ if ($configurationOptions->getPersistentCollectionFactory()) { $config->setPersistentCollectionFactory( - $container->get($configurationOptions->getPersistentCollectionFactory()) + $container->get($configurationOptions->getPersistentCollectionFactory()), ); } if ($configurationOptions->getPersistentCollectionGenerator()) { $config->setPersistentCollectionGenerator( - $container->get($configurationOptions->getPersistentCollectionGenerator()) + $container->get($configurationOptions->getPersistentCollectionGenerator()), ); } diff --git a/src/Service/ConnectionFactory.php b/src/Service/ConnectionFactory.php index 3e84b1f..7b81a83 100644 --- a/src/Service/ConnectionFactory.php +++ b/src/Service/ConnectionFactory.php @@ -26,7 +26,7 @@ final class ConnectionFactory extends AbstractFactory * * @return Client */ - public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, array|null $options = null) { $connectionOptions = $this->getOptions($container, 'connection'); assert($connectionOptions instanceof Options\Connection); @@ -58,7 +58,7 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $ $dbName = substr( $connectionString, $dbStart + 1, - $dbEnd ? ($dbEnd - $dbStart - 1) : PHP_INT_MAX + $dbEnd ? ($dbEnd - $dbStart - 1) : PHP_INT_MAX, ); } } diff --git a/src/Service/DoctrineObjectHydratorFactory.php b/src/Service/DoctrineObjectHydratorFactory.php index d26e1f2..b8d3a8a 100644 --- a/src/Service/DoctrineObjectHydratorFactory.php +++ b/src/Service/DoctrineObjectHydratorFactory.php @@ -19,7 +19,7 @@ final class DoctrineObjectHydratorFactory implements FactoryInterface public function __invoke( ContainerInterface $container, $requestedName = null, - ?array $options = null + array|null $options = null, ): DoctrineObject { $documentManager = $container->get('doctrine.documentmanager.odm_default'); assert($documentManager instanceof DocumentManager); diff --git a/src/Service/DocumentManagerFactory.php b/src/Service/DocumentManagerFactory.php index f729a2d..46f0573 100644 --- a/src/Service/DocumentManagerFactory.php +++ b/src/Service/DocumentManagerFactory.php @@ -20,7 +20,7 @@ final class DocumentManagerFactory extends AbstractFactory * * @return DocumentManager */ - public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, array|null $options = null) { $options = $this->getOptions($container, 'documentmanager'); assert($options instanceof Options\DocumentManager); diff --git a/src/Service/MongoLoggerCollectorFactory.php b/src/Service/MongoLoggerCollectorFactory.php index 7e71d4d..01b1bc0 100644 --- a/src/Service/MongoLoggerCollectorFactory.php +++ b/src/Service/MongoLoggerCollectorFactory.php @@ -19,6 +19,7 @@ final class MongoLoggerCollectorFactory extends AbstractFactory public function __construct(string $name) { parent::__construct($name); + $this->name = $name; } @@ -27,7 +28,7 @@ public function __construct(string $name) * * @return MongoLoggerCollector */ - public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, array|null $options = null) { $settings = $this->getOptions($container, 'mongo_logger_collector'); assert($settings instanceof Options\MongoLoggerCollector); diff --git a/tests/AbstractTest.php b/tests/AbstractTest.php index 67cf987..fd8c0a9 100644 --- a/tests/AbstractTest.php +++ b/tests/AbstractTest.php @@ -36,7 +36,7 @@ protected function tearDown(): void $writeConcern = new WriteConcern(1); foreach ($collections as $collection) { $database->dropCollection($collection->getName(), ['writeConcern' => $writeConcern]); } - } catch (RuntimeException $e) { + } catch (RuntimeException) { } } } diff --git a/tests/Assets/CustomRepositoryFactory.php b/tests/Assets/CustomRepositoryFactory.php index b067e01..cc1114e 100644 --- a/tests/Assets/CustomRepositoryFactory.php +++ b/tests/Assets/CustomRepositoryFactory.php @@ -23,7 +23,7 @@ public function getRepository(DocumentManager $documentManager, string $document /** * {@inheritDoc} */ - public function find($id): ?object + public function find($id): object|null { return null; } @@ -43,7 +43,7 @@ public function findAll(): array * * @psalm-return mixed[] */ - public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array + public function findBy(array $criteria, array|null $orderBy = null, $limit = null, $offset = null): array { return []; } @@ -51,14 +51,12 @@ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $ /** * {@inheritDoc} */ - public function findOneBy(array $criteria): ?object + public function findOneBy(array $criteria): object|null { return null; } - /** - * @psalm-return string - */ + /** @psalm-return string */ public function getClassName(): string { return stdClass::class; diff --git a/tests/Doctrine/CliTest.php b/tests/Doctrine/CliTest.php index 388504b..e848751 100644 --- a/tests/Doctrine/CliTest.php +++ b/tests/Doctrine/CliTest.php @@ -59,7 +59,7 @@ protected function setUp(): void 'loadCli.post', static function () use (&$invocations): void { $invocations += 1; - } + }, ); $application->bootstrap(); @@ -84,31 +84,31 @@ public function testValidCommands(): void { $this->assertInstanceOf( 'Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateHydratorsCommand', - $this->cli->get('odm:generate:hydrators') + $this->cli->get('odm:generate:hydrators'), ); $this->assertInstanceOf( 'Doctrine\ODM\MongoDB\Tools\Console\Command\GeneratePersistentCollectionsCommand', - $this->cli->get('odm:generate:persistent-collections') + $this->cli->get('odm:generate:persistent-collections'), ); $this->assertInstanceOf( 'Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateProxiesCommand', - $this->cli->get('odm:generate:proxies') + $this->cli->get('odm:generate:proxies'), ); $this->assertInstanceOf( 'Doctrine\ODM\MongoDB\Tools\Console\Command\QueryCommand', - $this->cli->get('odm:query') + $this->cli->get('odm:query'), ); $this->assertInstanceOf( 'Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\CreateCommand', - $this->cli->get('odm:schema:create') + $this->cli->get('odm:schema:create'), ); $this->assertInstanceOf( 'Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\UpdateCommand', - $this->cli->get('odm:schema:update') + $this->cli->get('odm:schema:update'), ); $this->assertInstanceOf( 'Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\DropCommand', - $this->cli->get('odm:schema:drop') + $this->cli->get('odm:schema:drop'), ); } } diff --git a/tests/Doctrine/ConfigurationFactoryTest.php b/tests/Doctrine/ConfigurationFactoryTest.php index b009925..3842df9 100644 --- a/tests/Doctrine/ConfigurationFactoryTest.php +++ b/tests/Doctrine/ConfigurationFactoryTest.php @@ -27,32 +27,32 @@ public function testCreation(): void $serviceLocator = new ServiceManager(); $serviceLocator->setService( 'stubbed_logger', - $this->getMockForAbstractClass(CommandLoggerInterface::class) + $this->getMockForAbstractClass(CommandLoggerInterface::class), ); $serviceLocator->setService( 'doctrine.cache.stubbed_metadatacache', - $metadataCache = $this->getMockForAbstractClass(Cache::class) + $metadataCache = $this->getMockForAbstractClass(Cache::class), ); $serviceLocator->setService( 'doctrine.driver.stubbed_driver', - $mappingDriver = $this->getMockForAbstractClass(MappingDriver::class) + $mappingDriver = $this->getMockForAbstractClass(MappingDriver::class), ); $serviceLocator->setService( CustomRepositoryFactory::class, - $repositoryFactory = new CustomRepositoryFactory() + $repositoryFactory = new CustomRepositoryFactory(), ); $serviceLocator->setService( PersistentCollectionFactory::class, - $persistentCollectionFactory = $this->getMockForAbstractClass(PersistentCollectionFactory::class) + $persistentCollectionFactory = $this->getMockForAbstractClass(PersistentCollectionFactory::class), ); $serviceLocator->setService( PersistentCollectionGenerator::class, - $persistentCollectionGenerator = $this->getMockForAbstractClass(PersistentCollectionGenerator::class) + $persistentCollectionGenerator = $this->getMockForAbstractClass(PersistentCollectionGenerator::class), ); $serviceLocator->setService( @@ -89,7 +89,7 @@ public function testCreation(): void ], ], ], - ] + ], ); $factory = new ConfigurationFactory('odm_test'); diff --git a/tests/Doctrine/ConnectionFactoryTest.php b/tests/Doctrine/ConnectionFactoryTest.php index 911dc9d..1b010fa 100644 --- a/tests/Doctrine/ConnectionFactoryTest.php +++ b/tests/Doctrine/ConnectionFactoryTest.php @@ -9,9 +9,7 @@ use DoctrineMongoODMModuleTest\AbstractTest; use MongoDB\Client; -/** - * @covers \DoctrineMongoODMModule\Service\ConnectionFactory - */ +/** @covers \DoctrineMongoODMModule\Service\ConnectionFactory */ class ConnectionFactoryTest extends AbstractTest { /** @var mixed[] $configuration */ @@ -22,6 +20,7 @@ class ConnectionFactoryTest extends AbstractTest protected function setUp(): void { parent::setup(); + $this->serviceManager->setAllowOverride(true); $this->serviceManager->setService('doctrine.configuration.odm_default', null); $this->serviceManager->setService('doctrine.connection.odm_default', null); diff --git a/tests/Doctrine/DocumentManagerTest.php b/tests/Doctrine/DocumentManagerTest.php index 14ce07d..c9a369a 100644 --- a/tests/Doctrine/DocumentManagerTest.php +++ b/tests/Doctrine/DocumentManagerTest.php @@ -15,6 +15,7 @@ final class DocumentManagerTest extends AbstractTest protected function setUp(): void { parent::setup(); + $this->serviceManager->setAllowOverride(true); $this->configuration = $this->serviceManager->get('config'); $this->serviceManager->setService('doctrine.configuration.odm_default', null); diff --git a/tests/ServiceManagerFactory.php b/tests/ServiceManagerFactory.php index d863fa7..d84bfa8 100644 --- a/tests/ServiceManagerFactory.php +++ b/tests/ServiceManagerFactory.php @@ -17,9 +17,7 @@ */ class ServiceManagerFactory { - /** - * @return mixed[] - */ + /** @return mixed[] */ public static function getConfiguration(): array { return include __DIR__ . '/TestConfiguration.php'; @@ -30,12 +28,12 @@ public static function getConfiguration(): array * * @param mixed[]|null $configuration */ - public static function getServiceManager(?array $configuration = null): ServiceManager + public static function getServiceManager(array|null $configuration = null): ServiceManager { $configuration = $configuration ?: static::getConfiguration(); $serviceManager = new ServiceManager(); $serviceManagerConfig = new ServiceManagerConfig( - $configuration['service_manager'] ?? [] + $configuration['service_manager'] ?? [], ); $serviceManagerConfig->configureServiceManager($serviceManager); $serviceManager->setService('ApplicationConfig', $configuration);