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;