From 0466a7315209a80261fe756b1ff00a849333c52b Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sat, 26 Feb 2022 09:07:16 -0600 Subject: [PATCH] Add CS fixer and apply rules --- .php-cs-fixer.dist.php | 10 ++++++++++ composer.json | 2 +- src/ConnectionConfig.php | 11 +---------- src/Connector.php | 3 ++- src/Executor.php | 6 ------ src/Link.php | 2 -- src/Pool.php | 3 ++- src/Result.php | 6 ------ src/Statement.php | 2 -- src/TransientResource.php | 2 -- 10 files changed, 16 insertions(+), 31 deletions(-) create mode 100644 .php-cs-fixer.dist.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..d146dba --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,10 @@ +getFinder() + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/test'); + +$config->setCacheFile(__DIR__ . '/.php_cs.cache'); + +return $config; diff --git a/composer.json b/composer.json index 1b7ecfa..cb2f27e 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/src/ConnectionConfig.php b/src/ConnectionConfig.php index b56fa02..af82c5a 100644 --- a/src/ConnectionConfig.php +++ b/src/ConnectionConfig.php @@ -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; diff --git a/src/Connector.php b/src/Connector.php index 36a9b18..d8e4af0 100644 --- a/src/Connector.php +++ b/src/Connector.php @@ -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; } diff --git a/src/Executor.php b/src/Executor.php index 4d3746b..46cec35 100644 --- a/src/Executor.php +++ b/src/Executor.php @@ -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). diff --git a/src/Link.php b/src/Link.php index 010ac7c..70d61d4 100644 --- a/src/Link.php +++ b/src/Link.php @@ -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; } diff --git a/src/Pool.php b/src/Pool.php index 8a31ab0..ddbbe12 100644 --- a/src/Pool.php +++ b/src/Pool.php @@ -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; diff --git a/src/Result.php b/src/Result.php index 5e323a1..8298131 100644 --- a/src/Result.php +++ b/src/Result.php @@ -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; } diff --git a/src/Statement.php b/src/Statement.php index 6559989..65c3592 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -6,8 +6,6 @@ interface Statement extends TransientResource { /** * @param mixed[] $params - * - * @return Result */ public function execute(array $params = []): Result; diff --git a/src/TransientResource.php b/src/TransientResource.php index 3eb5fa4..8b12ed1 100644 --- a/src/TransientResource.php +++ b/src/TransientResource.php @@ -6,8 +6,6 @@ interface TransientResource { /** * Indicates if the resource is still valid. - * - * @return bool */ public function isAlive(): bool;