Skip to content

Commit 724a3c4

Browse files
greg0ireXWB
authored andcommitted
Address deprecations from persistence (#1600)
* Address deprecations from persistence 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 type declarations of non-constructor methods, 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 * Remove trailing whitespace
1 parent 37802de commit 724a3c4

15 files changed

+26
-22
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"require-dev": {
2525
"doctrine/orm": "^2.5",
2626
"doctrine/doctrine-bundle": "^1.6",
27-
"doctrine/persistence": "^1.3.3",
27+
"doctrine/persistence": "^1.3.4",
2828
"doctrine/phpcr-bundle": "^1.3|^2.0",
2929
"doctrine/phpcr-odm": "^1.4",
3030
"jackalope/jackalope-doctrine-dbal": "^1.2",

src/Doctrine/AbstractElasticaToModelTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace FOS\ElasticaBundle\Doctrine;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Persistence\ManagerRegistry;
1515
use FOS\ElasticaBundle\HybridResult;
1616
use FOS\ElasticaBundle\Transformer\AbstractElasticaToModelTransformer as BaseTransformer;
1717
use FOS\ElasticaBundle\Transformer\HighlightableModelInterface;

src/Doctrine/Listener.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace FOS\ElasticaBundle\Doctrine;
1313

14-
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
14+
use Doctrine\Persistence\Event\LifecycleEventArgs;
1515
use FOS\ElasticaBundle\Persister\ObjectPersister;
1616
use FOS\ElasticaBundle\Persister\ObjectPersisterInterface;
1717
use FOS\ElasticaBundle\Provider\IndexableInterface;
@@ -243,3 +243,5 @@ private function isObjectIndexable($object)
243243
);
244244
}
245245
}
246+
247+
class_exists(LifecycleEventArgs::class);

src/Doctrine/MongoDBPagerProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace FOS\ElasticaBundle\Doctrine;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Persistence\ManagerRegistry;
1515
use FOS\ElasticaBundle\Provider\PagerfantaPager;
1616
use FOS\ElasticaBundle\Provider\PagerProviderInterface;
1717
use Pagerfanta\Adapter\DoctrineODMMongoDBAdapter;
@@ -28,7 +28,7 @@ final class MongoDBPagerProvider implements PagerProviderInterface
2828
* @var ManagerRegistry
2929
*/
3030
private $doctrine;
31-
31+
3232
/**
3333
* @var array
3434
*/

src/Doctrine/ORMPagerProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace FOS\ElasticaBundle\Doctrine;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
1514
use Doctrine\ORM\Query\Expr\From;
1615
use Doctrine\ORM\QueryBuilder;
16+
use Doctrine\Persistence\ManagerRegistry;
1717
use FOS\ElasticaBundle\Provider\PagerfantaPager;
1818
use FOS\ElasticaBundle\Provider\PagerProviderInterface;
1919
use Pagerfanta\Adapter\DoctrineORMAdapter;

src/Doctrine/PHPCRPagerProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace FOS\ElasticaBundle\Doctrine;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Persistence\ManagerRegistry;
1515
use FOS\ElasticaBundle\Provider\PagerfantaPager;
1616
use FOS\ElasticaBundle\Provider\PagerProviderInterface;
1717
use Pagerfanta\Adapter\DoctrineODMPhpcrAdapter;
@@ -35,7 +35,7 @@ final class PHPCRPagerProvider implements PagerProviderInterface
3535
* @var array
3636
*/
3737
private $baseOptions;
38-
38+
3939
/**
4040
* @var RegisterListenersService
4141
*/
@@ -64,13 +64,13 @@ public function provide(array $options = array())
6464

6565
$manager = $this->doctrine->getManagerForClass($this->objectClass);
6666
$repository = $manager->getRepository($this->objectClass);
67-
67+
6868
$adapter = new DoctrineODMPhpcrAdapter(
6969
call_user_func([$repository, $options['query_builder_method']], static::ENTITY_ALIAS)
7070
);
71-
71+
7272
$pager = new PagerfantaPager(new Pagerfanta($adapter));
73-
73+
7474
$this->registerListenersService->register($manager, $pager, $options);
7575

7676
return $pager;

src/Doctrine/RegisterListenersService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,5 @@ private function addListener(PagerInterface $pager, $eventName, \Closure $callab
9999
});
100100
}
101101
}
102+
103+
interface_exists(ObjectManager::class);

src/Doctrine/RepositoryManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace FOS\ElasticaBundle\Doctrine;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Persistence\ManagerRegistry;
1515
use FOS\ElasticaBundle\Finder\FinderInterface;
1616
use FOS\ElasticaBundle\Manager\RepositoryManagerInterface;
1717

tests/Unit/Doctrine/AbstractElasticaToModelTransformerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace FOS\ElasticaBundle\Tests\Unit\Doctrine;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
14+
use Doctrine\Persistence\ManagerRegistry;
1515
use Elastica\Result;
1616
use FOS\ElasticaBundle\Doctrine\AbstractElasticaToModelTransformer;
1717
use FOS\ElasticaBundle\Doctrine\ORM\ElasticaToModelTransformer;

tests/Unit/Doctrine/ORM/ElasticaToModelTransformerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
namespace FOS\ElasticaBundle\Tests\Unit\Doctrine\ORM;
1313

14-
use Doctrine\Common\Persistence\ManagerRegistry;
15-
use Doctrine\Common\Persistence\ObjectManager;
16-
use Doctrine\Common\Persistence\ObjectRepository;
1714
use Doctrine\ORM\AbstractQuery;
1815
use Doctrine\ORM\Query\Expr;
1916
use Doctrine\ORM\QueryBuilder;
17+
use Doctrine\Persistence\ManagerRegistry;
18+
use Doctrine\Persistence\ObjectManager;
19+
use Doctrine\Persistence\ObjectRepository;
2020
use FOS\ElasticaBundle\Doctrine\ORM\ElasticaToModelTransformer;
2121
use PHPUnit\Framework\TestCase;
2222

@@ -25,7 +25,7 @@ class ElasticaToModelTransformerTest extends TestCase
2525
const OBJECT_CLASS = \stdClass::class;
2626

2727
/**
28-
* @var \Doctrine\Common\Persistence\ManagerRegistry|\PHPUnit_Framework_MockObject_MockObject
28+
* @var \Doctrine\Persistence\ManagerRegistry|\PHPUnit_Framework_MockObject_MockObject
2929
*/
3030
protected $registry;
3131

0 commit comments

Comments
 (0)