From bcf2e59a005ac9d50efc9903e78e5bb5fad2af11 Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Tue, 24 Oct 2023 20:21:03 -0400 Subject: [PATCH] feat: Symfony 7 support --- .github/workflows/continuous-integration.yml | 12 +++---- CacheWarmer/HydratorCacheWarmer.php | 4 +-- .../PersistentCollectionCacheWarmer.php | 4 +-- CacheWarmer/ProxyCacheWarmer.php | 4 +-- .../ClearMetadataCacheDoctrineODMCommand.php | 6 ++-- Command/CreateSchemaDoctrineODMCommand.php | 6 ++-- Command/DropSchemaDoctrineODMCommand.php | 6 ++-- .../GenerateHydratorsDoctrineODMCommand.php | 6 ++-- Command/GenerateProxiesDoctrineODMCommand.php | 6 ++-- Command/InfoDoctrineODMCommand.php | 6 ++-- .../LoadDataFixturesDoctrineODMCommand.php | 9 ++---- Command/QueryDoctrineODMCommand.php | 6 ++-- Command/ShardDoctrineODMCommand.php | 6 ++-- Command/TailCursorDoctrineODMCommand.php | 9 ++---- Command/UpdateSchemaDoctrineODMCommand.php | 6 ++-- DependencyInjection/Configuration.php | 4 +-- Form/DoctrineMongoDBExtension.php | 5 ++- Form/DoctrineMongoDBTypeGuesser.php | 12 +++---- Form/Type/DocumentType.php | 3 +- composer.json | 31 ++++++++++--------- 20 files changed, 58 insertions(+), 93 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 778334bd..ebfc41cb 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -25,12 +25,11 @@ jobs: - "8.1" - "8.2" - "8.3" - stability: - - "stable" symfony-version: - "5.4.*" - - "6.2.*" - "6.3.*" + - "6.4.*" + - "7.0.*" driver-version: - "stable" dependencies: @@ -40,8 +39,10 @@ jobs: os: "ubuntu-20.04" php-version: "8.1" driver-version: "1.5.0" - stability: "stable" symfony-version: "5.4.*" + exclude: + - php-version: "8.1" + symfony-version: "7.0.*" services: mongodb: @@ -79,9 +80,6 @@ jobs: coverage: "pcov" ini-values: "zend.assertions=1" - - name: "Set minimum-stability to stable in Composer" - run: "composer config minimum-stability ${{ matrix.stability }}" - - name: "Install dependencies with Composer" uses: "ramsey/composer-install@v2" with: diff --git a/CacheWarmer/HydratorCacheWarmer.php b/CacheWarmer/HydratorCacheWarmer.php index 7351f308..4e637759 100644 --- a/CacheWarmer/HydratorCacheWarmer.php +++ b/CacheWarmer/HydratorCacheWarmer.php @@ -40,13 +40,13 @@ public function __construct(private ContainerInterface $container) * * @return false */ - public function isOptional() + public function isOptional(): bool { return false; } /** @return string[] */ - public function warmUp(string $cacheDir) + public function warmUp(string $cacheDir, string $buildDir = null): array { // we need the directory no matter the hydrator cache generation strategy. $hydratorCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.hydrator_dir'); diff --git a/CacheWarmer/PersistentCollectionCacheWarmer.php b/CacheWarmer/PersistentCollectionCacheWarmer.php index 135e9017..c146c05a 100644 --- a/CacheWarmer/PersistentCollectionCacheWarmer.php +++ b/CacheWarmer/PersistentCollectionCacheWarmer.php @@ -41,13 +41,13 @@ public function __construct(private ContainerInterface $container) * * @return false */ - public function isOptional() + public function isOptional(): bool { return false; } /** @return string[] */ - public function warmUp(string $cacheDir) + public function warmUp(string $cacheDir, string $buildDir = null): array { // we need the directory no matter the hydrator cache generation strategy. $collCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.persistent_collection_dir'); diff --git a/CacheWarmer/ProxyCacheWarmer.php b/CacheWarmer/ProxyCacheWarmer.php index 1380e8eb..69499625 100644 --- a/CacheWarmer/ProxyCacheWarmer.php +++ b/CacheWarmer/ProxyCacheWarmer.php @@ -42,13 +42,13 @@ public function __construct(private ContainerInterface $container) * * @return false */ - public function isOptional() + public function isOptional(): bool { return false; } /** @return string[] */ - public function warmUp(string $cacheDir) + public function warmUp(string $cacheDir, string $buildDir = null): array { // we need the directory no matter the proxy cache generation strategy. $proxyCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.proxy_dir'); diff --git a/Command/ClearMetadataCacheDoctrineODMCommand.php b/Command/ClearMetadataCacheDoctrineODMCommand.php index 5067c566..be239a1a 100644 --- a/Command/ClearMetadataCacheDoctrineODMCommand.php +++ b/Command/ClearMetadataCacheDoctrineODMCommand.php @@ -14,8 +14,7 @@ */ class ClearMetadataCacheDoctrineODMCommand extends MetadataCommand { - /** @return void */ - protected function configure() + protected function configure(): void { parent::configure(); @@ -35,8 +34,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { DoctrineODMCommand::setApplicationDocumentManager($this->getApplication(), $input->getOption('dm')); diff --git a/Command/CreateSchemaDoctrineODMCommand.php b/Command/CreateSchemaDoctrineODMCommand.php index 2a024916..9fc7fe20 100644 --- a/Command/CreateSchemaDoctrineODMCommand.php +++ b/Command/CreateSchemaDoctrineODMCommand.php @@ -15,8 +15,7 @@ */ class CreateSchemaDoctrineODMCommand extends CreateCommand { - /** @return void */ - protected function configure() + protected function configure(): void { parent::configure(); @@ -35,8 +34,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { DoctrineODMCommand::setApplicationDocumentManager($this->getApplication(), $input->getOption('dm')); diff --git a/Command/DropSchemaDoctrineODMCommand.php b/Command/DropSchemaDoctrineODMCommand.php index cd92b546..33a4bee9 100644 --- a/Command/DropSchemaDoctrineODMCommand.php +++ b/Command/DropSchemaDoctrineODMCommand.php @@ -15,8 +15,7 @@ */ class DropSchemaDoctrineODMCommand extends DropCommand { - /** @return void */ - protected function configure() + protected function configure(): void { parent::configure(); @@ -35,8 +34,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { DoctrineODMCommand::setApplicationDocumentManager($this->getApplication(), $input->getOption('dm')); diff --git a/Command/GenerateHydratorsDoctrineODMCommand.php b/Command/GenerateHydratorsDoctrineODMCommand.php index dcb9e58f..6aee2a5f 100644 --- a/Command/GenerateHydratorsDoctrineODMCommand.php +++ b/Command/GenerateHydratorsDoctrineODMCommand.php @@ -14,8 +14,7 @@ */ class GenerateHydratorsDoctrineODMCommand extends GenerateHydratorsCommand { - /** @return void */ - protected function configure() + protected function configure(): void { parent::configure(); @@ -34,8 +33,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { DoctrineODMCommand::setApplicationDocumentManager($this->getApplication(), $input->getOption('dm')); diff --git a/Command/GenerateProxiesDoctrineODMCommand.php b/Command/GenerateProxiesDoctrineODMCommand.php index b0678a5c..6400d724 100644 --- a/Command/GenerateProxiesDoctrineODMCommand.php +++ b/Command/GenerateProxiesDoctrineODMCommand.php @@ -14,8 +14,7 @@ */ class GenerateProxiesDoctrineODMCommand extends GenerateProxiesCommand { - /** @return void */ - protected function configure() + protected function configure(): void { parent::configure(); @@ -34,8 +33,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { DoctrineODMCommand::setApplicationDocumentManager($this->getApplication(), $input->getOption('dm')); diff --git a/Command/InfoDoctrineODMCommand.php b/Command/InfoDoctrineODMCommand.php index 2e184e26..850f0881 100644 --- a/Command/InfoDoctrineODMCommand.php +++ b/Command/InfoDoctrineODMCommand.php @@ -20,8 +20,7 @@ */ class InfoDoctrineODMCommand extends DoctrineODMCommand { - /** @return void */ - protected function configure() + protected function configure(): void { $this ->setName('doctrine:mongodb:mapping:info') @@ -40,8 +39,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $documentManagerName = $input->hasOption('dm') ? $input->getOption('dm') : $this->getManagerRegistry()->getDefaultManagerName(); diff --git a/Command/LoadDataFixturesDoctrineODMCommand.php b/Command/LoadDataFixturesDoctrineODMCommand.php index 83694e42..557c5719 100644 --- a/Command/LoadDataFixturesDoctrineODMCommand.php +++ b/Command/LoadDataFixturesDoctrineODMCommand.php @@ -32,14 +32,12 @@ public function __construct(?ManagerRegistry $registry = null, ?KernelInterface parent::__construct($registry); } - /** @return bool */ - public function isEnabled() + public function isEnabled(): bool { return parent::isEnabled() && class_exists(Loader::class); } - /** @return void */ - protected function configure() + protected function configure(): void { $this ->setName('doctrine:mongodb:fixtures:load') @@ -69,8 +67,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $dm = $this->getManagerRegistry()->getManager($input->getOption('dm')); $ui = new SymfonyStyle($input, $output); diff --git a/Command/QueryDoctrineODMCommand.php b/Command/QueryDoctrineODMCommand.php index 3b2f9cde..5c6e6381 100644 --- a/Command/QueryDoctrineODMCommand.php +++ b/Command/QueryDoctrineODMCommand.php @@ -14,8 +14,7 @@ */ class QueryDoctrineODMCommand extends QueryCommand { - /** @return void */ - protected function configure() + protected function configure(): void { parent::configure(); @@ -24,8 +23,7 @@ protected function configure() ->addOption('dm', null, InputOption::VALUE_OPTIONAL, 'The document manager to use for this command.'); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { DoctrineODMCommand::setApplicationDocumentManager($this->getApplication(), $input->getOption('dm')); diff --git a/Command/ShardDoctrineODMCommand.php b/Command/ShardDoctrineODMCommand.php index c13cf10d..33e70a1b 100644 --- a/Command/ShardDoctrineODMCommand.php +++ b/Command/ShardDoctrineODMCommand.php @@ -15,8 +15,7 @@ */ class ShardDoctrineODMCommand extends ShardCommand { - /** @return void */ - protected function configure() + protected function configure(): void { parent::configure(); @@ -35,8 +34,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { DoctrineODMCommand::setApplicationDocumentManager($this->getApplication(), $input->getOption('dm')); diff --git a/Command/TailCursorDoctrineODMCommand.php b/Command/TailCursorDoctrineODMCommand.php index 4e37cdc5..5aa7d5bf 100644 --- a/Command/TailCursorDoctrineODMCommand.php +++ b/Command/TailCursorDoctrineODMCommand.php @@ -13,8 +13,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Throwable; use function sleep; @@ -26,10 +24,8 @@ * * @deprecated since version 4.4 */ -class TailCursorDoctrineODMCommand extends Command implements ContainerAwareInterface +class TailCursorDoctrineODMCommand extends Command { - use ContainerAwareTrait; - /** @return void */ protected function configure() { @@ -43,8 +39,7 @@ protected function configure() ->addOption('sleep-time', null, InputOption::VALUE_REQUIRED, 'The number of seconds to wait between two checks.', '10'); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { trigger_deprecation( 'doctrine/mongodb-odm-bundle', diff --git a/Command/UpdateSchemaDoctrineODMCommand.php b/Command/UpdateSchemaDoctrineODMCommand.php index 870c9a5b..3895efc0 100644 --- a/Command/UpdateSchemaDoctrineODMCommand.php +++ b/Command/UpdateSchemaDoctrineODMCommand.php @@ -15,8 +15,7 @@ */ class UpdateSchemaDoctrineODMCommand extends UpdateCommand { - /** @return void */ - protected function configure() + protected function configure(): void { parent::configure(); @@ -35,8 +34,7 @@ protected function configure() ); } - /** @return int */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { DoctrineODMCommand::setApplicationDocumentManager($this->getApplication(), $input->getOption('dm')); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f29b0053..8271df53 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -29,10 +29,8 @@ class Configuration implements ConfigurationInterface { /** * Generates the configuration tree builder. - * - * @return TreeBuilder */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('doctrine_mongodb'); $rootNode = $treeBuilder->getRootNode(); diff --git a/Form/DoctrineMongoDBExtension.php b/Form/DoctrineMongoDBExtension.php index 2cda9710..7428e77c 100644 --- a/Form/DoctrineMongoDBExtension.php +++ b/Form/DoctrineMongoDBExtension.php @@ -23,15 +23,14 @@ public function __construct(ManagerRegistry $registry) } /** @return FormTypeInterface[] */ - protected function loadTypes() + protected function loadTypes(): array { return [ new Type\DocumentType($this->registry), ]; } - /** @return FormTypeGuesserInterface|null */ - protected function loadTypeGuesser() + protected function loadTypeGuesser(): ?FormTypeGuesserInterface { return new DoctrineMongoDBTypeGuesser($this->registry); } diff --git a/Form/DoctrineMongoDBTypeGuesser.php b/Form/DoctrineMongoDBTypeGuesser.php index a57e01bd..e7d20967 100644 --- a/Form/DoctrineMongoDBTypeGuesser.php +++ b/Form/DoctrineMongoDBTypeGuesser.php @@ -38,8 +38,7 @@ public function __construct(ManagerRegistry $registry) $this->registry = $registry; } - /** @return TypeGuess|null */ - public function guessType(string $class, string $property) + public function guessType(string $class, string $property): ?TypeGuess { $ret = $this->getMetadata($class); if (! $ret) { @@ -116,8 +115,7 @@ public function guessType(string $class, string $property) } } - /** @return ValueGuess|null */ - public function guessRequired(string $class, string $property) + public function guessRequired(string $class, string $property): ?ValueGuess { $ret = $this->getMetadata($class); if ($ret && $ret[0]->hasField($property)) { @@ -137,8 +135,7 @@ public function guessRequired(string $class, string $property) return null; } - /** @return ValueGuess|null */ - public function guessMaxLength(string $class, string $property) + public function guessMaxLength(string $class, string $property): ?ValueGuess { return null; } @@ -150,8 +147,7 @@ public function guessMinLength($class, $property) { } - /** @return ValueGuess|null */ - public function guessPattern(string $class, string $property) + public function guessPattern(string $class, string $property): ?ValueGuess { $ret = $this->getMetadata($class); if (! $ret || ! $ret[0]->hasField($property) || $ret[0]->hasAssociation($property)) { diff --git a/Form/Type/DocumentType.php b/Form/Type/DocumentType.php index 97653387..fe708c39 100644 --- a/Form/Type/DocumentType.php +++ b/Form/Type/DocumentType.php @@ -30,8 +30,7 @@ public function getLoader(ObjectManager $manager, object $queryBuilder, string $ ); } - /** @return void */ - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { parent::configureOptions($resolver); diff --git a/composer.json b/composer.json index be732051..3def4cea 100644 --- a/composer.json +++ b/composer.json @@ -31,27 +31,27 @@ "doctrine/persistence": "^2.2 || ^3.0", "jean85/pretty-package-versions": "^1.3.0 || ^2.0.1", "psr/log": "^1.0 || ^2.0 || ^3.0", - "symfony/config": "^5.4 || ^6.2", - "symfony/console": "^5.4 || ^6.2", - "symfony/dependency-injection": "^5.4 || ^6.2", + "symfony/config": "^5.4 || ^6.2 || ^7.0", + "symfony/console": "^5.4 || ^6.2 || ^7.0", + "symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0", "symfony/deprecation-contracts": "^2.1 || ^3.0", - "symfony/doctrine-bridge": "^5.4.19 || ^6.2", - "symfony/framework-bundle": "^5.4 || ^6.2", - "symfony/http-kernel": "^5.4 || ^6.2", - "symfony/options-resolver": "^5.4 || ^6.2" + "symfony/doctrine-bridge": "^5.4.19 || ^6.2 || ^7.0", + "symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0", + "symfony/http-kernel": "^5.4 || ^6.2 || ^7.0", + "symfony/options-resolver": "^5.4 || ^6.2 || ^7.0" }, "require-dev": { "doctrine/coding-standard": "^11.0", "doctrine/data-fixtures": "^1.3", "phpunit/phpunit": "^9.5.5", "psalm/plugin-symfony": "^5.0", - "symfony/browser-kit": "^5.4 || ^6.2", - "symfony/form": "^5.4 || ^6.2", - "symfony/phpunit-bridge": "^6.2", - "symfony/security-bundle": "^5.4 || ^6.2", - "symfony/stopwatch": "^5.4 || ^6.2", - "symfony/validator": "^5.4 || ^6.2", - "symfony/yaml": "^5.4 || ^6.2", + "symfony/browser-kit": "^5.4 || ^6.2 || ^7.0", + "symfony/form": "^5.4 || ^6.2 || ^7.0", + "symfony/phpunit-bridge": "^6.2 || ^7.0", + "symfony/security-bundle": "^5.4 || ^6.2 || ^7.0", + "symfony/stopwatch": "^5.4 || ^6.2 || ^7.0", + "symfony/validator": "^5.4 || ^6.2 || ^7.0", + "symfony/yaml": "^5.4 || ^6.2 || ^7.0", "vimeo/psalm": "^5.12" }, "conflict": { @@ -60,7 +60,8 @@ "suggest": { "doctrine/data-fixtures": "Load data fixtures" }, - "minimum-stability": "stable", + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { "Doctrine\\Bundle\\MongoDBBundle\\": ""