From 5f03f3b52d4401bbd868d04e23aa9f26767a5d20 Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Thu, 7 May 2020 21:02:04 +0200 Subject: [PATCH 1/4] introduce internal StrictObjectTrait --- src/Exceptions/MemberAccessException.php | 11 ++++ src/Utils/StrictObjectTrait.php | 75 ++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 src/Exceptions/MemberAccessException.php create mode 100644 src/Utils/StrictObjectTrait.php diff --git a/src/Exceptions/MemberAccessException.php b/src/Exceptions/MemberAccessException.php new file mode 100644 index 00000000..19ebcfb6 --- /dev/null +++ b/src/Exceptions/MemberAccessException.php @@ -0,0 +1,11 @@ + $args + * @throws MemberAccessException + */ + public function __call(string $name, array $args) + { + $class = get_class($this); + throw new MemberAccessException("Call to undefined method $class::$name()."); + } + + + /** + * @phpstan-return never + * @phpstan-param array $args + * @throws MemberAccessException + */ + public static function __callStatic(string $name, array $args) + { + $class = get_class(); + throw new MemberAccessException("Call to undefined static method $class::$name()."); + } + + + /** + * @phpstan-return never + * @throws MemberAccessException + */ + public function &__get(string $name) + { + $class = get_class(); + throw new MemberAccessException("Cannot read an undeclared property $class::\$$name."); + } + + + /** + * @param mixed $value + * @phpstan-return never + * @throws MemberAccessException + */ + public function __set(string $name, $value) + { + $class = get_class(); + throw new MemberAccessException("Cannot write to an undeclared property $class::\$$name."); + } + + + /** + * @phpstan-return never + * @throws MemberAccessException + */ + public function __unset(string $name) + { + $class = get_class(); + throw new MemberAccessException("Cannot unset an undeclared property $class::\$$name."); + } + + + public function __isset(string $name): bool + { + return false; + } +} From efa389abef4f98287600e80d1b155a2b201b9cbc Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Thu, 7 May 2020 21:06:28 +0200 Subject: [PATCH 2/4] make relevant classes strict --- src/Connection.php | 4 ++++ src/Drivers/Mysqli/MysqliDriver.php | 4 ++++ src/Drivers/Mysqli/MysqliEmptyResultAdapter.php | 4 ++++ src/Drivers/Mysqli/MysqliResultAdapter.php | 4 ++++ src/Drivers/Pgsql/PgsqlDriver.php | 4 ++++ src/Drivers/Pgsql/PgsqlResultAdapter.php | 4 ++++ src/Drivers/Sqlsrv/SqlsrvDriver.php | 4 ++++ src/Drivers/Sqlsrv/SqlsrvResultAdapter.php | 4 ++++ src/MultiLogger.php | 4 ++++ src/Platforms/Data/Column.php | 6 ++++++ src/Platforms/Data/ForeignKey.php | 6 ++++++ src/Platforms/Data/Table.php | 6 ++++++ src/Platforms/MySqlPlatform.php | 4 ++++ src/Platforms/PostgreSqlPlatform.php | 4 ++++ src/Platforms/SqlServerPlatform.php | 4 ++++ src/QueryBuilder/QueryBuilder.php | 4 ++++ src/Result/Result.php | 4 ++++ src/SqlProcessor.php | 4 ++++ src/Utils/FileImporter.php | 3 +++ src/Utils/LoggerHelper.php | 3 +++ src/Utils/SqlHighlighter.php | 3 +++ src/Utils/Typos.php | 3 +++ 22 files changed, 90 insertions(+) diff --git a/src/Connection.php b/src/Connection.php index f184e4ad..8349118a 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -13,6 +13,7 @@ use Nextras\Dbal\QueryBuilder\QueryBuilder; use Nextras\Dbal\Result\Result; use Nextras\Dbal\Utils\LoggerHelper; +use Nextras\Dbal\Utils\StrictObjectTrait; use function array_unshift; use function assert; use function call_user_func_array; @@ -23,6 +24,9 @@ class Connection implements IConnection { + use StrictObjectTrait; + + /** * @var array * @phpstan-var array diff --git a/src/Drivers/Mysqli/MysqliDriver.php b/src/Drivers/Mysqli/MysqliDriver.php index cac0cac1..37c77f1c 100644 --- a/src/Drivers/Mysqli/MysqliDriver.php +++ b/src/Drivers/Mysqli/MysqliDriver.php @@ -26,10 +26,14 @@ use Nextras\Dbal\Result\Result; use Nextras\Dbal\UniqueConstraintViolationException; use Nextras\Dbal\Utils\LoggerHelper; +use Nextras\Dbal\Utils\StrictObjectTrait; class MysqliDriver implements IDriver { + use StrictObjectTrait; + + /** @var mysqli|null */ private $connection; diff --git a/src/Drivers/Mysqli/MysqliEmptyResultAdapter.php b/src/Drivers/Mysqli/MysqliEmptyResultAdapter.php index 71fd3bb2..4da03be4 100644 --- a/src/Drivers/Mysqli/MysqliEmptyResultAdapter.php +++ b/src/Drivers/Mysqli/MysqliEmptyResultAdapter.php @@ -10,10 +10,14 @@ use Nextras\Dbal\Drivers\IResultAdapter; use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Utils\StrictObjectTrait; class MysqliEmptyResultAdapter implements IResultAdapter { + use StrictObjectTrait; + + public function seek(int $index): void { throw new InvalidStateException("Unable to seek in row set to {$index} index."); diff --git a/src/Drivers/Mysqli/MysqliResultAdapter.php b/src/Drivers/Mysqli/MysqliResultAdapter.php index fc0db5e0..ff62cb8f 100644 --- a/src/Drivers/Mysqli/MysqliResultAdapter.php +++ b/src/Drivers/Mysqli/MysqliResultAdapter.php @@ -11,10 +11,14 @@ use mysqli_result; use Nextras\Dbal\Drivers\IResultAdapter; use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Utils\StrictObjectTrait; class MysqliResultAdapter implements IResultAdapter { + use StrictObjectTrait; + + /** @var array */ protected static $types = [ MYSQLI_TYPE_TIME => self::TYPE_DRIVER_SPECIFIC, diff --git a/src/Drivers/Pgsql/PgsqlDriver.php b/src/Drivers/Pgsql/PgsqlDriver.php index 4910eb09..b3988531 100644 --- a/src/Drivers/Pgsql/PgsqlDriver.php +++ b/src/Drivers/Pgsql/PgsqlDriver.php @@ -25,11 +25,15 @@ use Nextras\Dbal\Result\Result; use Nextras\Dbal\UniqueConstraintViolationException; use Nextras\Dbal\Utils\LoggerHelper; +use Nextras\Dbal\Utils\StrictObjectTrait; use Tester\Assert; class PgsqlDriver implements IDriver { + use StrictObjectTrait; + + /** @var resource|null */ private $connection; diff --git a/src/Drivers/Pgsql/PgsqlResultAdapter.php b/src/Drivers/Pgsql/PgsqlResultAdapter.php index 11ffeafe..afb4d6cf 100644 --- a/src/Drivers/Pgsql/PgsqlResultAdapter.php +++ b/src/Drivers/Pgsql/PgsqlResultAdapter.php @@ -10,10 +10,14 @@ use Nextras\Dbal\Drivers\IResultAdapter; use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Utils\StrictObjectTrait; class PgsqlResultAdapter implements IResultAdapter { + use StrictObjectTrait; + + /** @var resource */ private $result; diff --git a/src/Drivers/Sqlsrv/SqlsrvDriver.php b/src/Drivers/Sqlsrv/SqlsrvDriver.php index 44176229..a6c5ee44 100644 --- a/src/Drivers/Sqlsrv/SqlsrvDriver.php +++ b/src/Drivers/Sqlsrv/SqlsrvDriver.php @@ -26,10 +26,14 @@ use Nextras\Dbal\UniqueConstraintViolationException; use Nextras\Dbal\Utils\DateTimeImmutable; use Nextras\Dbal\Utils\LoggerHelper; +use Nextras\Dbal\Utils\StrictObjectTrait; class SqlsrvDriver implements IDriver { + use StrictObjectTrait; + + /** @var resource|null */ private $connection; diff --git a/src/Drivers/Sqlsrv/SqlsrvResultAdapter.php b/src/Drivers/Sqlsrv/SqlsrvResultAdapter.php index 0dba72cc..a0a53fb4 100644 --- a/src/Drivers/Sqlsrv/SqlsrvResultAdapter.php +++ b/src/Drivers/Sqlsrv/SqlsrvResultAdapter.php @@ -10,10 +10,14 @@ use Nextras\Dbal\Drivers\IResultAdapter; use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Utils\StrictObjectTrait; class SqlsrvResultAdapter implements IResultAdapter { + use StrictObjectTrait; + + /** * @var array * @phpstan-var array diff --git a/src/MultiLogger.php b/src/MultiLogger.php index 926996b0..87aad519 100644 --- a/src/MultiLogger.php +++ b/src/MultiLogger.php @@ -3,10 +3,14 @@ namespace Nextras\Dbal; use Nextras\Dbal\Result\Result; +use Nextras\Dbal\Utils\StrictObjectTrait; class MultiLogger implements ILogger { + use StrictObjectTrait; + + /** * @var ILogger[] * @phpstan-var array diff --git a/src/Platforms/Data/Column.php b/src/Platforms/Data/Column.php index a8428653..2edf0998 100644 --- a/src/Platforms/Data/Column.php +++ b/src/Platforms/Data/Column.php @@ -9,8 +9,14 @@ namespace Nextras\Dbal\Platforms\Data; +use Nextras\Dbal\Utils\StrictObjectTrait; + + class Column { + use StrictObjectTrait; + + /** @var string */ public $name; diff --git a/src/Platforms/Data/ForeignKey.php b/src/Platforms/Data/ForeignKey.php index d7e5d342..8d0238af 100644 --- a/src/Platforms/Data/ForeignKey.php +++ b/src/Platforms/Data/ForeignKey.php @@ -9,8 +9,14 @@ namespace Nextras\Dbal\Platforms\Data; +use Nextras\Dbal\Utils\StrictObjectTrait; + + class ForeignKey { + use StrictObjectTrait; + + /** @var string */ public $name; diff --git a/src/Platforms/Data/Table.php b/src/Platforms/Data/Table.php index 35ac1d71..5881fe68 100644 --- a/src/Platforms/Data/Table.php +++ b/src/Platforms/Data/Table.php @@ -9,8 +9,14 @@ namespace Nextras\Dbal\Platforms\Data; +use Nextras\Dbal\Utils\StrictObjectTrait; + + class Table { + use StrictObjectTrait; + + /** @var string */ public $name; diff --git a/src/Platforms/MySqlPlatform.php b/src/Platforms/MySqlPlatform.php index 4c78f58f..a499a750 100644 --- a/src/Platforms/MySqlPlatform.php +++ b/src/Platforms/MySqlPlatform.php @@ -12,10 +12,14 @@ use Nextras\Dbal\Platforms\Data\Column; use Nextras\Dbal\Platforms\Data\ForeignKey; use Nextras\Dbal\Platforms\Data\Table; +use Nextras\Dbal\Utils\StrictObjectTrait; class MySqlPlatform implements IPlatform { + use StrictObjectTrait; + + public const NAME = 'mysql'; /** @var Connection */ diff --git a/src/Platforms/PostgreSqlPlatform.php b/src/Platforms/PostgreSqlPlatform.php index 9534a5eb..2e358640 100644 --- a/src/Platforms/PostgreSqlPlatform.php +++ b/src/Platforms/PostgreSqlPlatform.php @@ -12,10 +12,14 @@ use Nextras\Dbal\Platforms\Data\Column; use Nextras\Dbal\Platforms\Data\ForeignKey; use Nextras\Dbal\Platforms\Data\Table; +use Nextras\Dbal\Utils\StrictObjectTrait; class PostgreSqlPlatform implements IPlatform { + use StrictObjectTrait; + + public const NAME = 'pgsql'; /** @var Connection */ diff --git a/src/Platforms/SqlServerPlatform.php b/src/Platforms/SqlServerPlatform.php index c29e5e98..6dd24b6b 100644 --- a/src/Platforms/SqlServerPlatform.php +++ b/src/Platforms/SqlServerPlatform.php @@ -12,12 +12,16 @@ use Nextras\Dbal\Platforms\Data\Column; use Nextras\Dbal\Platforms\Data\ForeignKey; use Nextras\Dbal\Platforms\Data\Table; +use Nextras\Dbal\Utils\StrictObjectTrait; use function count; use function explode; class SqlServerPlatform implements IPlatform { + use StrictObjectTrait; + + public const NAME = 'mssql'; /** @var Connection */ diff --git a/src/QueryBuilder/QueryBuilder.php b/src/QueryBuilder/QueryBuilder.php index 1fb48665..1a81b438 100644 --- a/src/QueryBuilder/QueryBuilder.php +++ b/src/QueryBuilder/QueryBuilder.php @@ -11,10 +11,14 @@ use Nextras\Dbal\Drivers\IDriver; use Nextras\Dbal\InvalidArgumentException; use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Utils\StrictObjectTrait; class QueryBuilder { + use StrictObjectTrait; + + /** @const */ const TYPE_SELECT = 1; const TYPE_INSERT = 2; diff --git a/src/Result/Result.php b/src/Result/Result.php index fc7a2823..78bc488f 100644 --- a/src/Result/Result.php +++ b/src/Result/Result.php @@ -14,6 +14,7 @@ use Nextras\Dbal\Drivers\IResultAdapter; use Nextras\Dbal\InvalidArgumentException; use Nextras\Dbal\Utils\DateTimeImmutable; +use Nextras\Dbal\Utils\StrictObjectTrait; use SeekableIterator; use function assert; use function date_default_timezone_get; @@ -25,6 +26,9 @@ */ class Result implements SeekableIterator, Countable { + use StrictObjectTrait; + + /** @var IResultAdapter */ private $adapter; diff --git a/src/SqlProcessor.php b/src/SqlProcessor.php index e5cb57a5..04bf4e93 100644 --- a/src/SqlProcessor.php +++ b/src/SqlProcessor.php @@ -10,10 +10,14 @@ use Nextras\Dbal\Drivers\IDriver; use Nextras\Dbal\Platforms\IPlatform; +use Nextras\Dbal\Utils\StrictObjectTrait; class SqlProcessor { + use StrictObjectTrait; + + /** * @var array (name => [supports ?, supports [], expected type]) * @phpstan-var array diff --git a/src/Utils/FileImporter.php b/src/Utils/FileImporter.php index 6361f5e8..3b8d8a4e 100644 --- a/src/Utils/FileImporter.php +++ b/src/Utils/FileImporter.php @@ -17,6 +17,9 @@ class FileImporter { + use StrictObjectTrait; + + /** * Imports & executes queries from sql file. * Code taken from Adminer (http://www.adminer.org) & modified, diff --git a/src/Utils/LoggerHelper.php b/src/Utils/LoggerHelper.php index 66f8c727..991b7a6b 100644 --- a/src/Utils/LoggerHelper.php +++ b/src/Utils/LoggerHelper.php @@ -19,6 +19,9 @@ */ class LoggerHelper { + use StrictObjectTrait; + + /** * @throws DriverException */ diff --git a/src/Utils/SqlHighlighter.php b/src/Utils/SqlHighlighter.php index dfb731aa..0217b9c7 100644 --- a/src/Utils/SqlHighlighter.php +++ b/src/Utils/SqlHighlighter.php @@ -14,6 +14,9 @@ */ class SqlHighlighter { + use StrictObjectTrait; + + public static function highlight(string $sql): string { static $keywords1 = 'SELECT|(?:ON\s+DUPLICATE\s+KEY)?UPDATE|INSERT(?:\s+INTO)?|REPLACE(?:\s+INTO)?|SHOW|DELETE|CALL|UNION|FROM|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|OFFSET|SET|VALUES|LEFT\s+JOIN|INNER\s+JOIN|TRUNCATE|START\s+TRANSACTION|COMMIT|ROLLBACK|(?:RELEASE\s+|ROLLBACK\s+TO\s+)?SAVEPOINT'; diff --git a/src/Utils/Typos.php b/src/Utils/Typos.php index 6af70272..e3eeb4db 100644 --- a/src/Utils/Typos.php +++ b/src/Utils/Typos.php @@ -11,6 +11,9 @@ class Typos { + use StrictObjectTrait; + + /** * Returns the closest word to the $current word or NULL if such word does not exist. * @param string[] $words From b554e68d7cb7ffbd614dac0801588abae9bf4856 Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Thu, 7 May 2020 21:07:13 +0200 Subject: [PATCH 3/4] move MultiLogger to utils & mark as internal, Typos also internal --- src/Connection.php | 1 + src/{ => Utils}/MultiLogger.php | 7 +++++-- src/Utils/Typos.php | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) rename src/{ => Utils}/MultiLogger.php (89%) diff --git a/src/Connection.php b/src/Connection.php index 8349118a..b24d8fb0 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -13,6 +13,7 @@ use Nextras\Dbal\QueryBuilder\QueryBuilder; use Nextras\Dbal\Result\Result; use Nextras\Dbal\Utils\LoggerHelper; +use Nextras\Dbal\Utils\MultiLogger; use Nextras\Dbal\Utils\StrictObjectTrait; use function array_unshift; use function assert; diff --git a/src/MultiLogger.php b/src/Utils/MultiLogger.php similarity index 89% rename from src/MultiLogger.php rename to src/Utils/MultiLogger.php index 87aad519..b118efdf 100644 --- a/src/MultiLogger.php +++ b/src/Utils/MultiLogger.php @@ -1,11 +1,14 @@ Date: Thu, 7 May 2020 22:02:47 +0200 Subject: [PATCH 4/4] exceptions: move to new locations --- .phpstan.neon | 3 + composer.json | 2 +- src/Connection.php | 6 +- src/Drivers/Exception/ConnectionException.php | 8 ++ .../ConstraintViolationException.php | 8 ++ src/Drivers/Exception/DriverException.php | 40 ++++++ ...ForeignKeyConstraintViolationException.php | 8 ++ .../NotNullConstraintViolationException.php | 8 ++ src/Drivers/Exception/QueryException.php | 31 +++++ .../UniqueConstraintViolationException.php | 8 ++ src/Drivers/IDriver.php | 11 +- src/Drivers/IResultAdapter.php | 4 +- src/Drivers/Mysqli/MysqliDriver.php | 43 +++---- .../Mysqli/MysqliEmptyResultAdapter.php | 4 +- src/Drivers/Mysqli/MysqliResultAdapter.php | 4 +- src/Drivers/Pgsql/PgsqlDriver.php | 36 +++--- src/Drivers/Pgsql/PgsqlResultAdapter.php | 4 +- src/Drivers/Sqlsrv/SqlsrvDriver.php | 19 +-- src/Drivers/Sqlsrv/SqlsrvResultAdapter.php | 4 +- src/Exception/IOException.php | 10 ++ src/Exception/InvalidArgumentException.php | 7 ++ src/Exception/InvalidStateException.php | 10 ++ .../MemberAccessException.php | 3 +- src/Exception/NotImplementedException.php | 10 ++ src/Exception/NotSupportedException.php | 10 ++ src/ILogger.php | 2 +- src/QueryBuilder/QueryBuilder.php | 14 ++- src/Result/Result.php | 4 +- src/Result/Row.php | 2 +- src/SqlProcessor.php | 5 +- src/Utils/FileImporter.php | 2 +- src/Utils/MultiLogger.php | 1 + src/Utils/StrictObjectTrait.php | 4 +- src/compatibility.php | 79 ++++++++++++ src/exceptions.php | 116 ------------------ tests/cases/integration/connection.pgsql.phpt | 2 +- tests/cases/integration/connection.phpt | 4 +- tests/cases/integration/driver.mysqli.phpt | 2 +- tests/cases/integration/driver.sqlsrv.phpt | 2 +- tests/cases/integration/result.phpt | 4 +- tests/cases/integration/transactions.phpt | 2 +- tests/cases/unit/QueryBuilderTest.basics.phpt | 2 +- tests/cases/unit/QueryBuilderTest.joins.phpt | 4 - tests/cases/unit/ResultTest.phpt | 2 +- tests/cases/unit/RowTest.phpt | 2 +- .../SqlProcessorTest.custom_modifier.phpt | 2 +- tests/cases/unit/SqlProcessorTest.ex.phpt | 2 +- .../cases/unit/SqlProcessorTest.process.phpt | 2 +- tests/cases/unit/SqlProcessorTest.raw.phpt | 2 +- tests/cases/unit/SqlProcessorTest.scalar.phpt | 2 +- tests/cases/unit/SqlProcessorTest.values.phpt | 2 +- tests/cases/unit/SqlProcessorTest.where.phpt | 2 +- tests/inc/IntegrationTestCase.php | 2 +- 53 files changed, 353 insertions(+), 219 deletions(-) create mode 100644 src/Drivers/Exception/ConnectionException.php create mode 100644 src/Drivers/Exception/ConstraintViolationException.php create mode 100644 src/Drivers/Exception/DriverException.php create mode 100644 src/Drivers/Exception/ForeignKeyConstraintViolationException.php create mode 100644 src/Drivers/Exception/NotNullConstraintViolationException.php create mode 100644 src/Drivers/Exception/QueryException.php create mode 100644 src/Drivers/Exception/UniqueConstraintViolationException.php create mode 100644 src/Exception/IOException.php create mode 100644 src/Exception/InvalidArgumentException.php create mode 100644 src/Exception/InvalidStateException.php rename src/{Exceptions => Exception}/MemberAccessException.php (72%) create mode 100644 src/Exception/NotImplementedException.php create mode 100644 src/Exception/NotSupportedException.php create mode 100644 src/compatibility.php delete mode 100644 src/exceptions.php diff --git a/.phpstan.neon b/.phpstan.neon index 382d69ba..8cdf322e 100644 --- a/.phpstan.neon +++ b/.phpstan.neon @@ -18,3 +18,6 @@ parameters: - message: '~Call to an undefined method .+::children\(\)\.~' path: "src/Bridges/SymfonyBundle/DependencyInjection/Configuration.php" + - + message: '~.*~' + path: "src/compatibility.php" diff --git a/composer.json b/composer.json index 91ec92b3..92a9dcfb 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ }, "autoload": { "psr-4": { "Nextras\\Dbal\\": "src/" }, - "classmap": ["src/exceptions.php"] + "classmap": ["src/compatibility.php"] }, "scripts": { "phpstan": "phpstan analyze -c .phpstan.neon" diff --git a/src/Connection.php b/src/Connection.php index b24d8fb0..f9fc2841 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -8,7 +8,9 @@ namespace Nextras\Dbal; +use Exception; use Nextras\Dbal\Drivers\IDriver; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\QueryBuilder\QueryBuilder; use Nextras\Dbal\Result\Result; @@ -210,7 +212,7 @@ public function transactional(callable $callback) $returnValue = $callback($this); $this->commitTransaction(); return $returnValue; - } catch (\Exception $e) { + } catch (Exception $e) { $this->rollbackTransaction(); throw $e; } @@ -353,7 +355,7 @@ private function nativeQuery(string $sql): Result private function createDriver(): IDriver { if (empty($this->config['driver'])) { - throw new InvalidStateException('Undefined driver. Choose from: mysqli, pgsql, sqlsrv.'); + throw new InvalidArgumentException('Undefined driver. Choose from: mysqli, pgsql, sqlsrv.'); } elseif ($this->config['driver'] instanceof IDriver) { return $this->config['driver']; } else { diff --git a/src/Drivers/Exception/ConnectionException.php b/src/Drivers/Exception/ConnectionException.php new file mode 100644 index 00000000..caeccbf2 --- /dev/null +++ b/src/Drivers/Exception/ConnectionException.php @@ -0,0 +1,8 @@ +errorCode = $errorCode; + $this->errorSqlState = (string) $errorSqlState; + } + + + public function getErrorCode(): int + { + return $this->errorCode; + } + + + public function getErrorSqlState(): string + { + return $this->errorSqlState; + } +} diff --git a/src/Drivers/Exception/ForeignKeyConstraintViolationException.php b/src/Drivers/Exception/ForeignKeyConstraintViolationException.php new file mode 100644 index 00000000..4339f2fb --- /dev/null +++ b/src/Drivers/Exception/ForeignKeyConstraintViolationException.php @@ -0,0 +1,8 @@ +sqlQuery = (string) $sqlQuery; + } + + + public function getSqlQuery(): string + { + return $this->sqlQuery; + } +} diff --git a/src/Drivers/Exception/UniqueConstraintViolationException.php b/src/Drivers/Exception/UniqueConstraintViolationException.php new file mode 100644 index 00000000..0566bf95 --- /dev/null +++ b/src/Drivers/Exception/UniqueConstraintViolationException.php @@ -0,0 +1,8 @@ +connection !== null); + assert($this->connection !== null); if ( !isset($params['sslKey']) && @@ -289,20 +294,17 @@ public function convertToPhp(string $value, $nativeType) { if ($nativeType === MYSQLI_TYPE_TIMESTAMP) { return $value . ' ' . $this->connectionTz->getName(); - } elseif ($nativeType === MYSQLI_TYPE_LONGLONG) { // called only on 32bit // hack for phpstan /** @var int|float $numeric */ $numeric = $value; return is_float($tmp = $numeric * 1) ? $numeric : $tmp; - } elseif ($nativeType === MYSQLI_TYPE_TIME) { preg_match('#^(-?)(\d+):(\d+):(\d+)#', $value, $m); $value = new DateInterval("PT{$m[2]}H{$m[3]}M{$m[4]}S"); $value->invert = $m[1] ? 1 : 0; return $value; - } else { throw new NotSupportedException("MysqliDriver does not support '{$nativeType}' type conversion."); } @@ -346,11 +348,11 @@ public function convertIdentifierToSql(string $value): string } - public function convertDatetimeToSql(\DateTimeInterface $value): string + public function convertDatetimeToSql(DateTimeInterface $value): string { - assert($value instanceof \DateTime || $value instanceof \DateTimeImmutable); + assert($value instanceof DateTime || $value instanceof DateTimeImmutable); if ($value->getTimezone()->getName() !== $this->connectionTz->getName()) { - if ($value instanceof \DateTimeImmutable) { + if ($value instanceof DateTimeImmutable) { $value = $value->setTimezone($this->connectionTz); } else { $value = clone $value; @@ -361,13 +363,13 @@ public function convertDatetimeToSql(\DateTimeInterface $value): string } - public function convertDatetimeSimpleToSql(\DateTimeInterface $value): string + public function convertDatetimeSimpleToSql(DateTimeInterface $value): string { return "'" . $value->format('Y-m-d H:i:s.u') . "'"; } - public function convertDateIntervalToSql(\DateInterval $value): string + public function convertDateIntervalToSql(DateInterval $value): string { $totalHours = ((int) $value->format('%a')) * 24 + $value->h; if ($totalHours >= 839) { @@ -405,23 +407,18 @@ public function modifyLimitQuery(string $query, ?int $limit, ?int $offset): stri * This method is based on Doctrine\DBAL project. * @link www.doctrine-project.org */ - protected function createException(string $error, int $errorNo, string $sqlState, ?string $query = null): \Exception + protected function createException(string $error, int $errorNo, string $sqlState, ?string $query = null): Exception { if (in_array($errorNo, [1216, 1217, 1451, 1452, 1701], true)) { return new ForeignKeyConstraintViolationException($error, $errorNo, $sqlState, null, $query); - } elseif (in_array($errorNo, [1062, 1557, 1569, 1586], true)) { return new UniqueConstraintViolationException($error, $errorNo, $sqlState, null, $query); - } elseif (in_array($errorNo, [1044, 1045, 1046, 1049, 1095, 1142, 1143, 1227, 1370, 2002, 2005, 2054], true)) { return new ConnectionException($error, $errorNo, $sqlState); - } elseif (in_array($errorNo, [1048, 1121, 1138, 1171, 1252, 1263, 1566], true)) { return new NotNullConstraintViolationException($error, $errorNo, $sqlState, null, $query); - } elseif ($query !== null) { return new QueryException($error, $errorNo, $sqlState, null, $query); - } else { return new DriverException($error, $errorNo, $sqlState); } diff --git a/src/Drivers/Mysqli/MysqliEmptyResultAdapter.php b/src/Drivers/Mysqli/MysqliEmptyResultAdapter.php index 4da03be4..41323211 100644 --- a/src/Drivers/Mysqli/MysqliEmptyResultAdapter.php +++ b/src/Drivers/Mysqli/MysqliEmptyResultAdapter.php @@ -9,7 +9,7 @@ namespace Nextras\Dbal\Drivers\Mysqli; use Nextras\Dbal\Drivers\IResultAdapter; -use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Utils\StrictObjectTrait; @@ -20,7 +20,7 @@ class MysqliEmptyResultAdapter implements IResultAdapter public function seek(int $index): void { - throw new InvalidStateException("Unable to seek in row set to {$index} index."); + throw new InvalidArgumentException("Unable to seek in row set to {$index} index."); } diff --git a/src/Drivers/Mysqli/MysqliResultAdapter.php b/src/Drivers/Mysqli/MysqliResultAdapter.php index ff62cb8f..9eec8045 100644 --- a/src/Drivers/Mysqli/MysqliResultAdapter.php +++ b/src/Drivers/Mysqli/MysqliResultAdapter.php @@ -10,7 +10,7 @@ use mysqli_result; use Nextras\Dbal\Drivers\IResultAdapter; -use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Utils\StrictObjectTrait; @@ -71,7 +71,7 @@ public function __destruct() public function seek(int $index): void { if ($this->result->num_rows !== 0 && !$this->result->data_seek($index)) { - throw new InvalidStateException("Unable to seek in row set to {$index} index."); + throw new InvalidArgumentException("Unable to seek in row set to {$index} index."); } } diff --git a/src/Drivers/Pgsql/PgsqlDriver.php b/src/Drivers/Pgsql/PgsqlDriver.php index b3988531..8eda19e8 100644 --- a/src/Drivers/Pgsql/PgsqlDriver.php +++ b/src/Drivers/Pgsql/PgsqlDriver.php @@ -9,24 +9,28 @@ namespace Nextras\Dbal\Drivers\Pgsql; use DateInterval; +use DateTime; +use DateTimeImmutable; +use DateTimeInterface; use DateTimeZone; +use Exception; use Nextras\Dbal\Connection; -use Nextras\Dbal\ConnectionException; -use Nextras\Dbal\DriverException; +use Nextras\Dbal\Drivers\Exception\ConnectionException; +use Nextras\Dbal\Drivers\Exception\DriverException; +use Nextras\Dbal\Drivers\Exception\ForeignKeyConstraintViolationException; +use Nextras\Dbal\Drivers\Exception\NotNullConstraintViolationException; +use Nextras\Dbal\Drivers\Exception\QueryException; +use Nextras\Dbal\Drivers\Exception\UniqueConstraintViolationException; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\ForeignKeyConstraintViolationException; +use Nextras\Dbal\Exception\InvalidArgumentException; +use Nextras\Dbal\Exception\NotSupportedException; use Nextras\Dbal\ILogger; -use Nextras\Dbal\InvalidArgumentException; -use Nextras\Dbal\NotNullConstraintViolationException; -use Nextras\Dbal\NotSupportedException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\Platforms\PostgreSqlPlatform; -use Nextras\Dbal\QueryException; use Nextras\Dbal\Result\Result; -use Nextras\Dbal\UniqueConstraintViolationException; use Nextras\Dbal\Utils\LoggerHelper; use Nextras\Dbal\Utils\StrictObjectTrait; -use Tester\Assert; +use function is_string; class PgsqlDriver implements IDriver @@ -134,7 +138,7 @@ public function query(string $query): Result } $state = pg_result_error_field($resource, PGSQL_DIAG_SQLSTATE); - if (\is_string($state)) { + if (is_string($state)) { throw $this->createException(pg_result_error($resource) ?: 'Unknown error', 0, $state, $query); } @@ -315,11 +319,11 @@ public function convertIdentifierToSql(string $value): string } - public function convertDateTimeToSql(\DateTimeInterface $value): string + public function convertDateTimeToSql(DateTimeInterface $value): string { - assert($value instanceof \DateTime || $value instanceof \DateTimeImmutable); + assert($value instanceof DateTime || $value instanceof DateTimeImmutable); if ($value->getTimezone()->getName() !== $this->connectionTz->getName()) { - if ($value instanceof \DateTimeImmutable) { + if ($value instanceof DateTimeImmutable) { $value = $value->setTimezone($this->connectionTz); } else { $value = clone $value; @@ -330,13 +334,13 @@ public function convertDateTimeToSql(\DateTimeInterface $value): string } - public function convertDateTimeSimpleToSql(\DateTimeInterface $value): string + public function convertDateTimeSimpleToSql(DateTimeInterface $value): string { return "'" . $value->format('Y-m-d H:i:s.u') . "'::timestamp"; } - public function convertDateIntervalToSql(\DateInterval $value): string + public function convertDateIntervalToSql(DateInterval $value): string { return $value->format('P%yY%mM%dDT%hH%iM%sS'); } @@ -365,7 +369,7 @@ public function modifyLimitQuery(string $query, ?int $limit, ?int $offset): stri * This method is based on Doctrine\DBAL project. * @link www.doctrine-project.org */ - protected function createException(string $error, int $errorNo, ?string $sqlState, ?string $query = null): \Exception + protected function createException(string $error, int $errorNo, ?string $sqlState, ?string $query = null): Exception { // see codes at http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html if ($sqlState === '0A000' && strpos($error, 'truncate') !== false) { diff --git a/src/Drivers/Pgsql/PgsqlResultAdapter.php b/src/Drivers/Pgsql/PgsqlResultAdapter.php index afb4d6cf..8d001dca 100644 --- a/src/Drivers/Pgsql/PgsqlResultAdapter.php +++ b/src/Drivers/Pgsql/PgsqlResultAdapter.php @@ -9,7 +9,7 @@ namespace Nextras\Dbal\Drivers\Pgsql; use Nextras\Dbal\Drivers\IResultAdapter; -use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Utils\StrictObjectTrait; @@ -71,7 +71,7 @@ public function __destruct() public function seek(int $index): void { if (pg_num_rows($this->result) !== 0 && !pg_result_seek($this->result, $index)) { - throw new InvalidStateException("Unable to seek in row set to {$index} index."); + throw new InvalidArgumentException("Unable to seek in row set to {$index} index."); } } diff --git a/src/Drivers/Sqlsrv/SqlsrvDriver.php b/src/Drivers/Sqlsrv/SqlsrvDriver.php index a6c5ee44..b8ce7fda 100644 --- a/src/Drivers/Sqlsrv/SqlsrvDriver.php +++ b/src/Drivers/Sqlsrv/SqlsrvDriver.php @@ -10,20 +10,21 @@ use DateInterval; use DateTimeInterface; +use Exception; use Nextras\Dbal\Connection; -use Nextras\Dbal\ConnectionException; -use Nextras\Dbal\DriverException; +use Nextras\Dbal\Drivers\Exception\ConnectionException; +use Nextras\Dbal\Drivers\Exception\DriverException; +use Nextras\Dbal\Drivers\Exception\ForeignKeyConstraintViolationException; +use Nextras\Dbal\Drivers\Exception\NotNullConstraintViolationException; +use Nextras\Dbal\Drivers\Exception\QueryException; +use Nextras\Dbal\Drivers\Exception\UniqueConstraintViolationException; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\ForeignKeyConstraintViolationException; +use Nextras\Dbal\Exception\InvalidArgumentException; +use Nextras\Dbal\Exception\NotSupportedException; use Nextras\Dbal\ILogger; -use Nextras\Dbal\InvalidArgumentException; -use Nextras\Dbal\NotNullConstraintViolationException; -use Nextras\Dbal\NotSupportedException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\Platforms\SqlServerPlatform; -use Nextras\Dbal\QueryException; use Nextras\Dbal\Result\Result; -use Nextras\Dbal\UniqueConstraintViolationException; use Nextras\Dbal\Utils\DateTimeImmutable; use Nextras\Dbal\Utils\LoggerHelper; use Nextras\Dbal\Utils\StrictObjectTrait; @@ -373,7 +374,7 @@ private function throwErrors(?string $query = null): void } - protected function createException(string $error, int $errorNo, string $sqlState, ?string $query = null): \Exception + protected function createException(string $error, int $errorNo, string $sqlState, ?string $query = null): Exception { if (in_array($sqlState, ['HYT00', '08001', '28000'], true)) { return new ConnectionException($error, $errorNo, $sqlState); diff --git a/src/Drivers/Sqlsrv/SqlsrvResultAdapter.php b/src/Drivers/Sqlsrv/SqlsrvResultAdapter.php index a0a53fb4..58403898 100644 --- a/src/Drivers/Sqlsrv/SqlsrvResultAdapter.php +++ b/src/Drivers/Sqlsrv/SqlsrvResultAdapter.php @@ -9,7 +9,7 @@ namespace Nextras\Dbal\Drivers\Sqlsrv; use Nextras\Dbal\Drivers\IResultAdapter; -use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Utils\StrictObjectTrait; @@ -58,7 +58,7 @@ public function __destruct() public function seek(int $index): void { if ($index !== 0 && sqlsrv_num_rows($this->statement) !== 0 && !sqlsrv_fetch($this->statement, SQLSRV_SCROLL_ABSOLUTE, $index)) { - throw new InvalidStateException("Unable to seek in row set to {$index} index."); + throw new InvalidArgumentException("Unable to seek in row set to {$index} index."); } $this->index = $index; } diff --git a/src/Exception/IOException.php b/src/Exception/IOException.php new file mode 100644 index 00000000..60d51571 --- /dev/null +++ b/src/Exception/IOException.php @@ -0,0 +1,10 @@ + $args * @deprecated QueryBuilder::innerJoin() is deprecated. Use QueryBuilder::joinInner() without $fromAlias and with $toAlias included in $toExpression. + * @noinspection PhpUnusedParameterInspection */ public function innerJoin(string $fromAlias, string $toExpression, string $toAlias, string $onExpression, ...$args): self { - \trigger_error( + trigger_error( 'QueryBuilder::innerJoin() is deprecated. Use QueryBuilder::joinInner() without $fromAlias and with $toAlias included in $toExpression.', E_USER_DEPRECATED ); @@ -229,10 +231,11 @@ public function innerJoin(string $fromAlias, string $toExpression, string $toAli /** * @phpstan-param array $args * @deprecated QueryBuilder::leftJoin() is deprecated. Use QueryBuilder::joinLeft() without $fromAlias and with $toAlias included in $toExpression. + * @noinspection PhpUnusedParameterInspection */ public function leftJoin(string $fromAlias, string $toExpression, string $toAlias, string $onExpression, ...$args): self { - \trigger_error( + trigger_error( 'QueryBuilder::leftJoin() is deprecated. Use QueryBuilder::joinLeft() without $fromAlias and with $toAlias included in $toExpression.', E_USER_DEPRECATED ); @@ -243,10 +246,11 @@ public function leftJoin(string $fromAlias, string $toExpression, string $toAlia /** * @phpstan-param array $args * @deprecated QueryBuilder::rightJoin() is deprecated. Use QueryBuilder::joinRight() without $fromAlias and with $toAlias included in $toExpression. + * @noinspection PhpUnusedParameterInspection */ public function rightJoin(string $fromAlias, string $toExpression, string $toAlias, string $onExpression, ...$args): self { - \trigger_error( + trigger_error( 'QueryBuilder::rightJoin() is deprecated. Use QueryBuilder::joinRight() without $fromAlias and with $toAlias included in $toExpression.', E_USER_DEPRECATED ); diff --git a/src/Result/Result.php b/src/Result/Result.php index 78bc488f..aee98084 100644 --- a/src/Result/Result.php +++ b/src/Result/Result.php @@ -12,7 +12,7 @@ use DateTimeZone; use Nextras\Dbal\Drivers\IDriver; use Nextras\Dbal\Drivers\IResultAdapter; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Utils\DateTimeImmutable; use Nextras\Dbal\Utils\StrictObjectTrait; use SeekableIterator; @@ -133,7 +133,7 @@ public function fetchAll(): array /** * @phpstan-return array */ - public function fetchPairs(string $key = null, string $value = null): array + public function fetchPairs(?string $key = null, ?string $value = null): array { if ($key === null && $value === null) { throw new InvalidArgumentException('Result::fetchPairs() requires defined key or value.'); diff --git a/src/Result/Row.php b/src/Result/Row.php index 2f1aa527..fe7bc5de 100644 --- a/src/Result/Row.php +++ b/src/Result/Row.php @@ -8,7 +8,7 @@ namespace Nextras\Dbal\Result; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Utils\Typos; diff --git a/src/SqlProcessor.php b/src/SqlProcessor.php index 04bf4e93..e198cea0 100644 --- a/src/SqlProcessor.php +++ b/src/SqlProcessor.php @@ -8,7 +8,10 @@ namespace Nextras\Dbal; +use DateTime; +use DateTimeImmutable; use Nextras\Dbal\Drivers\IDriver; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\Utils\StrictObjectTrait; @@ -257,7 +260,7 @@ public function processModifier(string $type, $value): string return $this->driver->convertJsonToSql($value); } - if ($value instanceof \DateTimeImmutable || $value instanceof \DateTime) { + if ($value instanceof DateTimeImmutable || $value instanceof DateTime) { switch ($type) { case 'any': case 'dt': diff --git a/src/Utils/FileImporter.php b/src/Utils/FileImporter.php index 3b8d8a4e..ea416cad 100644 --- a/src/Utils/FileImporter.php +++ b/src/Utils/FileImporter.php @@ -8,8 +8,8 @@ namespace Nextras\Dbal\Utils; +use Nextras\Dbal\Exception\IOException; use Nextras\Dbal\IConnection; -use Nextras\Dbal\IOException; use Nextras\Dbal\Platforms\MySqlPlatform; use Nextras\Dbal\Platforms\PostgreSqlPlatform; use Nextras\Dbal\Platforms\SqlServerPlatform; diff --git a/src/Utils/MultiLogger.php b/src/Utils/MultiLogger.php index b118efdf..0c56f39a 100644 --- a/src/Utils/MultiLogger.php +++ b/src/Utils/MultiLogger.php @@ -2,6 +2,7 @@ namespace Nextras\Dbal\Utils; +use Nextras\Dbal\Drivers\Exception\DriverException; use Nextras\Dbal\ILogger; use Nextras\Dbal\Result\Result; diff --git a/src/Utils/StrictObjectTrait.php b/src/Utils/StrictObjectTrait.php index f75cb517..21926daa 100644 --- a/src/Utils/StrictObjectTrait.php +++ b/src/Utils/StrictObjectTrait.php @@ -2,11 +2,11 @@ namespace Nextras\Dbal\Utils; -use Nextras\Dbal\Exceptions\MemberAccessException; +use Nextras\Dbal\Exception\MemberAccessException; /** - * @internal + * @internal */ trait StrictObjectTrait { diff --git a/src/compatibility.php b/src/compatibility.php new file mode 100644 index 00000000..30e382d3 --- /dev/null +++ b/src/compatibility.php @@ -0,0 +1,79 @@ +errorCode = $errorCode; - $this->errorSqlState = (string) $errorSqlState; - } - - - public function getErrorCode(): int - { - return $this->errorCode; - } - - - public function getErrorSqlState(): string - { - return $this->errorSqlState; - } - -} - - -class QueryException extends DriverException -{ - /** @var string */ - private $sqlQuery; - - - public function __construct(string $message, int $errorCode = 0, string $errorSqlState = '', Exception $previousException = NULL, string $sqlQuery = NULL) - { - parent::__construct($message, $errorCode, $errorSqlState, $previousException); - $this->sqlQuery = (string) $sqlQuery; - } - - - public function getSqlQuery(): string - { - return $this->sqlQuery; - } - -} - - - -abstract class ConstraintViolationException extends QueryException -{ -} - - -class NotNullConstraintViolationException extends ConstraintViolationException -{ -} - - -class ForeignKeyConstraintViolationException extends ConstraintViolationException -{ -} - - -class UniqueConstraintViolationException extends ConstraintViolationException -{ -} diff --git a/tests/cases/integration/connection.pgsql.phpt b/tests/cases/integration/connection.pgsql.phpt index 39dc88b3..d911fae6 100644 --- a/tests/cases/integration/connection.pgsql.phpt +++ b/tests/cases/integration/connection.pgsql.phpt @@ -8,7 +8,7 @@ namespace NextrasTests\Dbal; use Nextras\Dbal\Drivers\Pgsql\PgsqlDriver; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Tester\Assert; diff --git a/tests/cases/integration/connection.phpt b/tests/cases/integration/connection.phpt index b443f86a..c28135fd 100644 --- a/tests/cases/integration/connection.phpt +++ b/tests/cases/integration/connection.phpt @@ -7,7 +7,7 @@ namespace NextrasTests\Dbal; -use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Tester\Assert; @@ -59,7 +59,7 @@ class ConnectionTest extends IntegrationTestCase { Assert::exception(function () { $this->createConnection(['driver' => null]); - }, InvalidStateException::class); + }, InvalidArgumentException::class); } } diff --git a/tests/cases/integration/driver.mysqli.phpt b/tests/cases/integration/driver.mysqli.phpt index 81097def..4de0b7a6 100644 --- a/tests/cases/integration/driver.mysqli.phpt +++ b/tests/cases/integration/driver.mysqli.phpt @@ -8,7 +8,7 @@ namespace NextrasTests\Dbal; use DateTime; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Tester\Assert; diff --git a/tests/cases/integration/driver.sqlsrv.phpt b/tests/cases/integration/driver.sqlsrv.phpt index 9ac3b431..b74abc6c 100644 --- a/tests/cases/integration/driver.sqlsrv.phpt +++ b/tests/cases/integration/driver.sqlsrv.phpt @@ -8,7 +8,7 @@ namespace NextrasTests\Dbal; use DateTime; -use Nextras\Dbal\NotSupportedException; +use Nextras\Dbal\Exception\NotSupportedException; use Tester\Assert; diff --git a/tests/cases/integration/result.phpt b/tests/cases/integration/result.phpt index d43de3fb..65ab00b4 100644 --- a/tests/cases/integration/result.phpt +++ b/tests/cases/integration/result.phpt @@ -7,7 +7,7 @@ namespace NextrasTests\Dbal; -use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\SqlServerPlatform; use Nextras\Dbal\Utils\DateTimeImmutable; use Tester\Assert; @@ -62,7 +62,7 @@ class ResultIntegrationTest extends IntegrationTestCase Assert::exception(function () use ($result) { $result->seek(10); - }, InvalidStateException::class); + }, InvalidArgumentException::class); } diff --git a/tests/cases/integration/transactions.phpt b/tests/cases/integration/transactions.phpt index c9082027..c5f87b5a 100644 --- a/tests/cases/integration/transactions.phpt +++ b/tests/cases/integration/transactions.phpt @@ -8,7 +8,7 @@ namespace NextrasTests\Dbal; use Nextras\Dbal\Connection; -use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Exception\InvalidStateException; use Nextras\Dbal\Platforms\SqlServerPlatform; use Tester\Assert; use Tester\Environment; diff --git a/tests/cases/unit/QueryBuilderTest.basics.phpt b/tests/cases/unit/QueryBuilderTest.basics.phpt index cbbf5599..7ea85abb 100644 --- a/tests/cases/unit/QueryBuilderTest.basics.phpt +++ b/tests/cases/unit/QueryBuilderTest.basics.phpt @@ -4,7 +4,7 @@ namespace NextrasTests\Dbal; -use Nextras\Dbal\InvalidStateException; +use Nextras\Dbal\Exception\InvalidStateException; use Tester\Assert; diff --git a/tests/cases/unit/QueryBuilderTest.joins.phpt b/tests/cases/unit/QueryBuilderTest.joins.phpt index 493ce165..c0d078c1 100644 --- a/tests/cases/unit/QueryBuilderTest.joins.phpt +++ b/tests/cases/unit/QueryBuilderTest.joins.phpt @@ -4,10 +4,6 @@ namespace NextrasTests\Dbal; -use Nextras\Dbal\InvalidStateException; -use Tester\Assert; - - require_once __DIR__ . '/../../bootstrap.php'; diff --git a/tests/cases/unit/ResultTest.phpt b/tests/cases/unit/ResultTest.phpt index 7bb73a3e..a664048b 100644 --- a/tests/cases/unit/ResultTest.phpt +++ b/tests/cases/unit/ResultTest.phpt @@ -7,7 +7,7 @@ namespace NextrasTests\Dbal; use Mockery; use Nextras\Dbal\Drivers\IDriver; use Nextras\Dbal\Drivers\IResultAdapter; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Result\Result; use Nextras\Dbal\Result\Row; use Nextras\Dbal\Utils\DateTimeImmutable; diff --git a/tests/cases/unit/RowTest.phpt b/tests/cases/unit/RowTest.phpt index 4b72dd19..192b01a7 100644 --- a/tests/cases/unit/RowTest.phpt +++ b/tests/cases/unit/RowTest.phpt @@ -4,7 +4,7 @@ namespace NextrasTests\Dbal; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Result\Row; use Tester\Assert; diff --git a/tests/cases/unit/SqlProcessorTest.custom_modifier.phpt b/tests/cases/unit/SqlProcessorTest.custom_modifier.phpt index 5495db33..07392521 100644 --- a/tests/cases/unit/SqlProcessorTest.custom_modifier.phpt +++ b/tests/cases/unit/SqlProcessorTest.custom_modifier.phpt @@ -5,7 +5,7 @@ namespace NextrasTests\Dbal; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\SqlProcessor; use Tester\Assert; diff --git a/tests/cases/unit/SqlProcessorTest.ex.phpt b/tests/cases/unit/SqlProcessorTest.ex.phpt index 8d79dc91..c29617cb 100644 --- a/tests/cases/unit/SqlProcessorTest.ex.phpt +++ b/tests/cases/unit/SqlProcessorTest.ex.phpt @@ -7,7 +7,7 @@ namespace NextrasTests\Dbal; use Mockery; use Mockery\MockInterface; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\SqlProcessor; use Tester\Assert; diff --git a/tests/cases/unit/SqlProcessorTest.process.phpt b/tests/cases/unit/SqlProcessorTest.process.phpt index c20b3460..15450149 100644 --- a/tests/cases/unit/SqlProcessorTest.process.phpt +++ b/tests/cases/unit/SqlProcessorTest.process.phpt @@ -6,7 +6,7 @@ namespace NextrasTests\Dbal; use Mockery; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\SqlProcessor; use Tester\Assert; diff --git a/tests/cases/unit/SqlProcessorTest.raw.phpt b/tests/cases/unit/SqlProcessorTest.raw.phpt index ecd72ad3..544ac71c 100644 --- a/tests/cases/unit/SqlProcessorTest.raw.phpt +++ b/tests/cases/unit/SqlProcessorTest.raw.phpt @@ -6,7 +6,7 @@ namespace NextrasTests\Dbal; use Mockery; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\SqlProcessor; use Tester\Assert; diff --git a/tests/cases/unit/SqlProcessorTest.scalar.phpt b/tests/cases/unit/SqlProcessorTest.scalar.phpt index 69cbbc39..7ae43389 100644 --- a/tests/cases/unit/SqlProcessorTest.scalar.phpt +++ b/tests/cases/unit/SqlProcessorTest.scalar.phpt @@ -7,7 +7,7 @@ namespace NextrasTests\Dbal; use DateTime; use Mockery; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\SqlProcessor; use stdClass; diff --git a/tests/cases/unit/SqlProcessorTest.values.phpt b/tests/cases/unit/SqlProcessorTest.values.phpt index c763ae49..fcc393d0 100644 --- a/tests/cases/unit/SqlProcessorTest.values.phpt +++ b/tests/cases/unit/SqlProcessorTest.values.phpt @@ -6,7 +6,7 @@ namespace NextrasTests\Dbal; use Mockery\MockInterface; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\SqlProcessor; use Tester\Assert; diff --git a/tests/cases/unit/SqlProcessorTest.where.phpt b/tests/cases/unit/SqlProcessorTest.where.phpt index 96c09122..0acf33c4 100644 --- a/tests/cases/unit/SqlProcessorTest.where.phpt +++ b/tests/cases/unit/SqlProcessorTest.where.phpt @@ -7,7 +7,7 @@ namespace NextrasTests\Dbal; use DateTime; use Mockery; use Nextras\Dbal\Drivers\IDriver; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Platforms\IPlatform; use Nextras\Dbal\SqlProcessor; use stdClass; diff --git a/tests/inc/IntegrationTestCase.php b/tests/inc/IntegrationTestCase.php index 5dfd3754..6179dac8 100644 --- a/tests/inc/IntegrationTestCase.php +++ b/tests/inc/IntegrationTestCase.php @@ -3,7 +3,7 @@ namespace NextrasTests\Dbal; use Nextras\Dbal\Connection; -use Nextras\Dbal\InvalidArgumentException; +use Nextras\Dbal\Exception\InvalidArgumentException; use Nextras\Dbal\Utils\FileImporter; use Tester\Environment;