Skip to content

Commit 963d8f5

Browse files
refactors on Transaction namespace
1 parent 130d036 commit 963d8f5

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

src/Transaction/Contracts/Transaction.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ abstract class Transaction
2323
*
2424
* @var Connection
2525
*/
26-
protected $connection;
26+
protected Connection $connection;
2727

2828
/**
2929
* StreamTransaction options
3030
*
3131
* @var array
3232
*/
33-
protected $options;
33+
protected array $options;
3434

3535
/**
3636
* Some default options for transaction
@@ -40,7 +40,7 @@ abstract class Transaction
4040
*
4141
* @var array
4242
*/
43-
protected $defaultOptions = [
43+
protected array $defaultOptions = [
4444
'maxTransactionSize' => 32000000,
4545
'waitForSync' => true,
4646
'allowImplicit' => false,
@@ -54,7 +54,7 @@ abstract class Transaction
5454
* @param Connection $connection Connection object to use.
5555
* @param array $options Transaction options.
5656
*
57-
* @throws TransactionException|InvalidParameterException|MissingParameterException
57+
* @throws InvalidParameterException|MissingParameterException
5858
*/
5959
public function __construct(Connection $connection, array $options = [])
6060
{

src/Transaction/JavascriptTransaction.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class JavascriptTransaction extends Transaction
2626
*
2727
* @var string
2828
*/
29-
protected $action;
29+
protected string $action;
3030

3131
/**
3232
* JavascriptTransaction constructor.
@@ -35,7 +35,7 @@ final class JavascriptTransaction extends Transaction
3535
* @param string $action JavaScript code to execute on server
3636
* @param array $options Transaction options.
3737
*
38-
* @throws TransactionException|InvalidParameterException|MissingParameterException
38+
* @throws InvalidParameterException|MissingParameterException
3939
*/
4040
public function __construct(Connection $connection, string $action, array $options = [])
4141
{
@@ -50,7 +50,7 @@ public function __construct(Connection $connection, string $action, array $optio
5050
* @return mixed The result value of transaction
5151
* @throws TransactionException|GuzzleException
5252
*/
53-
public function execute()
53+
public function execute(): mixed
5454
{
5555
try {
5656
$options = array_merge($this->options, ['action' => $this->action]);

src/Transaction/StreamTransaction.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@ final class StreamTransaction extends Transaction
2525
*
2626
* @var string
2727
*/
28-
protected $id;
28+
protected string $id;
2929

3030
/**
3131
* Transaction status
3232
*
3333
* @var string
3434
*/
35-
protected $status = '';
35+
protected string $status = '';
3636

3737
/**
3838
* If the transaction object is already started
3939
*
4040
* @var bool
4141
*/
42-
protected $started = false;
42+
protected bool $started = false;
4343

4444
/**
4545
* StreamTransaction constructor.
4646
*
4747
* @param Connection $connection Connection object to use.
4848
* @param array $options Transaction options.
4949
*
50-
* @throws TransactionException|InvalidParameterException|MissingParameterException
50+
* @throws InvalidParameterException|MissingParameterException
5151
*/
5252
public function __construct(Connection $connection, array $options = [])
5353
{
@@ -79,7 +79,7 @@ public function getTransactionStatus(): string
7979
*
8080
* @throws TransactionException|BadResponseException|GuzzleException
8181
*/
82-
public function begin()
82+
public function begin(): void
8383
{
8484
try {
8585
$response = $this->connection->post(sprintf(Api::TRANSACTION_BEGIN), $this->options);
@@ -91,8 +91,7 @@ public function begin()
9191
} catch (BadResponseException $exception) {
9292
// An error was returned from server.
9393
$response = json_decode((string)$exception->getResponse()->getBody(), true);
94-
$transactionException = new TransactionException($response['errorMessage'], $exception, $response['errorNum']);
95-
throw $transactionException;
94+
throw new TransactionException($response['errorMessage'], $exception, $response['errorNum']);
9695
}
9796
}
9897

@@ -101,7 +100,7 @@ public function begin()
101100
*
102101
* @throws TransactionException|BadResponseException|GuzzleException
103102
*/
104-
public function commit()
103+
public function commit(): void
105104
{
106105
try {
107106
if ($this->started) {
@@ -127,7 +126,7 @@ public function commit()
127126
*
128127
* @throws TransactionException|BadResponseException|GuzzleException
129128
*/
130-
public function abort()
129+
public function abort(): void
131130
{
132131
try {
133132
if ($this->started) {

src/View/View.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class View
7676
* @param string $type The type of View
7777
* @param array $attributes View attributes
7878
*
79-
* @see https://www.arangodb.com/docs/stable/arangosearch-views.html#view-properties
79+
* @see https://docs.arangodb.com/3.12/index-and-search/arangosearch/arangosearch-views-reference/#view-properties
8080
*/
8181
public function __construct(string $name, string $type = "arangosearch", array $attributes = [])
8282
{
@@ -85,8 +85,8 @@ public function __construct(string $name, string $type = "arangosearch", array $
8585
$this->attributes = array_merge($this->defaults, $attributes);
8686

8787
$this->isNew = true;
88-
$this->id = isset($this->attributes['id']) ? $this->attributes['id'] : '';
89-
$this->globallyUniqueId = isset($this->attributes['globallyUniqueId']) ? $this->attributes['globallyUniqueId'] : '';
88+
$this->id = $this->attributes['id'] ?? '';
89+
$this->globallyUniqueId = $this->attributes['globallyUniqueId'] ?? '';
9090

9191
if ($this->id && $this->globallyUniqueId) {
9292
$this->isNew = false;

0 commit comments

Comments
 (0)