Skip to content

Commit

Permalink
Remove deprecated methods and classes
Browse files Browse the repository at this point in the history
This is a follow-up for doctrine#9876
  • Loading branch information
greg0ire committed Jan 4, 2023
1 parent 601948b commit 84e78b8
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 147 deletions.
18 changes: 17 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Upgrade to 3.0

## Removed `getEntityManager()` in `Doctrine\ORM\Event\OnClearEventArgs` and `Doctrine\ORM\Event\*FlushEventArgs`

Use `getObjectManager()` instead.

## BC BREAK: Removed `Doctrine\ORM\Event\LifecycleEventArgs` class.

Use one of the dedicated event classes instead:

* `Doctrine\ORM\Event\PrePersistEventArgs`
* `Doctrine\ORM\Event\PreUpdateEventArgs`
* `Doctrine\ORM\Event\PreRemoveEventArgs`
* `Doctrine\ORM\Event\PostPersistEventArgs`
* `Doctrine\ORM\Event\PostUpdateEventArgs`
* `Doctrine\ORM\Event\PostRemoveEventArgs`
* `Doctrine\ORM\Event\PostLoadEventArgs`

## BC BREAK: Removed `AttributeDriver::$entityAnnotationClasses` and `AttributeDriver::getReader()`

* If you need to change the behavior of `AttributeDriver::isTransient()`,
Expand Down Expand Up @@ -180,7 +196,7 @@ class MyStrategy implements NamingStrategy
}
```

## BC BREAK: Remove `StaticPHPDriver` and `DriverChain`
## BC BREAK: Remove `StaticPHPDriver` and `DriverChain`

Use `Doctrine\Persistence\Mapping\Driver\StaticPHPDriver` and
`Doctrine\Persistence\Mapping\Driver\MappingDriverChain` from
Expand Down
72 changes: 0 additions & 72 deletions lib/Doctrine/ORM/Event/LifecycleEventArgs.php

This file was deleted.

17 changes: 0 additions & 17 deletions lib/Doctrine/ORM/Event/OnClearEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\ORM\Event;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\OnClearEventArgs as BaseOnClearEventArgs;

Expand All @@ -17,20 +16,4 @@
*/
class OnClearEventArgs extends BaseOnClearEventArgs
{
/**
* Retrieves associated EntityManager.
*
* @deprecated 2.13. Use {@see getObjectManager} instead.
*/
public function getEntityManager(): EntityManagerInterface
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/9875',
'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.',
__METHOD__,
);

return $this->getObjectManager();
}
}
19 changes: 0 additions & 19 deletions lib/Doctrine/ORM/Event/OnFlushEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\ORM\Event;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\ManagerEventArgs;

Expand All @@ -17,22 +16,4 @@
*/
class OnFlushEventArgs extends ManagerEventArgs
{
/**
* Retrieve associated EntityManager.
*
* @deprecated 2.13. Use {@see getObjectManager} instead.
*
* @return EntityManagerInterface
*/
public function getEntityManager()
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/9875',
'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.',
__METHOD__,
);

return $this->getObjectManager();
}
}
19 changes: 0 additions & 19 deletions lib/Doctrine/ORM/Event/PostFlushEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\ORM\Event;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\ManagerEventArgs;

Expand All @@ -17,22 +16,4 @@
*/
class PostFlushEventArgs extends ManagerEventArgs
{
/**
* Retrieves associated EntityManager.
*
* @deprecated 2.13. Use {@see getObjectManager} instead.
*
* @return EntityManagerInterface
*/
public function getEntityManager()
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/9875',
'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.',
__METHOD__,
);

return $this->getObjectManager();
}
}
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Event/PostLoadEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Doctrine\ORM\Event;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\LifecycleEventArgs;

/** @extends LifecycleEventArgs<EntityManagerInterface> */
final class PostLoadEventArgs extends LifecycleEventArgs
{
}
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Event/PostPersistEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Doctrine\ORM\Event;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\LifecycleEventArgs;

/** @extends LifecycleEventArgs<EntityManagerInterface> */
final class PostPersistEventArgs extends LifecycleEventArgs
{
}
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Event/PostRemoveEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Doctrine\ORM\Event;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\LifecycleEventArgs;

/** @extends LifecycleEventArgs<EntityManagerInterface> */
final class PostRemoveEventArgs extends LifecycleEventArgs
{
}
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Event/PostUpdateEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Doctrine\ORM\Event;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\LifecycleEventArgs;

/** @extends LifecycleEventArgs<EntityManagerInterface> */
final class PostUpdateEventArgs extends LifecycleEventArgs
{
}
17 changes: 0 additions & 17 deletions lib/Doctrine/ORM/Event/PreFlushEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\ORM\Event;

use Doctrine\Deprecations\Deprecation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\ManagerEventArgs;

Expand All @@ -17,20 +16,4 @@
*/
class PreFlushEventArgs extends ManagerEventArgs
{
/**
* @deprecated 2.13. Use {@see getObjectManager} instead.
*
* @return EntityManagerInterface
*/
public function getEntityManager()
{
Deprecation::trigger(
'doctrine/orm',
'https://github.com/doctrine/orm/issues/9875',
'Method %s() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead.',
__METHOD__,
);

return $this->getObjectManager();
}
}
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Event/PrePersistEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Doctrine\ORM\Event;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\LifecycleEventArgs;

/** @extends LifecycleEventArgs<EntityManagerInterface> */
final class PrePersistEventArgs extends LifecycleEventArgs
{
}
4 changes: 4 additions & 0 deletions lib/Doctrine/ORM/Event/PreRemoveEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace Doctrine\ORM\Event;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\Event\LifecycleEventArgs;

/** @extends LifecycleEventArgs<EntityManagerInterface> */
final class PreRemoveEventArgs extends LifecycleEventArgs
{
}
3 changes: 3 additions & 0 deletions lib/Doctrine/ORM/Event/PreUpdateEventArgs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use InvalidArgumentException;

use function get_debug_type;
use function sprintf;

/**
* Class that holds event arguments for a preUpdate event.
*
* @extends LifecycleEventArgs<EntityManagerInterface>
*/
class PreUpdateEventArgs extends LifecycleEventArgs
{
Expand Down
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<referencedClass name="Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand" />
<!-- Remove on 3.0.x -->
<referencedClass name="Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets"/>
<referencedClass name="Doctrine\ORM\Event\LifecycleEventArgs"/>
</errorLevel>
</DeprecatedClass>
<DeprecatedMethod>
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2996Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DDC2996UserPreference
#[PreFlush]
public function preFlush($event): void
{
$em = $event->getEntityManager();
$em = $event->getObjectManager();
$uow = $em->getUnitOfWork();

if ($uow->getOriginalEntityData($this->user)) {
Expand Down

0 comments on commit 84e78b8

Please sign in to comment.