Skip to content

Commit 8a9954e

Browse files
authored
Address deprecations from persistence (#7953)
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
1 parent 527fff5 commit 8a9954e

File tree

81 files changed

+207
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+207
-170
lines changed

UPGRADE.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Whole Doctrine\ORM\Tools\Export namespace with all its members have been depreca
4747
## Deprecated `Doctrine\ORM\Proxy\Proxy` marker interface
4848

4949
Proxy objects in Doctrine ORM 3.0 will no longer implement `Doctrine\ORM\Proxy\Proxy` nor
50-
`Doctrine\Common\Persistence\Proxy`: instead, they implement
50+
`Doctrine\Persistence\Proxy`: instead, they implement
5151
`ProxyManager\Proxy\GhostObjectInterface`.
5252

5353
These related classes have been deprecated:
@@ -439,17 +439,17 @@ above you must implement these new methods.
439439

440440
## Metadata Drivers
441441

442-
Metadata drivers have been rewritten to reuse code from Doctrine\Common. Anyone who is using the
442+
Metadata drivers have been rewritten to reuse code from `Doctrine\Persistence`. Anyone who is using the
443443
`Doctrine\ORM\Mapping\Driver\Driver` interface should instead refer to
444-
`Doctrine\Common\Persistence\Mapping\Driver\MappingDriver`. Same applies to
444+
`Doctrine\Persistence\Mapping\Driver\MappingDriver`. Same applies to
445445
`Doctrine\ORM\Mapping\Driver\AbstractFileDriver`: you should now refer to
446-
`Doctrine\Common\Persistence\Mapping\Driver\FileDriver`.
446+
`Doctrine\Persistence\Mapping\Driver\FileDriver`.
447447

448448
Also, following mapping drivers have been deprecated, please use their replacements in Doctrine\Common as listed:
449449

450-
* `Doctrine\ORM\Mapping\Driver\DriverChain` => `Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain`
451-
* `Doctrine\ORM\Mapping\Driver\PHPDriver` => `Doctrine\Common\Persistence\Mapping\Driver\PHPDriver`
452-
* `Doctrine\ORM\Mapping\Driver\StaticPHPDriver` => `Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver`
450+
* `Doctrine\ORM\Mapping\Driver\DriverChain` => `Doctrine\Persistence\Mapping\Driver\MappingDriverChain`
451+
* `Doctrine\ORM\Mapping\Driver\PHPDriver` => `Doctrine\Persistence\Mapping\Driver\PHPDriver`
452+
* `Doctrine\ORM\Mapping\Driver\StaticPHPDriver` => `Doctrine\Persistence\Mapping\Driver\StaticPHPDriver`
453453

454454
# Upgrade to 2.2
455455

@@ -538,7 +538,7 @@ Previously EntityManager#find(null) returned null. It now throws an exception.
538538

539539
## Interface for EntityRepository
540540

541-
The EntityRepository now has an interface Doctrine\Common\Persistence\ObjectRepository. This means that your classes that override EntityRepository and extend find(), findOneBy() or findBy() must be adjusted to follow this interface.
541+
The EntityRepository now has an interface Doctrine\Persistence\ObjectRepository. This means that your classes that override EntityRepository and extend find(), findOneBy() or findBy() must be adjusted to follow this interface.
542542

543543
## AnnotationReader changes
544544

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"doctrine/dbal": "^2.9.3",
2626
"doctrine/event-manager": "^1.1",
2727
"doctrine/instantiator": "^1.3",
28-
"doctrine/persistence": "^1.2",
28+
"doctrine/persistence": "^1.3.3",
2929
"ocramius/package-versions": "^1.2",
3030
"symfony/console": "^3.0|^4.0|^5.0"
3131
},

composer.lock

