Skip to content

Commit 6906bc3

Browse files
authored
Format code (#5172)
1 parent 6e46764 commit 6906bc3

7 files changed

+28
-23
lines changed

src/Concerns/PostgreSqlSwooleExtManagesTransactions.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait PostgreSqlSwooleExtManagesTransactions
2020
/**
2121
* Execute a Closure within a transaction.
2222
*
23-
* @throws \Exception|\Throwable
23+
* @throws Exception|Throwable
2424
*/
2525
public function transaction(Closure $callback, int $attempts = 1)
2626
{
@@ -55,7 +55,7 @@ public function transaction(Closure $callback, int $attempts = 1)
5555

5656
/**
5757
* Start a new database transaction.
58-
* @throws \Exception
58+
* @throws Exception
5959
*/
6060
public function beginTransaction(): void
6161
{
@@ -85,7 +85,7 @@ public function commit(): void
8585
*
8686
* @param null|int $toLevel
8787
*
88-
* @throws \Exception
88+
* @throws Exception
8989
*/
9090
public function rollBack($toLevel = null): void
9191
{
@@ -125,11 +125,11 @@ public function transactionLevel(): int
125125
/**
126126
* Handle an exception encountered when running a transacted statement.
127127
*
128-
* @param \Exception $e
128+
* @param Exception $e
129129
* @param int $currentAttempt
130130
* @param int $maxAttempts
131131
*
132-
* @throws \Exception
132+
* @throws Exception
133133
*/
134134
protected function handleTransactionException($e, $currentAttempt, $maxAttempts)
135135
{
@@ -187,9 +187,9 @@ protected function createSavepoint()
187187
/**
188188
* Handle an exception from a transaction beginning.
189189
*
190-
* @param \Throwable $e
190+
* @param Throwable $e
191191
*
192-
* @throws \Exception
192+
* @throws Exception
193193
*/
194194
protected function handleBeginTransactionException($e)
195195
{
@@ -221,9 +221,9 @@ protected function performRollBack($toLevel)
221221
/**
222222
* Handle an exception from a rollback.
223223
*
224-
* @param \Exception $e
224+
* @param Exception $e
225225
*
226-
* @throws \Exception
226+
* @throws Exception
227227
*/
228228
protected function handleRollBackException($e)
229229
{

src/Connectors/PostgresConnector.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class PostgresConnector extends Connector implements ConnectorInterface
3232
/**
3333
* Establish a database connection.
3434
*
35-
* @return \PDO
35+
* @return PDO
3636
*/
3737
public function connect(array $config)
3838
{
@@ -67,7 +67,7 @@ public function connect(array $config)
6767
/**
6868
* Set the connection character set and collation.
6969
*
70-
* @param \PDO $connection
70+
* @param PDO $connection
7171
* @param array $config
7272
*/
7373
protected function configureEncoding($connection, $config)
@@ -82,7 +82,7 @@ protected function configureEncoding($connection, $config)
8282
/**
8383
* Set the timezone on the connection.
8484
*
85-
* @param \PDO $connection
85+
* @param PDO $connection
8686
*/
8787
protected function configureTimezone($connection, array $config)
8888
{
@@ -96,7 +96,7 @@ protected function configureTimezone($connection, array $config)
9696
/**
9797
* Set the schema on the connection.
9898
*
99-
* @param \PDO $connection
99+
* @param PDO $connection
100100
* @param array $config
101101
*/
102102
protected function configureSchema($connection, $config)
@@ -126,7 +126,7 @@ protected function formatSchema($schema)
126126
/**
127127
* Set the schema on the connection.
128128
*
129-
* @param \PDO $connection
129+
* @param PDO $connection
130130
* @param array $config
131131
*/
132132
protected function configureApplicationName($connection, $config)
@@ -184,7 +184,7 @@ protected function addSslOptions($dsn, array $config)
184184
/**
185185
* Configure the synchronous_commit setting.
186186
*
187-
* @param \PDO $connection
187+
* @param PDO $connection
188188
*/
189189
protected function configureSynchronousCommit($connection, array $config)
190190
{

src/Connectors/PostgresSqlSwooleExtConnector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
namespace Hyperf\Database\PgSQL\Connectors;
1313

14+
use Exception;
1415
use Hyperf\Database\Connectors\ConnectorInterface;
1516
use Swoole\Coroutine\PostgreSQL;
1617

@@ -56,7 +57,7 @@ public function createConnection(array $config): PostgreSQL
5657
));
5758

5859
if ($result === false) {
59-
throw new \Exception($connection->error);
60+
throw new Exception($connection->error);
6061
}
6162

6263
return $connection;

src/PostgreSqlConnection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Hyperf\Database\PgSQL\Query\Processors\PostgresProcessor;
1818
use Hyperf\Database\PgSQL\Schema\Grammars\PostgresGrammar as SchemaGrammar;
1919
use Hyperf\Database\PgSQL\Schema\PostgresBuilder;
20+
use PDOStatement;
2021

2122
class PostgreSqlConnection extends Connection
2223
{
@@ -35,7 +36,7 @@ public function getSchemaBuilder(): PostgresBuilder
3536
/**
3637
* Bind values to their parameters in the given statement.
3738
*/
38-
public function bindValues(\PDOStatement $statement, array $bindings): void
39+
public function bindValues(PDOStatement $statement, array $bindings): void
3940
{
4041
foreach ($bindings as $key => $value) {
4142
$statement->bindValue(

src/PostgreSqlSwooleExtConnection.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
namespace Hyperf\Database\PgSQL;
1313

14+
use Exception;
15+
use Generator;
1416
use Hyperf\Database\Connection;
1517
use Hyperf\Database\Exception\QueryException;
1618
use Hyperf\Database\PgSQL\Concerns\PostgreSqlSwooleExtManagesTransactions;
@@ -107,7 +109,7 @@ public function select(string $query, array $bindings = [], bool $useReadPdo = t
107109
$result = $statement->execute($this->prepareBindings($bindings));
108110

109111
if ($result === false || ! empty($this->pdo->error)) {
110-
throw new QueryException($query, [], new \Exception($this->pdo->error));
112+
throw new QueryException($query, [], new Exception($this->pdo->error));
111113
}
112114

113115
return $statement->fetchAll($this->fetchMode) ?: [];
@@ -117,7 +119,7 @@ public function select(string $query, array $bindings = [], bool $useReadPdo = t
117119
/**
118120
* Run a select statement against the database and returns a generator.
119121
*/
120-
public function cursor(string $query, array $bindings = [], bool $useReadPdo = true): \Generator
122+
public function cursor(string $query, array $bindings = [], bool $useReadPdo = true): Generator
121123
{
122124
$statement = $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) {
123125
if ($this->pretending()) {
@@ -151,7 +153,7 @@ public function queryAll(string $query, array $bindings = []): array
151153

152154
$result = $statement->execute($bindings);
153155
if (! $result) {
154-
throw new QueryException($query, [], new \Exception($this->pdo->error));
156+
throw new QueryException($query, [], new Exception($this->pdo->error));
155157
}
156158

157159
return $statement->fetchAll(SW_PGSQL_ASSOC);
@@ -212,7 +214,7 @@ protected function prepare(string $query): PostgreSQLStatement
212214

213215
$statement = $this->pdo->prepare($query);
214216
if (! $statement) {
215-
throw new QueryException($query, [], new \Exception($this->pdo->error));
217+
throw new QueryException($query, [], new Exception($this->pdo->error));
216218
}
217219

218220
return $statement;

src/Schema/Grammars/PostgresGrammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function compileIndex(Blueprint $blueprint, Fluent $command)
180180
* Compile a fulltext index key command.
181181
*
182182
* @return string
183-
* @throws \RuntimeException
183+
* @throws RuntimeException
184184
*/
185185
public function compileFulltext(Blueprint $blueprint, Fluent $command)
186186
{

tests/Cases/PostgreSqlSwooleExtConnectionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Hyperf\Database\PgSQL\Connectors\PostgresSqlSwooleExtConnector;
1818
use Hyperf\Database\PgSQL\PostgreSqlSwooleExtConnection;
1919
use Hyperf\Database\Query\Builder;
20+
use Mockery;
2021
use PHPUnit\Framework\TestCase;
2122
use Psr\Container\ContainerInterface;
2223

@@ -30,7 +31,7 @@ class PostgreSqlSwooleExtConnectionTest extends TestCase
3031

3132
public function setUp(): void
3233
{
33-
$container = \Mockery::mock(ContainerInterface::class);
34+
$container = Mockery::mock(ContainerInterface::class);
3435
$container->shouldReceive('has')->andReturn(true);
3536
$container->shouldReceive('get')->with('db.connector.pgsql-swoole')->andReturn(new PostgresSqlSwooleExtConnector());
3637

0 commit comments

Comments
 (0)