Skip to content

Commit 9a55ebb

Browse files
committed
fix testGetServerVersion
1 parent 5019663 commit 9a55ebb

10 files changed

+48
-31
lines changed

src/Types/ArrayDateTimeType.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616

1717
use Doctrine\DBAL\ParameterType;
1818
use Doctrine\DBAL\Platforms\AbstractPlatform;
19+
use function array_filter;
20+
use function array_map;
21+
use function implode;
1922

2023
/**
2124
* Array(DateTime) Type class
2225
*/
23-
class ArrayDateTimeType extends AbstractArrayType implements DatableTypeInterface
26+
class ArrayDateTimeType extends ArrayType implements DatableType
2427
{
25-
public function getBaseClickHouseType(): string
28+
public function getBaseClickHouseType() : string
2629
{
27-
return DatableTypeInterface::TYPE_DATE_TIME;
30+
return DatableType::TYPE_DATE_TIME;
2831
}
2932

3033
/**
@@ -35,7 +38,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
3538
return array_map(
3639
function ($stringDatetime) use ($platform) {
3740
return \DateTime::createFromFormat($platform->getDateTimeFormatString(), $stringDatetime);
38-
}, (array) $value
41+
},
42+
(array) $value
3943
);
4044
}
4145

@@ -49,8 +53,10 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
4953
array_map(
5054
function (\DateTime $datetime) use ($platform) {
5155
return "'" . $datetime->format($platform->getDateTimeFormatString()) . "'";
52-
}, array_filter(
53-
(array) $value, function ($datetime) {
56+
},
57+
array_filter(
58+
(array) $value,
59+
function ($datetime) {
5460
return $datetime instanceof \DateTime;
5561
}
5662
)

src/Types/ArrayDateType.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616

1717
use Doctrine\DBAL\ParameterType;
1818
use Doctrine\DBAL\Platforms\AbstractPlatform;
19+
use function array_filter;
20+
use function array_map;
21+
use function implode;
1922

2023
/**
2124
* Array(Date) Type class
2225
*/
23-
class ArrayDateType extends AbstractArrayType implements DatableTypeInterface
26+
class ArrayDateType extends ArrayType implements DatableType
2427
{
25-
public function getBaseClickHouseType(): string
28+
public function getBaseClickHouseType() : string
2629
{
27-
return DatableTypeInterface::TYPE_DATE;
30+
return DatableType::TYPE_DATE;
2831
}
2932

3033
/**
@@ -35,7 +38,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
3538
return array_map(
3639
function ($stringDatetime) use ($platform) {
3740
return \DateTime::createFromFormat($platform->getDateFormatString(), $stringDatetime);
38-
}, (array) $value
41+
},
42+
(array) $value
3943
);
4044
}
4145

@@ -49,8 +53,10 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
4953
array_map(
5054
function (\DateTime $datetime) use ($platform) {
5155
return "'" . $datetime->format($platform->getDateFormatString()) . "'";
52-
}, array_filter(
53-
(array) $value, function ($datetime) {
56+
},
57+
array_filter(
58+
(array) $value,
59+
function ($datetime) {
5460
return $datetime instanceof \DateTime;
5561
}
5662
)

src/Types/AbstractArrayType.php renamed to src/Types/ArrayType.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Doctrine\DBAL\DBALException;
1818
use Doctrine\DBAL\Platforms\AbstractPlatform;
1919
use Doctrine\DBAL\Types\Type;
20+
use function array_key_exists;
21+
use function sprintf;
22+
use function strtolower;
2023

2124
/**
2225
* Array(*) Types basic class
@@ -44,7 +47,7 @@ abstract class AbstractArrayType extends Type implements BaseClickHouseTypeInter
4447
*
4548
* @throws DBALException
4649
*/
47-
public static function registerArrayTypes(AbstractPlatform $platform): void
50+
public static function registerArrayTypes(AbstractPlatform $platform) : void
4851
{
4952
foreach (self::ARRAY_TYPES as $typeName => $className) {
5053
if (self::hasType($typeName)) {
@@ -61,28 +64,31 @@ public static function registerArrayTypes(AbstractPlatform $platform): void
6164
/**
6265
* {@inheritDoc}
6366
*/
64-
public function getMappedDatabaseTypes(AbstractPlatform $platform): array
67+
public function getMappedDatabaseTypes(AbstractPlatform $platform) : array
6568
{
6669
return [$this->getName()];
6770
}
6871

6972
/**
7073
* {@inheritDoc}
7174
*/
72-
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
75+
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform) : string
7376
{
7477
return $this->getDeclaration($fieldDeclaration);
7578
}
7679

7780
/**
7881
* {@inheritDoc}
7982
*/
80-
public function getName(): string
83+
public function getName() : string
8184
{
8285
return strtolower($this->getDeclaration());
8386
}
8487

85-
protected function getDeclaration(array $fieldDeclaration = []): string
88+
/**
89+
* @param mixed[] $fieldDeclaration
90+
*/
91+
protected function getDeclaration(array $fieldDeclaration = []) : string
8692
{
8793
return sprintf(
8894
array_key_exists(

src/Types/BitInterface.php renamed to src/Types/BitNumericalClickHouseType.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
namespace FOD\DBALClickHouse\Types;
1616

17-
interface BitInterface extends NumericalTypeInterface
17+
interface BitNumericalType extends NumericalType
1818
{
19-
public const EIGHT_BIT = 8;
20-
public const SIXTEEN_BIT = 16;
19+
public const EIGHT_BIT = 8;
20+
public const SIXTEEN_BIT = 16;
2121
public const THIRTY_TWO_BIT = 32;
2222
public const SIXTY_FOUR_BIT = 64;
2323

24-
public function getBits(): int;
24+
public function getBits() : int;
2525
}

src/Types/BaseClickHouseTypeInterface.php renamed to src/Types/ClickHouseType.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
namespace FOD\DBALClickHouse\Types;
1616

17-
1817
interface BaseClickHouseTypeInterface
1918
{
20-
public function getBaseClickHouseType(): string;
19+
public function getBaseClickHouseType() : string;
2120
}

src/Types/DatableTypeInterface.php renamed to src/Types/DatableClickHouseType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
namespace FOD\DBALClickHouse\Types;
1616

17-
interface DatableTypeInterface extends BaseClickHouseTypeInterface
17+
interface DatableType extends ClickHouseType
1818
{
19-
public const TYPE_DATE = 'Date';
19+
public const TYPE_DATE = 'Date';
2020
public const TYPE_DATE_TIME = 'DateTime';
2121
}

src/Types/NumericalTypeInterface.php renamed to src/Types/NumericalClickHouseType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
namespace FOD\DBALClickHouse\Types;
1616

17-
interface NumericalTypeInterface extends BaseClickHouseTypeInterface
17+
interface NumericalType extends ClickHouseType
1818
{
19-
public const TYPE_INT = 'Int';
19+
public const TYPE_INT = 'Int';
2020
public const TYPE_FLOAT = 'Float';
2121
}

src/Types/StringTypeInterface.php renamed to src/Types/StringClickHouseType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
namespace FOD\DBALClickHouse\Types;
1616

17-
interface StringTypeInterface extends BaseClickHouseTypeInterface
17+
interface StringType extends ClickHouseType
1818
{
19-
public const TYPE_STRING = 'String';
19+
public const TYPE_STRING = 'String';
2020
public const TYPE_FIXED_STRING = 'FixedString';
2121
}

src/Types/UnsignedInterface.php renamed to src/Types/UnsignedNumericalClickHouseType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace FOD\DBALClickHouse\Types;
1616

17-
interface UnsignedInterface extends NumericalTypeInterface
17+
interface UnsignedNumericalType extends NumericalType
1818
{
1919
public const UNSIGNED_CHAR = 'U';
2020
}

tests/ConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function testGetServerVersion()
150150
{
151151
$conn = $this->connection->getWrappedConnection();
152152
if ($conn instanceof ServerInfoAwareConnection) {
153-
$this->assertRegExp('/(^[0-9]+.[0-9]+.[0-9]+.[0-9]$)/mi', $conn->getServerVersion());
153+
$this->assertRegExp('/(^[0-9]+.[0-9]+.[0-9]+(.[0-9]$|$))/mi', $conn->getServerVersion());
154154
} else {
155155
$this->fail(sprintf('`%s` does not implement the `%s` interface', \get_class($conn),
156156
ServerInfoAwareConnection::class));

0 commit comments

Comments
 (0)