Require 8.1 and make Transaction isolation an enum

This commit is contained in:
Aaron Piotrowski 2022-02-22 18:25:37 -06:00
parent 55bfd0f439
commit 3698c20375
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
6 changed files with 20 additions and 18 deletions

View File

@ -11,16 +11,16 @@
"homepage": "https://amphp.org",
"license": "MIT",
"require": {
"php": ">=8",
"amphp/amp": "^3-dev"
"php": ">=8.1",
"amphp/amp": "^3"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^2-dev",
"amphp/phpunit-util": "^3",
"phpunit/phpunit": "^9",
"psalm/phar": "^4.10"
},
"minimum-stability": "dev",
"minimum-stability": "beta",
"prefer-stable": true,
"autoload": {
"psr-4": {

View File

@ -4,7 +4,7 @@ namespace Amp\Sql;
abstract class ConnectionConfig
{
const KEY_MAP = [
public const KEY_MAP = [
'hostname' => 'host',
'username' => 'user',
'pass' => 'password',

View File

@ -7,9 +7,9 @@ interface Link extends Executor
/**
* Starts a transaction on a single connection.
*
* @param int $isolation Transaction isolation level.
* @param TransactionIsolation $isolation Transaction isolation level.
*
* @return Transaction
*/
public function beginTransaction(int $isolation = Transaction::ISOLATION_COMMITTED): Transaction;
public function beginTransaction(TransactionIsolation $isolation = TransactionIsolation::COMMITTED): Transaction;
}

View File

@ -4,8 +4,7 @@ namespace Amp\Sql;
class QueryError extends \Error
{
/** @var string */
protected string $query = "";
protected readonly string $query;
public function __construct(string $message, string $query = "", \Throwable $previous = null)
{

View File

@ -4,15 +4,7 @@ namespace Amp\Sql;
interface Transaction extends Executor
{
public const ISOLATION_UNCOMMITTED = 0;
public const ISOLATION_COMMITTED = 1;
public const ISOLATION_REPEATABLE = 2;
public const ISOLATION_SERIALIZABLE = 4;
/**
* @return int
*/
public function getIsolationLevel(): int;
public function getIsolationLevel(): TransactionIsolation;
/**
* @return bool True if the transaction is active, false if it has been committed or rolled back.

View File

@ -0,0 +1,11 @@
<?php
namespace Amp\Sql;
enum TransactionIsolation
{
case UNCOMMITTED;
case COMMITTED;
case REPEATABLE;
case SERIALIZABLE;
}