Skip to content

Commit

Permalink
feat: Symfony 7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Nov 14, 2023
1 parent f637de0 commit bcf2e59
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 93 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions CacheWarmer/HydratorCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 49 in CacheWarmer/HydratorCacheWarmer.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Parameter $buildDir has null default value, but is not marked as nullable.
{
// we need the directory no matter the hydrator cache generation strategy.
$hydratorCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.hydrator_dir');
Expand Down
4 changes: 2 additions & 2 deletions CacheWarmer/PersistentCollectionCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 50 in CacheWarmer/PersistentCollectionCacheWarmer.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Parameter $buildDir has null default value, but is not marked as nullable.
{
// we need the directory no matter the hydrator cache generation strategy.
$collCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.persistent_collection_dir');
Expand Down
4 changes: 2 additions & 2 deletions CacheWarmer/ProxyCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 51 in CacheWarmer/ProxyCacheWarmer.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.2)

Parameter $buildDir has null default value, but is not marked as nullable.
{
// we need the directory no matter the proxy cache generation strategy.
$proxyCacheDir = (string) $this->container->getParameter('doctrine_mongodb.odm.proxy_dir');
Expand Down
6 changes: 2 additions & 4 deletions Command/ClearMetadataCacheDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*/
class ClearMetadataCacheDoctrineODMCommand extends MetadataCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -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'));

Expand Down
6 changes: 2 additions & 4 deletions Command/CreateSchemaDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
class CreateSchemaDoctrineODMCommand extends CreateCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -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'));

Expand Down
6 changes: 2 additions & 4 deletions Command/DropSchemaDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
class DropSchemaDoctrineODMCommand extends DropCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -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'));

Expand Down
6 changes: 2 additions & 4 deletions Command/GenerateHydratorsDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*/
class GenerateHydratorsDoctrineODMCommand extends GenerateHydratorsCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -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'));

Expand Down
6 changes: 2 additions & 4 deletions Command/GenerateProxiesDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*/
class GenerateProxiesDoctrineODMCommand extends GenerateProxiesCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -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'));

Expand Down
6 changes: 2 additions & 4 deletions Command/InfoDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
*/
class InfoDoctrineODMCommand extends DoctrineODMCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
$this
->setName('doctrine:mongodb:mapping:info')
Expand All @@ -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();

Expand Down
9 changes: 3 additions & 6 deletions Command/LoadDataFixturesDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions Command/QueryDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*/
class QueryDoctrineODMCommand extends QueryCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -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'));

Expand Down
6 changes: 2 additions & 4 deletions Command/ShardDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
class ShardDoctrineODMCommand extends ShardCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -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'));

Expand Down
9 changes: 2 additions & 7 deletions Command/TailCursorDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
{
Expand All @@ -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',
Expand Down
6 changes: 2 additions & 4 deletions Command/UpdateSchemaDoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
class UpdateSchemaDoctrineODMCommand extends UpdateCommand
{
/** @return void */
protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -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'));

Expand Down
4 changes: 1 addition & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions Form/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 4 additions & 8 deletions Form/DoctrineMongoDBTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 41 in Form/DoctrineMongoDBTypeGuesser.php

View workflow job for this annotation

GitHub Actions / Static Analysis with Psalm (8.2)

InvalidReturnType

Form/DoctrineMongoDBTypeGuesser.php:41:65: InvalidReturnType: Not all code paths of Doctrine\Bundle\MongoDBBundle\Form\DoctrineMongoDBTypeGuesser::guessType end in a return statement, return type Symfony\Component\Form\Guess\TypeGuess|null expected (see https://psalm.dev/011)
{
$ret = $this->getMetadata($class);
if (! $ret) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
}
Expand All @@ -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)) {
Expand Down
Loading

0 comments on commit bcf2e59

Please sign in to comment.