diff --git a/composer.json b/composer.json index ac22899..3c0ea63 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,9 @@ }, "require-dev": { "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1", - "phpunit/phpunit": "^6" + "amphp/phpunit-util": "^1.1", + "phpunit/phpunit": "^9 | ^8 | ^7", + "vimeo/psalm": "^3.11@dev" }, "autoload": { "psr-4": { @@ -29,11 +30,6 @@ "Amp\\Sql\\Test\\": "test" } }, - "config": { - "platform": { - "php": "7.0.0" - } - }, "scripts": { "check": [ "@cs", diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..365ac90 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/src/ConnectionConfig.php b/src/ConnectionConfig.php index f65719e..34b49de 100644 --- a/src/ConnectionConfig.php +++ b/src/ConnectionConfig.php @@ -46,7 +46,8 @@ abstract class ConnectionConfig } foreach ($params as $param) { - list($key, $value) = \array_map("trim", \explode("=", $param, 2) + [1 => null]); + /** @psalm-suppress PossiblyInvalidArgument */ + [$key, $value] = \array_map("trim", \explode("=", $param, 2) + [1 => null]); if (isset($keymap[$key])) { $key = $keymap[$key]; diff --git a/src/Executor.php b/src/Executor.php index 8b8eaae..7230e7f 100644 --- a/src/Executor.php +++ b/src/Executor.php @@ -9,7 +9,7 @@ interface Executor extends TransientResource /** * @param string $sql SQL query to execute. * - * @return Promise + * @return Promise * * @throws FailureException If the operation fails due to unexpected condition. * @throws ConnectionException If the connection to the database is lost. @@ -32,7 +32,7 @@ interface Executor extends TransientResource * @param string $sql SQL query to prepare and execute. * @param mixed[] $params Query parameters. * - * @return Promise + * @return Promise * * @throws FailureException If the operation fails due to unexpected condition. * @throws ConnectionException If the connection to the database is lost. @@ -43,5 +43,5 @@ interface Executor extends TransientResource /** * Closes the executor. No further queries may be performed. */ - public function close(); + public function close(): void; } diff --git a/src/QueryError.php b/src/QueryError.php index 9026530..7d9fdc9 100644 --- a/src/QueryError.php +++ b/src/QueryError.php @@ -4,6 +4,7 @@ namespace Amp\Sql; class QueryError extends \Error { + /** @var string */ protected $query = ""; public function __construct(string $message, string $query = "", \Throwable $previous = null) diff --git a/src/Statement.php b/src/Statement.php index b29a795..a0a7ae0 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -9,7 +9,7 @@ interface Statement extends TransientResource /** * @param mixed[] $params * - * @return Promise + * @return Promise */ public function execute(array $params = []): Promise; diff --git a/src/Transaction.php b/src/Transaction.php index decd2d7..79e32cd 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -24,7 +24,7 @@ interface Transaction extends Executor /** * Commits the transaction and makes it inactive. * - * @return Promise + * @return Promise * * @throws TransactionError If the transaction has been committed or rolled back. */ @@ -33,7 +33,7 @@ interface Transaction extends Executor /** * Rolls back the transaction and makes it inactive. * - * @return Promise + * @return Promise * * @throws TransactionError If the transaction has been committed or rolled back. */ @@ -44,7 +44,7 @@ interface Transaction extends Executor * * @param string $identifier Savepoint identifier. * - * @return Promise + * @return Promise * * @throws TransactionError If the transaction has been committed or rolled back. */ @@ -55,7 +55,7 @@ interface Transaction extends Executor * * @param string $identifier Savepoint identifier. * - * @return Promise + * @return Promise * * @throws TransactionError If the transaction has been committed or rolled back. */ @@ -66,7 +66,7 @@ interface Transaction extends Executor * * @param string $identifier Savepoint identifier. * - * @return Promise + * @return Promise * * @throws TransactionError If the transaction has been committed or rolled back. */ diff --git a/test/QueryErrorTest.php b/test/QueryErrorTest.php index 26b40e2..1e19f2d 100644 --- a/test/QueryErrorTest.php +++ b/test/QueryErrorTest.php @@ -2,10 +2,10 @@ namespace Amp\Sql\Test; -use Amp\PHPUnit\TestCase; +use Amp\PHPUnit\AsyncTestCase; use Amp\Sql\QueryError; -class QueryErrorTest extends TestCase +class QueryErrorTest extends AsyncTestCase { /** * @test