Skip to content

Commit

Permalink
Address deprecations from persistence library
Browse files Browse the repository at this point in the history
A backwards-compatibility layer has been added to persistence to help
consumers move to the new namespacing. It is based on class aliases,
which means the type declaration changes should not be a BC-break: types
are the same.
See doctrine/persistence#71

This means:
- using the new namespaces
- adding autoload calls for new types to types that may be extended and
use persistence types in methods signatures for which compatibility
checks may happen,
so that signature compatibility is recognized by old versions of php.
More details on this at
https://dev.to/greg0ire/how-to-deprecate-a-type-in-php-48cf

Fixes #616 as a side effect, but the real fix is at
symfony/symfony#35728
  • Loading branch information
greg0ire committed Mar 15, 2020
1 parent 6f94729 commit ce5f39b
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion CacheWarmer/HydratorCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Doctrine\Bundle\MongoDBBundle\CacheWarmer;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\ManagerRegistry;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
Expand Down
2 changes: 1 addition & 1 deletion CacheWarmer/PersistentCollectionCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Doctrine\Bundle\MongoDBBundle\CacheWarmer;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\ManagerRegistry;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
Expand Down
2 changes: 1 addition & 1 deletion CacheWarmer/ProxyCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Doctrine\Bundle\MongoDBBundle\CacheWarmer;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\Persistence\ManagerRegistry;
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
Expand Down
6 changes: 3 additions & 3 deletions DependencyInjection/Compiler/DoctrineMongoDBMappingsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler;

use Doctrine\Common\Persistence\Mapping\Driver\PHPDriver;
use Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver;
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
use Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver;
use Doctrine\Persistence\Mapping\Driver\PHPDriver;
use Doctrine\Persistence\Mapping\Driver\StaticPHPDriver;
use Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator;
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterMappingsPass;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
Expand Down
2 changes: 1 addition & 1 deletion Form/ChoiceList/MongoDBQueryBuilderLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Doctrine\Bundle\MongoDBBundle\Form\ChoiceList;

use Closure;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ODM\MongoDB\Query\Builder;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use function array_values;
Expand Down
2 changes: 1 addition & 1 deletion Form/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\Bundle\MongoDBBundle\Form;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Form\AbstractExtension;