Lines changed: 16 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/en/cookbook/implementing-the-notify-changetracking-policy.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ implement the ``NotifyPropertyChanged`` interface from the
2222
.. code-block:: php
2323
2424
<?php
25-
use Doctrine\Common\NotifyPropertyChanged;
26-
use Doctrine\Common\PropertyChangedListener;
25+
use Doctrine\Persistence\NotifyPropertyChanged;
26+
use Doctrine\Persistence\PropertyChangedListener;
2727
2828
abstract class DomainObject implements NotifyPropertyChanged
2929
{

docs/en/reference/change-tracking-policies.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ follows:
7171
.. code-block:: php
7272
7373
<?php
74-
use Doctrine\Common\NotifyPropertyChanged,
75-
Doctrine\Common\PropertyChangedListener;
74+
use Doctrine\Persistence\NotifyPropertyChanged,
75+
Doctrine\Persistence\PropertyChangedListener;
7676
7777
/**
7878
* @Entity

docs/en/reference/events.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ A lifecycle event listener looks like the following:
423423
.. code-block:: php
424424
425425
<?php
426-
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
426+
use Doctrine\Persistence\Event\LifecycleEventArgs;
427427
428428
class MyEventListener
429429
{
@@ -445,8 +445,8 @@ A lifecycle event subscriber may look like this:
445445
446446
<?php
447447
use Doctrine\ORM\Events;
448-
use Doctrine\Common\EventSubscriber;
449-
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
448+
use Doctrine\EventSubscriber;
449+
use Doctrine\Persistence\Event\LifecycleEventArgs;
450450
451451
class MyEventSubscriber implements EventSubscriber
452452
{

lib/Doctrine/ORM/AbstractQuery.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919

2020
namespace Doctrine\ORM;
2121

22-
use Doctrine\Common\Persistence\Mapping\MappingException;
2322
use Doctrine\Common\Util\ClassUtils;
2423
use Doctrine\Common\Collections\Collection;
2524
use Doctrine\Common\Collections\ArrayCollection;
26-
25+
use Doctrine\DBAL\Cache\QueryCacheProfile;
2726
use Doctrine\ORM\Mapping\MappingException as ORMMappingException;
2827
use Doctrine\ORM\Query\Parameter;
2928
use Doctrine\ORM\Cache\QueryCacheKey;
30-
use Doctrine\DBAL\Cache\QueryCacheProfile;
29+
use Doctrine\Persistence\Mapping\MappingException;
3130

3231
/**
3332
* Base contract for ORM queries. Base class for Query and NativeQuery.

lib/Doctrine/ORM/Configuration.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
use Doctrine\Common\Annotations\SimpleAnnotationReader;
2626
use Doctrine\Common\Cache\ArrayCache;
2727
use Doctrine\Common\Cache\Cache as CacheDriver;
28-
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriver;
29-
use Doctrine\Common\Persistence\ObjectRepository;
3028
use Doctrine\Common\Proxy\AbstractProxyFactory;
3129
use Doctrine\ORM\Cache\CacheConfiguration;
3230
use Doctrine\ORM\Mapping\ClassMetadataFactory;
@@ -39,6 +37,9 @@
3937
use Doctrine\ORM\Mapping\QuoteStrategy;
4038
use Doctrine\ORM\Repository\DefaultRepositoryFactory;
4139
use Doctrine\ORM\Repository\RepositoryFactory;
40+
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
41+
use Doctrine\Persistence\ObjectRepository;
42+
use function interface_exists;
4243

4344
/**
4445
* Configuration container for all configuration options of Doctrine.
@@ -676,7 +677,7 @@ public function getFilterClassName($name)
676677
*
677678
* @return void
678679
*
679-
* @throws ORMException If not is a \Doctrine\Common\Persistence\ObjectRepository
680+
* @throws ORMException If $classname is not an ObjectRepository.
680681
*/
681682
public function setDefaultRepositoryClassName($className)
682683
{
@@ -918,3 +919,5 @@ public function setDefaultQueryHint($name, $value)
918919
$this->_attributes['defaultQueryHints'][$name] = $value;
919920
}
920921
}
922+
923+
interface_exists(MappingDriver::class);

lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php

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

2222
use Doctrine\ORM\Query\ResultSetMapping;
2323
use Doctrine\ORM\EntityManagerInterface;
24-
use Doctrine\Common\Persistence\ObjectManagerDecorator;
24+
use Doctrine\Persistence\ObjectManagerDecorator;
2525

2626
/**
2727
* Base class for EntityManager decorators

lib/Doctrine/ORM/EntityManager.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
use Doctrine\ORM\Proxy\ProxyFactory;
2929
use Doctrine\ORM\Query\FilterCollection;
3030
use Doctrine\Common\Util\ClassUtils;
31+
use Doctrine\Persistence\Mapping\MappingException;
32+
use Doctrine\Persistence\ObjectRepository;
3133
use Throwable;
3234
use const E_USER_DEPRECATED;
3335
use function trigger_error;
@@ -546,9 +548,9 @@ public function getPartialReference($entityName, $identifier)
546548
*
547549
* @return void
548550
*
549-
* @throws ORMInvalidArgumentException if a non-null non-string value is given
550-
* @throws \Doctrine\Common\Persistence\Mapping\MappingException if a $entityName is given, but that entity is not
551-
* found in the mappings
551+
* @throws ORMInvalidArgumentException If a non-null non-string value is given.
552+
* @throws MappingException If a $entityName is given, but that entity is not
553+
* found in the mappings.
552554
*/
553555
public function clear($entityName = null)
554556
{
@@ -729,7 +731,7 @@ public function lock($entity, $lockMode, $lockVersion = null)
729731
*
730732
* @param string $entityName The name of the entity.
731733
*
732-
* @return \Doctrine\Common\Persistence\ObjectRepository|\Doctrine\ORM\EntityRepository The repository class.
734+
* @return ObjectRepository|EntityRepository The repository class.
733735
*/
734736
public function getRepository($entityName)
735737
{

0 commit comments

Comments
 (0)