Skip to content

Commit

Permalink
Add compatibility with Symfony 6
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Nov 18, 2021
1 parent 21d74f2 commit 377c709
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 43 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ jobs:
php-version: "8.0"
stability: "dev"
symfony-version: "5.4.*"
- dependencies: "highest"
os: "ubuntu-20.04"
driver-version: "stable"
php-version: "8.0"
stability: "dev"
symfony-version: "6.0.*"

services:
mongodb:
Expand Down
28 changes: 6 additions & 22 deletions DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,34 +458,23 @@ protected function loadDocumentManagerBundlesMappingInformation(array $documentM

/**
* @param string $name
*
* @return string
*/
protected function getObjectManagerElementName($name)
protected function getObjectManagerElementName($name): string
{
return 'doctrine_mongodb.odm.' . $name;
}

/**
* @return string
*/
protected function getMappingObjectDefaultName()
protected function getMappingObjectDefaultName(): string
{
return 'Document';
}

/**
* @return string
*/
protected function getMappingResourceConfigDirectory()
protected function getMappingResourceConfigDirectory(): string
{
return 'Resources/config/doctrine';
}

/**
* @return string
*/
protected function getMappingResourceExtension()
protected function getMappingResourceExtension(): string
{
return 'mongodb';
}
Expand All @@ -495,10 +484,7 @@ protected function getMetadataDriverClass(string $driverType): string
return '%' . $this->getObjectManagerElementName('metadata.' . $driverType . '.class') . '%';
}

