mirror of
https://github.com/danog/sql.git
synced 2024-11-26 12:04:44 +01:00
Add CS fixer and apply rules
This commit is contained in:
parent
d032734e94
commit
0466a73152
10
.php-cs-fixer.dist.php
Normal file
10
.php-cs-fixer.dist.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
$config = new Amp\CodeStyle\Config;
|
||||
$config->getFinder()
|
||||
->in(__DIR__ . '/src')
|
||||
->in(__DIR__ . '/test');
|
||||
|
||||
$config->setCacheFile(__DIR__ . '/.php_cs.cache');
|
||||
|
||||
return $config;
|
@ -15,7 +15,7 @@
|
||||
"amphp/amp": "^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"amphp/php-cs-fixer-config": "dev-master",
|
||||
"amphp/php-cs-fixer-config": "^2-dev",
|
||||
"amphp/phpunit-util": "^3",
|
||||
"phpunit/phpunit": "^9",
|
||||
"psalm/phar": "^4.10"
|
||||
|
@ -25,7 +25,7 @@ abstract class ConnectionConfig
|
||||
/**
|
||||
* Parses a connection string into an array of keys and values given.
|
||||
*
|
||||
* @param string $connectionString
|
||||
* @param string $connectionString Connection string, e.g., "hostname=localhost username=sql password=default"
|
||||
* @param string[] $keymap Map of alternative key names to canonical key names.
|
||||
*
|
||||
* @return string[]
|
||||
@ -97,9 +97,6 @@ abstract class ConnectionConfig
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
final public function getUser(): ?string
|
||||
{
|
||||
return $this->user;
|
||||
@ -112,9 +109,6 @@ abstract class ConnectionConfig
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
final public function getPassword(): ?string
|
||||
{
|
||||
return $this->password;
|
||||
@ -127,9 +121,6 @@ abstract class ConnectionConfig
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
final public function getDatabase(): ?string
|
||||
{
|
||||
return $this->database;
|
||||
|
@ -5,7 +5,8 @@ namespace Amp\Sql;
|
||||
interface Connector
|
||||
{
|
||||
/**
|
||||
* @param ConnectionConfig $config
|
||||
* Returns a new database connection based on the given configuration.
|
||||
* Implementations may provide further parameters, such as a Cancellation.
|
||||
*/
|
||||
public function connect(ConnectionConfig $config): Link;
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ interface Executor extends TransientResource
|
||||
/**
|
||||
* @param string $sql SQL query to execute.
|
||||
*
|
||||
* @return Result
|
||||
*
|
||||
* @throws FailureException If the operation fails due to unexpected condition.
|
||||
* @throws ConnectionException If the connection to the database is lost.
|
||||
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
|
||||
@ -18,8 +16,6 @@ interface Executor extends TransientResource
|
||||
/**
|
||||
* @param string $sql SQL query to prepare.
|
||||
*
|
||||
* @return Statement
|
||||
*
|
||||
* @throws FailureException If the operation fails due to unexpected condition.
|
||||
* @throws ConnectionException If the connection to the database is lost.
|
||||
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
|
||||
@ -30,8 +26,6 @@ interface Executor extends TransientResource
|
||||
* @param string $sql SQL query to prepare and execute.
|
||||
* @param mixed[] $params Query parameters.
|
||||
*
|
||||
* @return Result
|
||||
*
|
||||
* @throws FailureException If the operation fails due to unexpected condition.
|
||||
* @throws ConnectionException If the connection to the database is lost.
|
||||
* @throws QueryError If the operation fails due to an error in the query (such as a syntax error).
|
||||
|
@ -8,8 +8,6 @@ interface Link extends Executor
|
||||
* Starts a transaction on a single connection.
|
||||
*
|
||||
* @param TransactionIsolation $isolation Transaction isolation level.
|
||||
*
|
||||
* @return Transaction
|
||||
*/
|
||||
public function beginTransaction(TransactionIsolation $isolation = TransactionIsolation::Committed): Transaction;
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ namespace Amp\Sql;
|
||||
interface Pool extends Link
|
||||
{
|
||||
/**
|
||||
* @return Link
|
||||
* Gets a single connection from the pool to run a set of queries against a single connection.
|
||||
* Generally a transaction should be used instead of this method.
|
||||
*/
|
||||
public function extractConnection(): Link;
|
||||
|
||||
|
@ -7,24 +7,18 @@ interface Result extends \Traversable
|
||||
/**
|
||||
* Resolves with a new instance of Result if another result is available after this result. Resolves with null if
|
||||
* no further results are available.
|
||||
*
|
||||
* @return Result|null
|
||||
*/
|
||||
public function getNextResult(): ?Result;
|
||||
|
||||
/**
|
||||
* Returns the number of rows affected or returned by the query if applicable or null if the number of rows is
|
||||
* unknown or not applicable to the query.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getRowCount(): ?int;
|
||||
|
||||
/**
|
||||
* Returns the number of columns returned by the query if applicable or null if the number of columns is
|
||||
* unknown or not applicable to the query.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getColumnCount(): ?int;
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ interface Statement extends TransientResource
|
||||
{
|
||||
/**
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return Result
|
||||
*/
|
||||
public function execute(array $params = []): Result;
|
||||
|
||||
|
@ -6,8 +6,6 @@ interface TransientResource
|
||||
{
|
||||
/**
|
||||
* Indicates if the resource is still valid.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAlive(): bool;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user