55/**
66 * @template TResult of Result
77 * @template TStatement of Statement
8- * @extends Executor<TResult, TStatement>
8+ * @template TTransaction of Transaction
9+ * @extends Executor<TResult, TStatement, TTransaction>
910 */
1011interface Transaction extends Executor
1112{
@@ -16,6 +17,11 @@ public function getIsolationLevel(): TransactionIsolation;
1617 */
1718 public function isActive (): bool ;
1819
20+ /**
21+ * @return bool True if this transaction was created inside another transaction using a savepoint.
22+ */
23+ public function isNestedTransaction (): bool ;
24+
1925 /**
2026 * Commits the transaction and makes it inactive.
2127 *
@@ -31,29 +37,19 @@ public function commit(): void;
3137 public function rollback (): void ;
3238
3339 /**
34- * Creates a savepoint with the given identifier.
35- *
36- * @param non-empty-string $identifier Savepoint identifier.
40+ * Attaches a callback which is invoked when the entire transaction is committed. If this transaction
41+ * is a nested transaction, the callback will not be invoked until the top-level transaction is committed.
3742 *
38- * @throws TransactionError If the transaction has been committed or rolled back.
43+ * @param \Closure():void $onCommit
3944 */
40- public function createSavepoint ( string $ identifier ): void ;
45+ public function onCommit ( \ Closure $ onCommit ): void ;
4146
4247 /**
43- * Rolls back to the savepoint with the given identifier.
44- *
45- * @param non-empty-string $identifier Savepoint identifier .
48+ * Attaches a callback which is invoked when the transaction is rolled back. If in a nested transaction, the
49+ * callbacks may be invoked when rolling back to a savepoint or if the entire transaction is rolled back,
50+ * regardless of if the savepoint was released prior .
4651 *
47- * @throws TransactionError If the transaction has been committed or rolled back.
48- */
49- public function rollbackTo (string $ identifier ): void ;
50-
51- /**
52- * Releases the savepoint with the given identifier.
53- *
54- * @param non-empty-string $identifier Savepoint identifier.
55- *
56- * @throws TransactionError If the transaction has been committed or rolled back.
52+ * @param \Closure():void $onRollback
5753 */
58- public function releaseSavepoint ( string $ identifier ): void ;
54+ public function onRollback ( \ Closure $ onRollback ): void ;
5955}
0 commit comments