From 6e0a45025be43765aea8994e705542eab0021c1a Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Tue, 16 Jan 2024 12:30:15 +0100 Subject: [PATCH] refactor: remove Safe\PcreException throws --- src/Client/ClickHouseClient.php | 6 ------ src/Snippet/CurrentDatabase.php | 2 -- src/Snippet/DatabaseSize.php | 2 -- src/Snippet/Parts.php | 2 -- src/Snippet/ShowCreateTable.php | 2 -- src/Snippet/ShowDatabases.php | 2 -- src/Snippet/TableSizes.php | 2 -- src/Snippet/Version.php | 2 -- src/Sql/SqlFactory.php | 4 +--- src/Sql/ValueFormatter.php | 8 ++------ tests/Snippet/ShowCreateTableTest.php | 2 +- tests/WithClient.php | 2 -- 12 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/Client/ClickHouseClient.php b/src/Client/ClickHouseClient.php index a94f557..6d95c9b 100644 --- a/src/Client/ClickHouseClient.php +++ b/src/Client/ClickHouseClient.php @@ -5,7 +5,6 @@ namespace SimPod\ClickHouseClient\Client; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Exception\CannotInsert; use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Exception\UnsupportedValue; @@ -18,7 +17,6 @@ interface ClickHouseClient * @param array $settings * * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError */ public function executeQuery(string $query, array $settings = []): void; @@ -28,7 +26,6 @@ public function executeQuery(string $query, array $settings = []): void; * @param array $settings * * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError * @throws UnsupportedValue */ @@ -41,7 +38,6 @@ public function executeQueryWithParams(string $query, array $params, array $sett * @return O * * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError * * @template O of Output @@ -56,7 +52,6 @@ public function select(string $query, Format $outputFormat, array $settings = [] * @return O * * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError * @throws UnsupportedValue * @@ -71,7 +66,6 @@ public function selectWithParams(string $query, array $params, Format $outputFor * * @throws CannotInsert * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError */ public function insert(string $table, array $values, array|null $columns = null, array $settings = []): void; diff --git a/src/Snippet/CurrentDatabase.php b/src/Snippet/CurrentDatabase.php index 60a53d0..477c5a2 100644 --- a/src/Snippet/CurrentDatabase.php +++ b/src/Snippet/CurrentDatabase.php @@ -5,7 +5,6 @@ namespace SimPod\ClickHouseClient\Snippet; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Format\JsonEachRow; @@ -14,7 +13,6 @@ final class CurrentDatabase { /** * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError */ public static function run(ClickHouseClient $clickHouseClient): string diff --git a/src/Snippet/DatabaseSize.php b/src/Snippet/DatabaseSize.php index fa159fc..238f587 100644 --- a/src/Snippet/DatabaseSize.php +++ b/src/Snippet/DatabaseSize.php @@ -5,7 +5,6 @@ namespace SimPod\ClickHouseClient\Snippet; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Exception\UnsupportedValue; @@ -16,7 +15,6 @@ final class DatabaseSize { /** * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError * @throws UnsupportedValue */ diff --git a/src/Snippet/Parts.php b/src/Snippet/Parts.php index dc5633a..74a7715 100644 --- a/src/Snippet/Parts.php +++ b/src/Snippet/Parts.php @@ -5,7 +5,6 @@ namespace SimPod\ClickHouseClient\Snippet; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Exception\UnsupportedValue; @@ -19,7 +18,6 @@ final class Parts * @return array> * * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError * @throws UnsupportedValue */ diff --git a/src/Snippet/ShowCreateTable.php b/src/Snippet/ShowCreateTable.php index 28a3c19..e23bea6 100644 --- a/src/Snippet/ShowCreateTable.php +++ b/src/Snippet/ShowCreateTable.php @@ -5,7 +5,6 @@ namespace SimPod\ClickHouseClient\Snippet; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Format\JsonEachRow; @@ -14,7 +13,6 @@ final class ShowCreateTable { /** * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError */ public static function run(ClickHouseClient $clickHouseClient, string $tableName): string diff --git a/src/Snippet/ShowDatabases.php b/src/Snippet/ShowDatabases.php index c95c9d7..186e1ba 100644 --- a/src/Snippet/ShowDatabases.php +++ b/src/Snippet/ShowDatabases.php @@ -5,7 +5,6 @@ namespace SimPod\ClickHouseClient\Snippet; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Format\JsonEachRow; @@ -18,7 +17,6 @@ final class ShowDatabases * @return list * * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError */ public static function run(ClickHouseClient $clickHouseClient): array diff --git a/src/Snippet/TableSizes.php b/src/Snippet/TableSizes.php index e2fb766..b7377d6 100644 --- a/src/Snippet/TableSizes.php +++ b/src/Snippet/TableSizes.php @@ -5,7 +5,6 @@ namespace SimPod\ClickHouseClient\Snippet; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Exception\UnsupportedValue; @@ -19,7 +18,6 @@ final class TableSizes * @return array * * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError * @throws UnsupportedValue */ diff --git a/src/Snippet/Version.php b/src/Snippet/Version.php index 779b962..a78944f 100644 --- a/src/Snippet/Version.php +++ b/src/Snippet/Version.php @@ -5,7 +5,6 @@ namespace SimPod\ClickHouseClient\Snippet; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Exception\ServerError; use SimPod\ClickHouseClient\Format\JsonEachRow; @@ -14,7 +13,6 @@ final class Version { /** * @throws ClientExceptionInterface - * @throws PcreException * @throws ServerError */ public static function run(ClickHouseClient $clickHouseClient): string diff --git a/src/Sql/SqlFactory.php b/src/Sql/SqlFactory.php index 03302a4..cba2085 100644 --- a/src/Sql/SqlFactory.php +++ b/src/Sql/SqlFactory.php @@ -4,12 +4,11 @@ namespace SimPod\ClickHouseClient\Sql; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Exception\UnsupportedValue; use function assert; use function is_string; -use function Safe\preg_replace; +use function preg_replace; use function sprintf; use function str_replace; @@ -23,7 +22,6 @@ public function __construct(private ValueFormatter $valueFormatter) /** * @param array $parameters * - * @throws PcreException * @throws UnsupportedValue */ public function createWithParameters(string $query, array $parameters): string diff --git a/src/Sql/ValueFormatter.php b/src/Sql/ValueFormatter.php index 7bcdde1..4f3ec6f 100644 --- a/src/Sql/ValueFormatter.php +++ b/src/Sql/ValueFormatter.php @@ -7,7 +7,6 @@ use BackedEnum; use DateTimeImmutable; use DateTimeZone; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Exception\UnsupportedValue; use function array_key_first; @@ -20,7 +19,7 @@ use function is_object; use function is_string; use function method_exists; -use function Safe\preg_match; +use function preg_match; use function sprintf; /** @internal */ @@ -30,10 +29,7 @@ public function __construct(private DateTimeZone|null $dateTimeZone = null) { } - /** - * @throws PcreException - * @throws UnsupportedValue - */ + /** @throws UnsupportedValue */ public function format(mixed $value, string|null $paramName = null, string|null $sql = null): string { if (is_string($value)) { diff --git a/tests/Snippet/ShowCreateTableTest.php b/tests/Snippet/ShowCreateTableTest.php index fa1f3ca..eadf83f 100644 --- a/tests/Snippet/ShowCreateTableTest.php +++ b/tests/Snippet/ShowCreateTableTest.php @@ -9,7 +9,7 @@ use SimPod\ClickHouseClient\Tests\TestCaseBase; use SimPod\ClickHouseClient\Tests\WithClient; -use function Safe\preg_replace; +use function preg_replace; use function str_replace; #[CoversClass(ShowCreateTable::class)] diff --git a/tests/WithClient.php b/tests/WithClient.php index 78ad6bd..67d6829 100644 --- a/tests/WithClient.php +++ b/tests/WithClient.php @@ -9,7 +9,6 @@ use PHPUnit\Framework\Attributes\After; use PHPUnit\Framework\Attributes\Before; use Psr\Http\Client\ClientExceptionInterface; -use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Client\ClickHouseAsyncClient; use SimPod\ClickHouseClient\Client\ClickHouseClient; use SimPod\ClickHouseClient\Client\Http\RequestFactory; @@ -52,7 +51,6 @@ public function tearDownDataBase(): void /** * @throws ClientExceptionInterface * @throws InvalidArgumentException - * @throws PcreException * @throws ServerError */ private function restartClickHouseClient(): void