/**
* @return string
*/
public function getAlias()
public function getAlias(): string
{
return 'doctrine_mongodb';
}
Expand Down Expand Up @@ -528,13 +514,11 @@ public function getXsdValidationBasePath()
* @param string $objectManagerName The object manager name
* @param array $cacheDriver The cache driver mapping
*
* @return string
*
* @throws InvalidArgumentException
*
* @psalm-suppress UndefinedClass this won't be necessary when removing metadata cache configuration
*/
protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheDriver, ContainerBuilder $container)
protected function loadCacheDriver($cacheName, $objectManagerName, array $cacheDriver, ContainerBuilder $container): string
{
if (isset($cacheDriver['namespace'])) {
return parent::loadCacheDriver($cacheName, $objectManagerName, $cacheDriver, $container);
Expand Down
5 changes: 1 addition & 4 deletions DoctrineMongoDBBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public function build(ContainerBuilder $container)
$security->addUserProviderFactory(new EntityFactory('mongodb', 'doctrine_mongodb.odm.security.user.provider'));
}

/**
* @return ExtensionInterface|null
*/
public function getContainerExtension()
public function getContainerExtension(): ?ExtensionInterface
{
return new DoctrineMongoDBExtension();
}
Expand Down
4 changes: 2 additions & 2 deletions Form/ChoiceList/MongoDBQueryBuilderLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct($queryBuilder, ?ObjectManager $manager = null, $clas
/**
* @return object[]
*/
public function getEntities()
public function getEntities(): array
{
return array_values($this->queryBuilder->getQuery()->execute()->toArray());
}
Expand All @@ -65,7 +65,7 @@ public function getEntities()
*
* @return object[]
*/
public function getEntitiesByIds($identifier, array $values)
public function getEntitiesByIds($identifier, array $values): array
{
$qb = clone $this->queryBuilder;

Expand Down
4 changes: 1 addition & 3 deletions Form/Type/DocumentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ class DocumentType extends DoctrineType
/**
* @param object $queryBuilder
* @param string $class
*
* @return EntityLoaderInterface
*/
public function getLoader(ObjectManager $manager, $queryBuilder, $class)
public function getLoader(ObjectManager $manager, $queryBuilder, $class): EntityLoaderInterface
{
return new MongoDBQueryBuilderLoader(
$queryBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

namespace DoctrineMongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\AnnotationsBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

/**
* @MongoDB\Document
*/
class Test
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace DoctrineMongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\AttributesBundle\Document;

use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;

#[MongoDB\Document]
class Test
{
}
11 changes: 11 additions & 0 deletions UPGRADE-4.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@ UPGRADE FROM 4.x to 4.4
been marked as `@internal`, you should not extend from this class.
* The `doctrine_mongodb.odm.command_logger` service has been deprecated. You should use
`doctrine_mongodb.odm.psr_command_logger` instead.
* [BC Break] In order to have compatibility with Symfony 6, return types have
been added to the following methods:
* `Doctrine\Bundle\MongoDBBundle\DependencyInjection\DoctrineMongoDBExtension::getObjectManagerElementName()`
* `Doctrine\Bundle\MongoDBBundle\DependencyInjection\DoctrineMongoDBExtension::getMappingObjectDefaultName()`
* `Doctrine\Bundle\MongoDBBundle\DependencyInjection\DoctrineMongoDBExtension::getMappingResourceExtension()`
* `Doctrine\Bundle\MongoDBBundle\DependencyInjection\DoctrineMongoDBExtension::getAlias()`
* `Doctrine\Bundle\MongoDBBundle\DependencyInjection\DoctrineMongoDBExtension::loadCacheDriver()`
* `Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle::getContainerExtension()`
* `Doctrine\Bundle\MongoDBBundle\Form\ChoiceList\MongoDBQueryBuilderLoader::getEntities()`
* `Doctrine\Bundle\MongoDBBundle\Form\ChoiceList\MongoDBQueryBuilderLoader::getEntitiesByIds()`
* `Doctrine\Bundle\MongoDBBundle\Form\Type\DocumentType::getLoader()`
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"doctrine/annotations": "^1.13",
"doctrine/mongodb-odm": "2.3.x-dev",
"doctrine/persistence": "^1.3.6|^2.0",
"symfony/config": "^4.3.3|^5.0",
"psr/log": "^1.0|^2.0|^3.0",
"symfony/console": "^4.4.6|^5.0",
"symfony/dependency-injection": "^4.3.3|^5.0",
"symfony/config": "^4.4|^5.3|^6.0",
"symfony/console": "^4.4.6|^5.3|^6.0",
"symfony/dependency-injection": "^4.4|^5.3|^6.0",
"symfony/deprecation-contracts": "^2.1",
"symfony/doctrine-bridge": "^4.3.3|^5.0",
"symfony/framework-bundle": "^4.3.3|^5.0",
"symfony/http-kernel": "^4.3.7|^5.0",
"symfony/options-resolver": "^4.3.3|^5.0"
"symfony/doctrine-bridge": "^4.4|^5.3|^6.0",
"symfony/framework-bundle": "^4.4|^5.3|^6.0",
"symfony/http-kernel": "^4.4|^5.0|^6.0",
"symfony/options-resolver": "^4.4|^5.3|^6.0"
},
"conflict": {
"doctrine/data-fixtures": "<1.3"
Expand All @@ -36,12 +36,12 @@
"phpunit/phpunit": "^8.5 || ^9.3",
"psalm/plugin-symfony": "^3.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/form": "^4.3.3|^5.0",
"symfony/form": "^4.3.3|^5.0|^6.0",
"symfony/phpunit-bridge": "^5.3",
"symfony/security-bundle": "^4.4|^5.0",
"symfony/stopwatch": "^4.4|^5.0",
"symfony/validator": "^4.4|^5.0",
"symfony/yaml": "^4.3.3|^5.0",
"symfony/security-bundle": "^4.4|^5.3|^6.0",
"symfony/stopwatch": "^4.4|^5.3|^6.0",
"symfony/validator": "^4.4|^5.3|^6.0",
"symfony/yaml": "^4.3.3|^5.3|^6.0",
"vimeo/psalm": "^4.8"
},
"suggest": {
Expand Down

0 comments on commit 377c709

Please sign in to comment.