Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Client/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

use const PHP_QUERY_RFC3986;

final class RequestFactory
final readonly class RequestFactory
{
private UriInterface|null $uri;

Expand All @@ -36,7 +36,7 @@
UriFactoryInterface|null $uriFactory = null,
UriInterface|string $uri = '',
) {
if ($uriFactory === null && $uri === '') {

Check warning on line 39 in src/Client/Http/RequestFactory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "LogicalAnd": @@ @@ /** @throws InvalidArgumentException */ public function __construct(private ParamValueConverterRegistry $paramValueConverterRegistry, private RequestFactoryInterface $requestFactory, private StreamFactoryInterface $streamFactory, UriFactoryInterface|null $uriFactory = null, UriInterface|string $uri = '') { - if ($uriFactory === null && $uri === '') { + if ($uriFactory === null || $uri === '') { $uri = null; } elseif (is_string($uri)) { if ($uriFactory === null) {
$uri = null;
} elseif (is_string($uri)) {
if ($uriFactory === null) {
Expand All @@ -62,7 +62,7 @@
);

if ($this->uri === null) {
$uri = $query === '' ? '' : '?' . $query;

Check warning on line 65 in src/Client/Http/RequestFactory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "Ternary": @@ @@ { $query = http_build_query($requestSettings->settings + $additionalOptions, '', '&', PHP_QUERY_RFC3986); if ($this->uri === null) { - $uri = $query === '' ? '' : '?' . $query; + $uri = $query === '' ? '?' . $query : ''; } else { $uriQuery = $this->uri->getQuery(); try {

Check warning on line 65 in src/Client/Http/RequestFactory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ { $query = http_build_query($requestSettings->settings + $additionalOptions, '', '&', PHP_QUERY_RFC3986); if ($this->uri === null) { - $uri = $query === '' ? '' : '?' . $query; + $uri = $query === '' ? '' : '?'; } else { $uriQuery = $this->uri->getQuery(); try {

Check warning on line 65 in src/Client/Http/RequestFactory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ { $query = http_build_query($requestSettings->settings + $additionalOptions, '', '&', PHP_QUERY_RFC3986); if ($this->uri === null) { - $uri = $query === '' ? '' : '?' . $query; + $uri = $query === '' ? '' : $query; } else { $uriQuery = $this->uri->getQuery(); try {

Check warning on line 65 in src/Client/Http/RequestFactory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "Concat": @@ @@ { $query = http_build_query($requestSettings->settings + $additionalOptions, '', '&', PHP_QUERY_RFC3986); if ($this->uri === null) { - $uri = $query === '' ? '' : '?' . $query; + $uri = $query === '' ? '' : $query . '?'; } else { $uriQuery = $this->uri->getQuery(); try {
} else {
$uriQuery = $this->uri->getQuery();
try {
Expand Down Expand Up @@ -95,7 +95,7 @@

/** @var array<string, Type> $paramToType */
$paramToType = array_reduce(
array_keys($matches[1]),

Check warning on line 98 in src/Client/Http/RequestFactory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "IncrementInteger": @@ @@ } } /** @var array<string, Type> $paramToType */ - $paramToType = array_reduce(array_keys($matches[1]), static function (array $acc, string|int $k) use ($matches) { + $paramToType = array_reduce(array_keys($matches[2]), static function (array $acc, string|int $k) use ($matches) { $acc[$matches[1][$k]] = Type::fromString($matches[2][$k]); return $acc; }, []);
static function (array $acc, string|int $k) use ($matches) {
$acc[$matches[1][$k]] = Type::fromString($matches[2][$k]);

Expand All @@ -120,7 +120,7 @@
try {
$body = new MultipartStream($streamElements);
$request = $request->withBody($body)
->withHeader('Content-Type', 'multipart/form-data; boundary=' . $body->getBoundary());

Check warning on line 123 in src/Client/Http/RequestFactory.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ } try { $body = new MultipartStream($streamElements); - $request = $request->withBody($body)->withHeader('Content-Type', 'multipart/form-data; boundary=' . $body->getBoundary()); + $request = $request->withBody($body)->withHeader('Content-Type', 'multipart/form-data; boundary='); } catch (InvalidArgumentException) { absurd(); }
} catch (InvalidArgumentException) {
absurd();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Http/RequestOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimPod\ClickHouseClient\Client\Http;

final class RequestOptions
final readonly class RequestOptions
{
/** @param array<string, mixed> $params */
public function __construct(
Expand Down
2 changes: 1 addition & 1 deletion src/Client/Http/RequestSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimPod\ClickHouseClient\Client\Http;

final class RequestSettings
final readonly class RequestSettings
{
/** @var array<string, float|int|string> */
public array $settings;
Expand Down
2 changes: 1 addition & 1 deletion src/Client/PsrClickHouseAsyncClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use function uniqid;

class PsrClickHouseAsyncClient implements ClickHouseAsyncClient
readonly class PsrClickHouseAsyncClient implements ClickHouseAsyncClient
{
private SqlFactory $sqlFactory;

Expand Down Expand Up @@ -98,7 +98,7 @@
);

$id = uniqid('', true);
$this->sqlLogger?->startQuery($id, $sql);

Check warning on line 101 in src/Client/PsrClickHouseAsyncClient.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ { $request = $this->requestFactory->prepareSqlRequest($sql, new RequestSettings($this->defaultSettings, $settings), new RequestOptions($params)); $id = uniqid('', true); - $this->sqlLogger?->startQuery($id, $sql); + return Create::promiseFor($this->asyncClient->sendAsyncRequest($request))->then(function (ResponseInterface $response) use ($id, $processResponse) { $this->sqlLogger?->stopQuery($id); if ($response->getStatusCode() !== 200) {

return Create::promiseFor(
$this->asyncClient->sendAsyncRequest($request),
Expand All @@ -117,7 +117,7 @@

return $processResponse($response);
},
fn () => $this->sqlLogger?->stopQuery($id),

Check warning on line 120 in src/Client/PsrClickHouseAsyncClient.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "NullSafeMethodCall": @@ @@ return $response; } return $processResponse($response); - }, fn() => $this->sqlLogger?->stopQuery($id)); + }, fn() => $this->sqlLogger->stopQuery($id)); } }
);
}
}
2 changes: 1 addition & 1 deletion src/Client/PsrClickHouseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use function sprintf;
use function uniqid;

class PsrClickHouseClient implements ClickHouseClient
readonly class PsrClickHouseClient implements ClickHouseClient
{
private ValueFormatter $valueFormatter;

Expand Down Expand Up @@ -64,7 +64,7 @@

public function executeQueryWithParams(string $query, array $params, array $settings = []): void
{
$this->executeRequest(

Check warning on line 67 in src/Client/PsrClickHouseClient.php

View workflow job for this annotation

GitHub Actions / Infection

Escaped Mutant for Mutator "MethodCallRemoval": @@ @@ } public function executeQueryWithParams(string $query, array $params, array $settings = []): void { - $this->executeRequest($this->sqlFactory->createWithParameters($query, $params), params: $params, settings: $settings); + } public function select(string $query, Format $outputFormat, array $settings = []): Output {
$this->sqlFactory->createWithParameters($query, $params),
params: $params,
settings: $settings,
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @template T
* @implements Format<\SimPod\ClickHouseClient\Output\Json<T>>
*/
final class Json implements Format
final readonly class Json implements Format
{
/** @throws JsonException */
public static function output(string $contents): Output
Expand Down
2 changes: 1 addition & 1 deletion src/Format/JsonCompact.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @template T
* @implements Format<\SimPod\ClickHouseClient\Output\JsonCompact<T>>
*/
final class JsonCompact implements Format
final readonly class JsonCompact implements Format
{
/** @throws JsonException */
public static function output(string $contents): Output
Expand Down
2 changes: 1 addition & 1 deletion src/Format/JsonEachRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @template T
* @implements Format<\SimPod\ClickHouseClient\Output\JsonEachRow<T>>
*/
final class JsonEachRow implements Format
final readonly class JsonEachRow implements Format
{
/** @throws JsonException */
public static function output(string $contents): Output
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Null_.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @template T
* @implements Format<\SimPod\ClickHouseClient\Output\Null_<T>>
*/
final class Null_ implements Format
final readonly class Null_ implements Format
{
public static function output(string $contents): Output
{
Expand Down
2 changes: 1 addition & 1 deletion src/Format/Pretty.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @template T
* @implements Format<Basic<T>>
*/
final class Pretty implements Format
final readonly class Pretty implements Format
{
public static function output(string $contents): Output
{
Expand Down
2 changes: 1 addition & 1 deletion src/Format/PrettySpace.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @template T
* @implements Format<Basic<T>>
*/
final class PrettySpace implements Format
final readonly class PrettySpace implements Format
{
public static function output(string $contents): Output
{
Expand Down
2 changes: 1 addition & 1 deletion src/Format/RowBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @template T
* @implements Format<Basic<T>>
*/
final class RowBinary implements Format
final readonly class RowBinary implements Format
{
public static function output(string $contents): Output
{
Expand Down
2 changes: 1 addition & 1 deletion src/Format/TabSeparated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @template T
* @implements Format<Basic<T>>
*/
final class TabSeparated implements Format
final readonly class TabSeparated implements Format
{
public static function output(string $contents): Output
{
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/LoggerChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimPod\ClickHouseClient\Logger;

final class LoggerChain implements SqlLogger
final readonly class LoggerChain implements SqlLogger
{
/** @param SqlLogger[] $loggers */
public function __construct(private array $loggers = [])
Expand Down
2 changes: 1 addition & 1 deletion src/Logger/PsrLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Psr\Log\LoggerInterface;

final class PsrLogger implements SqlLogger
final readonly class PsrLogger implements SqlLogger
{
public function __construct(private LoggerInterface $logger)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @template T
* @implements Output<T>
*/
final class Basic implements Output
final readonly class Basic implements Output
{
public function __construct(public string $contents)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @template T
* @implements Output<T>
*/
final class Json implements Output
final readonly class Json implements Output
{
/** @var list<T> */
public array $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Output/JsonCompact.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @template T
* @implements Output<T>
*/
final class JsonCompact implements Output
final readonly class JsonCompact implements Output
{
/** @var list<T> */
public array $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Output/JsonEachRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @template T
* @implements Output<T>
*/
final class JsonEachRow implements Output
final readonly class JsonEachRow implements Output
{
/** @var list<T> */
public array $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Null_.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @template T
* @implements Output<T>
*/
final class Null_ implements Output
final readonly class Null_ implements Output
{
public function __construct(string $_)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Param/ParamValueConverterRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
* @phpstan-type Converter Closure(mixed, Type|string|null, bool):(StreamInterface|string)
* @phpstan-type ConverterRegistry array<string, Converter>
*/
final class ParamValueConverterRegistry
final readonly class ParamValueConverterRegistry
{
private const CaseInsensitiveTypes = [
private const array CaseInsensitiveTypes = [
'bool',
'date',
'date32',
Expand Down
2 changes: 1 addition & 1 deletion src/Snippet/CurrentDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use SimPod\ClickHouseClient\Exception\ServerError;
use SimPod\ClickHouseClient\Format\JsonEachRow;

final class CurrentDatabase
final readonly class CurrentDatabase
{
/**
* @throws ClientExceptionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Snippet/DatabaseSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use SimPod\ClickHouseClient\Format\JsonEachRow;
use SimPod\ClickHouseClient\Sql\Expression;

final class DatabaseSize
final readonly class DatabaseSize
{
/**
* @throws ClientExceptionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Snippet/Parts.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use function sprintf;

final class Parts
final readonly class Parts
{
/**
* @return array<array<string, mixed>>
Expand Down
2 changes: 1 addition & 1 deletion src/Snippet/ShowCreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use SimPod\ClickHouseClient\Exception\ServerError;
use SimPod\ClickHouseClient\Format\JsonEachRow;

final class ShowCreateTable
final readonly class ShowCreateTable
{
/**
* @throws ClientExceptionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Snippet/ShowDatabases.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use function array_map;

final class ShowDatabases
final readonly class ShowDatabases
{
/**
* @return list<string>
Expand Down
2 changes: 1 addition & 1 deletion src/Snippet/TableSizes.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use SimPod\ClickHouseClient\Sql\Expression;

/** @phpstan-type Entry array{table: string, database: string, size: string, min_date: string, max_date: string} */
final class TableSizes
final readonly class TableSizes
{
/**
* @return array<Entry>
Expand Down
2 changes: 1 addition & 1 deletion src/Snippet/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use SimPod\ClickHouseClient\Exception\ServerError;
use SimPod\ClickHouseClient\Format\JsonEachRow;

final class Version
final readonly class Version
{
/**
* @throws ClientExceptionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Sql/Escaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @link https://github.com/ClickHouse/clickhouse-jdbc/blob/8481c1323f5de09bb9dbbf67085e5e1b2585756a/src/main/java/ru/yandex/clickhouse/ClickHouseUtil.java
*/
final class Escaper
final readonly class Escaper
{
public static function escape(string $s): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Sql/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimPod\ClickHouseClient\Sql;

final class Expression
final readonly class Expression
{
public string $innerExpression;

Expand Down
2 changes: 1 addition & 1 deletion src/Sql/SqlFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use function str_replace;

/** @internal */
final class SqlFactory
final readonly class SqlFactory
{
public function __construct(private ValueFormatter $valueFormatter)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/ClickHouseVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

use const STR_PAD_LEFT;

final class ClickHouseVersion
final readonly class ClickHouseVersion
{
private const EnvName = 'CLICKHOUSE_VERSION';
private const string EnvName = 'CLICKHOUSE_VERSION';

/** @throws RuntimeException */
public static function get(): int
Expand Down