From 95655988ea1fb0c260ca792751e2e9da81afc3a7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 27 Nov 2020 10:40:37 -0600 Subject: [PATCH] formatting --- .../Database/Concerns/ManagesTransactions.php | 40 +++++++------------ src/Illuminate/Database/Connection.php | 2 +- .../Database/DatabaseServiceProvider.php | 2 +- .../Database/DatabaseTransactionsManager.php | 8 ++-- 4 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/Illuminate/Database/Concerns/ManagesTransactions.php b/src/Illuminate/Database/Concerns/ManagesTransactions.php index 0d7b9a2e944d..498aac0309b9 100644 --- a/src/Illuminate/Database/Concerns/ManagesTransactions.php +++ b/src/Illuminate/Database/Concerns/ManagesTransactions.php @@ -44,9 +44,7 @@ public function transaction(Closure $callback, $attempts = 1) if ($this->transactions == 1) { $this->getPdo()->commit(); - if ($this->transactionsManager) { - $this->transactionsManager->commit($this->getName()); - } + optional($this->transactionsManager)->commit($this->getName()); } $this->transactions = max(0, $this->transactions - 1); @@ -83,11 +81,9 @@ protected function handleTransactionException(Throwable $e, $currentAttempt, $ma $this->transactions > 1) { $this->transactions--; - if ($this->transactionsManager) { - $this->transactionsManager->rollback( - $this->getName(), $this->transactions - ); - } + optional($this->transactionsManager)->rollback( + $this->getName(), $this->transactions + ); throw $e; } @@ -118,11 +114,9 @@ public function beginTransaction() $this->transactions++; - if ($this->transactionsManager) { - $this->transactionsManager->begin( - $this->getName(), $this->transactions - ); - } + optional($this->transactionsManager)->begin( + $this->getName(), $this->transactions + ); $this->fireConnectionEvent('beganTransaction'); } @@ -194,9 +188,7 @@ public function commit() if ($this->transactions == 1) { $this->getPdo()->commit(); - if ($this->transactionsManager) { - $this->transactionsManager->commit($this->getName()); - } + optional($this->transactionsManager)->commit($this->getName()); } $this->transactions = max(0, $this->transactions - 1); @@ -262,11 +254,9 @@ public function rollBack($toLevel = null) $this->transactions = $toLevel; - if ($this->transactionsManager) { - $this->transactionsManager->rollback( - $this->getName(), $this->transactions - ); - } + optional($this->transactionsManager)->rollback( + $this->getName(), $this->transactions + ); $this->fireConnectionEvent('rollingBack'); } @@ -303,11 +293,9 @@ protected function handleRollBackException(Throwable $e) if ($this->causedByLostConnection($e)) { $this->transactions = 0; - if ($this->transactionsManager) { - $this->transactionsManager->rollback( - $this->getName(), $this->transactions - ); - } + optional($this->transactionsManager)->rollback( + $this->getName(), $this->transactions + ); } throw $e; diff --git a/src/Illuminate/Database/Connection.php b/src/Illuminate/Database/Connection.php index ea8c41e908e8..b4fa6d4c3a0d 100755 --- a/src/Illuminate/Database/Connection.php +++ b/src/Illuminate/Database/Connection.php @@ -1172,7 +1172,7 @@ public function setTransactionManager($manager) } /** - * Unset the event transaction manager for this connection. + * Unset the transaction manager for this connection. * * @return void */ diff --git a/src/Illuminate/Database/DatabaseServiceProvider.php b/src/Illuminate/Database/DatabaseServiceProvider.php index d8f87227ae07..49ea50f19556 100755 --- a/src/Illuminate/Database/DatabaseServiceProvider.php +++ b/src/Illuminate/Database/DatabaseServiceProvider.php @@ -73,7 +73,7 @@ protected function registerConnectionServices() }); $this->app->singleton('db.transactions', function ($app) { - return new DatabaseTransactionsManager(); + return new DatabaseTransactionsManager; }); } diff --git a/src/Illuminate/Database/DatabaseTransactionsManager.php b/src/Illuminate/Database/DatabaseTransactionsManager.php index 95462a331c8f..156514de6020 100755 --- a/src/Illuminate/Database/DatabaseTransactionsManager.php +++ b/src/Illuminate/Database/DatabaseTransactionsManager.php @@ -5,7 +5,7 @@ class DatabaseTransactionsManager { /** - * All the recorded transactions. + * All of the recorded transactions. * * @var \Illuminate\Support\Collection */ @@ -46,7 +46,7 @@ public function rollback($connection, $level) { $this->transactions = $this->transactions->reject(function ($transaction) use ($connection, $level) { return $transaction->connection == $connection && - $transaction->level > $level; + $transaction->level > $level; })->values(); } @@ -72,8 +72,8 @@ public function commit($connection) /** * Register a transaction callback. * - * @param callable $callback - * @return void. + * @param callable $callback + * @return void */ public function addCallback($callback) {