mirror of
https://github.com/danog/sql.git
synced 2024-11-29 20:19:14 +01:00
Add Psalm and fix doc types
This commit is contained in:
parent
58f2931186
commit
83e21f8699
@ -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",
|
||||
|
15
psalm.xml
Normal file
15
psalm.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="2"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src"/>
|
||||
<ignoreFiles>
|
||||
<directory name="vendor"/>
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
</psalm>
|
@ -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];
|
||||
|
@ -9,7 +9,7 @@ interface Executor extends TransientResource
|
||||
/**
|
||||
* @param string $sql SQL query to execute.
|
||||
*
|
||||
* @return Promise<CommandResult|ResultSet>
|
||||
* @return Promise<Result>
|
||||
*
|
||||
* @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<CommandResult|ResultSet>
|
||||
* @return Promise<Result>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -9,7 +9,7 @@ interface Statement extends TransientResource
|
||||
/**
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return Promise<CommandResult|ResultSet>
|
||||
* @return Promise<Result>
|
||||
*/
|
||||
public function execute(array $params = []): Promise;
|
||||
|
||||
|
@ -24,7 +24,7 @@ interface Transaction extends Executor
|
||||
/**
|
||||
* Commits the transaction and makes it inactive.
|
||||
*
|
||||
* @return Promise<CommandResult>
|
||||
* @return Promise<Result>
|
||||
*
|
||||
* @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<CommandResult>
|
||||
* @return Promise<Result>
|
||||
*
|
||||
* @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<CommandResult>
|
||||
* @return Promise<Result>
|
||||
*
|
||||
* @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<CommandResult>
|
||||
* @return Promise<Result>
|
||||
*
|
||||
* @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<CommandResult>
|
||||
* @return Promise<Result>
|
||||
*
|
||||
* @throws TransactionError If the transaction has been committed or rolled back.
|
||||
*/
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user