diff --git a/UPGRADE.md b/UPGRADE.md
index 109618c18bf..09992996a37 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -1,5 +1,9 @@
# Upgrade to 3.0
+## BC BREAK: Remove `Doctrine\ORM\EntityManagerInterface#transactional()`
+
+This method has been replaced by `Doctrine\ORM\EntityManagerInterface#wrapInTransaction()`.
+
## BC BREAK: Removed support for schema emulation.
The ORM no longer attempts to emulate schemas on SQLite.
diff --git a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php
index c537e486775..0e8301e6b87 100644
--- a/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php
+++ b/lib/Doctrine/ORM/Decorator/EntityManagerDecorator.php
@@ -8,13 +8,6 @@
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Persistence\ObjectManagerDecorator;
-use function get_class;
-use function method_exists;
-use function sprintf;
-use function trigger_error;
-
-use const E_USER_NOTICE;
-
/**
* Base class for EntityManager decorators
*/
@@ -52,28 +45,11 @@ public function beginTransaction()
$this->wrapped->beginTransaction();
}
- /**
- * {@inheritdoc}
- */
- public function transactional($func)
- {
- return $this->wrapped->transactional($func);
- }
-
/**
* {@inheritdoc}
*/
public function wrapInTransaction(callable $func)
{
- if (! method_exists($this->wrapped, 'wrapInTransaction')) {
- trigger_error(
- sprintf('Calling `transactional()` instead of `wrapInTransaction()` which is not implemented on %s', get_class($this->wrapped)),
- E_USER_NOTICE
- );
-
- return $this->wrapped->transactional($func);
- }
-
return $this->wrapped->wrapInTransaction($func);
}
diff --git a/lib/Doctrine/ORM/EntityManager.php b/lib/Doctrine/ORM/EntityManager.php
index bc39cfad8e2..0b5c6611c0a 100644
--- a/lib/Doctrine/ORM/EntityManager.php
+++ b/lib/Doctrine/ORM/EntityManager.php
@@ -4,7 +4,6 @@
namespace Doctrine\ORM;
-use BadMethodCallException;
use Doctrine\Common\Cache\Psr6\CacheAdapter;
use Doctrine\Common\EventManager;
use Doctrine\Common\Util\ClassUtils;
@@ -32,11 +31,9 @@
use Throwable;
use function array_keys;
-use function call_user_func;
use function get_class;
use function gettype;
use function is_array;
-use function is_callable;
use function is_object;
use function is_string;
use function ltrim;
@@ -221,32 +218,6 @@ public function getCache()
return $this->cache;
}
- /**
- * {@inheritDoc}
- */
- public function transactional($func)
- {
- if (! is_callable($func)) {
- throw new InvalidArgumentException('Expected argument of type "callable", got "' . gettype($func) . '"');
- }
-
- $this->conn->beginTransaction();
-
- try {
- $return = call_user_func($func, $this);
-
- $this->flush();
- $this->conn->commit();
-
- return $return ?: true;
- } catch (Throwable $e) {
- $this->close();
- $this->conn->rollBack();
-
- throw $e;
- }
- }
-
/**
* {@inheritDoc}
*/
diff --git a/lib/Doctrine/ORM/EntityManagerInterface.php b/lib/Doctrine/ORM/EntityManagerInterface.php
index bd4df4e801f..5ae287bbcd1 100644
--- a/lib/Doctrine/ORM/EntityManagerInterface.php
+++ b/lib/Doctrine/ORM/EntityManagerInterface.php
@@ -20,7 +20,6 @@
* EntityManager interface
*
* @method Mapping\ClassMetadataFactory getMetadataFactory()
- * @method mixed wrapInTransaction(callable $func)
*/
interface EntityManagerInterface extends ObjectManager
{
@@ -72,24 +71,6 @@ public function getExpressionBuilder();
*/
public function beginTransaction();
- /**
- * Executes a function in a transaction.
- *
- * The function gets passed this EntityManager instance as an (optional) parameter.
- *
- * {@link flush} is invoked prior to transaction commit.
- *
- * If an exception occurs during execution of the function or flushing or transaction commit,
- * the transaction is rolled back, the EntityManager closed and the exception re-thrown.
- *
- * @deprecated 2.10 Use {@link wrapInTransaction} instead.
- *
- * @param callable $func The function to execute transactionally.
- *
- * @return mixed The non-empty value returned from the closure or true instead.
- */
- public function transactional($func);
-
/**
* Executes a function in a transaction.
*
@@ -106,7 +87,7 @@ public function transactional($func);
*
* @template T
*/
- // public function wrapInTransaction(callable $func);
+ public function wrapInTransaction(callable $func);
/**
* Commits a transaction on the underlying database connection.
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 38a6f37772c..2e9dcd43f61 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -409,19 +409,14 @@
-
+
getHydrator
- transactional
- transactional
$entity
$lockMode
$lockVersion
-
- wrapInTransaction
-
$wrapped
@@ -479,9 +474,6 @@
$this->repositoryFactory->getRepository($this, $entityName)
new $class($this)
-
- wrapInTransaction
-
EntityRepository<T>
newHydrator
@@ -773,10 +765,9 @@
$parent
new $definition['class']()
-
+
addNamedNativeQuery
addNamedQuery
- getName
! $definition
@@ -875,9 +866,6 @@
$class
$subclass
-
- canEmulateSchemas
-
$this->columnNames
$this->columnNames
@@ -1040,10 +1028,6 @@
-
- canEmulateSchemas
- canEmulateSchemas
-
$joinColumn
@@ -3312,9 +3296,6 @@
-
- canEmulateSchemas
-
! $definingClass
$definingClass
diff --git a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php
index 021d6d3a403..8f101c416e4 100644
--- a/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php
+++ b/tests/Doctrine/Performance/Mock/NonProxyLoadingEntityManager.php
@@ -92,14 +92,6 @@ public function beginTransaction()
$this->realEntityManager->beginTransaction();
}
- /**
- * {@inheritDoc}
- */
- public function transactional($func)
- {
- return $this->realEntityManager->transactional($func);
- }
-
/**
* {@inheritDoc}
*/
diff --git a/tests/Doctrine/Tests/ORM/EntityManagerTest.php b/tests/Doctrine/Tests/ORM/EntityManagerTest.php
index 0162f7d7d70..710e40e8a00 100644
--- a/tests/Doctrine/Tests/ORM/EntityManagerTest.php
+++ b/tests/Doctrine/Tests/ORM/EntityManagerTest.php
@@ -240,38 +240,6 @@ static function (EntityManagerInterface $em) use ($expectedValue) {
$this->assertSame($expectedValue, $return);
}
- /**
- * @group DDC-1125
- */
- public function testTransactionalAcceptsReturn(): void
- {
- $return = $this->entityManager->transactional(static function ($em) {
- return 'foo';
- });
-
- self::assertEquals('foo', $return);
- }
-
- public function testTransactionalAcceptsVariousCallables(): void
- {
- self::assertSame('callback', $this->entityManager->transactional([$this, 'transactionalCallback']));
- }
-
- public function testTransactionalThrowsInvalidArgumentExceptionIfNonCallablePassed(): void
- {
- $this->expectException(InvalidArgumentException::class);
- $this->expectExceptionMessage('Expected argument of type "callable", got "object"');
-
- $this->entityManager->transactional($this);
- }
-
- public function transactionalCallback($em): string
- {
- self::assertSame($this->entityManager, $em);
-
- return 'callback';
- }
-
public function testCreateInvalidConnection(): void
{
$this->expectException(InvalidArgumentException::class);
@@ -282,24 +250,6 @@ public function testCreateInvalidConnection(): void
EntityManager::create(1, $config);
}
- /**
- * @group #5796
- */
- public function testTransactionalReThrowsThrowables(): void
- {
- try {
- $this->entityManager->transactional(static function (): void {
- (static function (array $value): void {
- // this only serves as an IIFE that throws a `TypeError`
- })(null);
- });
-
- self::fail('TypeError expected to be thrown');
- } catch (TypeError $ignored) {
- self::assertFalse($this->entityManager->isOpen());
- }
- }
-
/**
* @group #5796
*/
diff --git a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
index e3e647c59a0..17981735dfd 100644
--- a/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
+++ b/tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
@@ -5,6 +5,7 @@
namespace Doctrine\Tests\ORM\Functional;
use Doctrine\DBAL\Logging\DebugStack;
+use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityNotFoundException;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\ORMInvalidArgumentException;
@@ -22,7 +23,6 @@
use InvalidArgumentException;
use function get_class;
-use function in_array;
class BasicFunctionalTest extends OrmFunctionalTestCase
{
@@ -717,7 +717,7 @@ public function testQueryEntityByReference(): void
$user->setAddress($address);
- $this->_em->transactional(static function ($em) use ($user): void {
+ $this->_em->wrapInTransaction(static function (EntityManagerInterface $em) use ($user): void {
$em->persist($user);
});
$this->_em->clear();