/**
Expand Down
4 changes: 2 additions & 2 deletions Form/DoctrineMongoDBTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Doctrine\Bundle\MongoDBBundle\Form;

use Doctrine\Bundle\MongoDBBundle\Form\Type\DocumentType;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\Mapping\MappingException;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\Mapping\MappingException;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/DocumentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
namespace Doctrine\Bundle\MongoDBBundle\Form\Type;

use Doctrine\Bundle\MongoDBBundle\Form\ChoiceList\MongoDBQueryBuilderLoader;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\ObjectManager;
use InvalidArgumentException;
use Symfony\Bridge\Doctrine\Form\Type\DoctrineType;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function interface_exists;

/**
* Form type for a MongoDB document
Expand Down Expand Up @@ -83,3 +84,5 @@ public function getName()
return $this->getBlockPrefix();
}
}

interface_exists(ObjectManager::class);
2 changes: 1 addition & 1 deletion Repository/ContainerRepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
namespace Doctrine\Bundle\MongoDBBundle\Repository;

use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\ServiceRepositoryCompilerPass;
use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
use Doctrine\ODM\MongoDB\Repository\RepositoryFactory;
use Doctrine\Persistence\ObjectRepository;
use Psr\Container\ContainerInterface;
use RuntimeException;
use function class_exists;
Expand Down
2 changes: 1 addition & 1 deletion Repository/ServiceRepositoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Doctrine\Bundle\MongoDBBundle\Repository;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\ManagerRegistry;
use LogicException;
use function sprintf;

Expand Down
2 changes: 1 addition & 1 deletion Resources/config/mongodb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<parameter key="doctrine_mongodb.odm.cache.xcache.class">Doctrine\Common\Cache\XcacheCache</parameter>

<!-- metadata -->
<parameter key="doctrine_mongodb.odm.metadata.driver_chain.class">Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain</parameter>
<parameter key="doctrine_mongodb.odm.metadata.driver_chain.class">Doctrine\Persistence\Mapping\Driver\MappingDriverChain</parameter>
<parameter key="doctrine_mongodb.odm.metadata.annotation.class">Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver</parameter>
<parameter key="doctrine_mongodb.odm.metadata.xml.class">Doctrine\Bundle\MongoDBBundle\Mapping\Driver\XmlDriver</parameter>

Expand Down
2 changes: 1 addition & 1 deletion Tests/CacheWarmer/PersistentCollectionCacheWarmerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

use Doctrine\Bundle\MongoDBBundle\CacheWarmer\PersistentCollectionCacheWarmer;
use Doctrine\Bundle\MongoDBBundle\Tests\TestCase;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\PersistentCollection\PersistentCollectionGenerator;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use function sys_get_temp_dir;
Expand Down
2 changes: 1 addition & 1 deletion Tests/DependencyInjection/AbstractMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
use Doctrine\Common\Cache\MemcachedCache;
use Doctrine\Common\Cache\XcacheCache;
use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ODM\MongoDB\Configuration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
use MongoDB\Client;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit_Framework_AssertionFailedError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Doctrine\Bundle\MongoDBBundle\Fixture\ODMFixtureInterface;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;

class DependentOnRequiredConstructorArgsFixtures implements ODMFixtureInterface, DependentFixtureInterface
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/FooBundle/DataFixtures/OtherFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Doctrine\Bundle\MongoDBBundle\Fixture\FixtureGroupInterface;
use Doctrine\Bundle\MongoDBBundle\Fixture\ODMFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;

class OtherFixtures implements ODMFixtureInterface, FixtureGroupInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\FooBundle\DataFixtures;

use Doctrine\Bundle\MongoDBBundle\Fixture\ODMFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;

class RequiredConstructorArgsFixtures implements ODMFixtureInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Doctrine\Bundle\MongoDBBundle\Fixture\FixtureGroupInterface;
use Doctrine\Bundle\MongoDBBundle\Fixture\ODMFixtureInterface;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;

class WithDependenciesFixtures implements ODMFixtureInterface, DependentFixtureInterface, FixtureGroupInterface
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Form/Type/DocumentTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\Form\Category;
use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\Form\Document;
use Doctrine\Bundle\MongoDBBundle\Tests\TestCase;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\ManagerRegistry;
use MongoDB\BSON\ObjectId;
use PHPUnit_Framework_MockObject_MockObject;
use Symfony\Component\Form\AbstractType;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Form/Type/TypeGuesserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\Form\Document;
use Doctrine\Bundle\MongoDBBundle\Tests\Fixtures\Form\Guesser;
use Doctrine\Bundle\MongoDBBundle\Tests\TestCase;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit_Framework_MockObject_MockObject;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Test\TypeTestCase;
Expand Down
6 changes: 3 additions & 3 deletions Tests/Mapping/Driver/AbstractDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Doctrine\Bundle\MongoDBBundle\Tests\Mapping\Driver;

use Doctrine\Common\Persistence\Mapping\Driver\FileDriver;
use Doctrine\Persistence\Mapping\Driver\FileDriver;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;

Expand Down Expand Up @@ -38,7 +38,7 @@ public function testFindMappingFileInSubnamespace()
}

/**
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
* @expectedException Doctrine\Persistence\Mapping\MappingException
*/
public function testFindMappingFileNamespacedFoundFileNotFound()
{
Expand All @@ -49,7 +49,7 @@ public function testFindMappingFileNamespacedFoundFileNotFound()
}

/**
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
* @expectedException Doctrine\Persistence\Mapping\MappingException
*/
public function testFindMappingNamespaceNotFound()
{
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"php": "^7.2",
"doctrine/annotations": "^1.2",
"doctrine/mongodb-odm": "^2.0.0",
"doctrine/persistence": "^1.3.6",
"psr/log": "^1.0",
"symfony/console": "^4.3.3|^5.0",
"symfony/dependency-injection": "^4.3.3|^5.0",
Expand Down

0 comments on commit ce5f39b

Please sign in to comment.