From 8041f3faf84ed29c91206530912dc44028b43873 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 15 Jan 2024 09:16:21 +0100 Subject: [PATCH] chore(deps): remove thecodingmachine/phpstan-safe-rule --- composer.json | 1 - phpstan.neon.dist | 3 --- src/Sql/SqlFactory.php | 4 ++++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index fe819a7..3878704 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,6 @@ "psalm/plugin-phpunit": "0.18.4", "roave/infection-static-analysis-plugin": "^1.6", "symfony/http-client": "^7.0", - "thecodingmachine/phpstan-safe-rule": "^1.0", "vimeo/psalm": "^5.0.0" }, "autoload": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b34e9c3..44c9e90 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -15,9 +15,6 @@ parameters: # There's no other way to test-pass without assertions while counting it towards coverage https://github.com/sebastianbergmann/phpunit/issues/3016 - '~Call to static method PHPUnit\\Framework\\Assert::assertTrue\(\) with true will always evaluate to true~' - # Adds unnecessary maintanence overhead. We rather rely on PHPStan telling us the method returns unhandled FALSE - - "~Class DateTime(Immutable)? is unsafe to use. Its methods can return FALSE instead of throwing an exception. Please add 'use Safe\\\\DateTime(Immutable)?;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library~" - # No need to have @throws in some phpunit related methods - message: "~Method SimPod\\\\ClickHouseClient\\\\Tests\\\\.+?Test(CaseBase)?::(test.+?|provider.+?|setUp(BeforeClass)?|tearDown|setupClickHouseClient|tearDownDataBase)\\(\\) throws checked exception .+? but it's missing from the PHPDoc @throws tag~" path: tests diff --git a/src/Sql/SqlFactory.php b/src/Sql/SqlFactory.php index deb9247..03302a4 100644 --- a/src/Sql/SqlFactory.php +++ b/src/Sql/SqlFactory.php @@ -7,6 +7,8 @@ use Safe\Exceptions\PcreException; use SimPod\ClickHouseClient\Exception\UnsupportedValue; +use function assert; +use function is_string; use function Safe\preg_replace; use function sprintf; use function str_replace; @@ -33,9 +35,11 @@ public function createWithParameters(string $query, array $parameters): string str_replace('\\', '\\\\', $this->valueFormatter->format($value, $name, $query)), $query, ); + assert(is_string($query)); } $query = preg_replace('~ ?=([\s]*?)IS NULL~', '$1IS NULL', $query); + assert(is_string($query)); return $query; }