Skip to content

Commit ebb4106

Browse files
committed
fix cs by Doctrine guide
1 parent c81170d commit ebb4106

File tree

3 files changed

+117
-63
lines changed

3 files changed

+117
-63
lines changed

src/ClickHouseConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ClickHouseConnection implements Connection, PingableConnection, ServerInfo
3838
/**
3939
* Connection constructor
4040
*
41-
* @param array $params Array with connection params.
41+
* @param mixed[] $params
4242
*/
4343
public function __construct(
4444
array $params,

src/ClickHousePlatform.php

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ class ClickHousePlatform extends AbstractPlatform
6969
public function getBooleanTypeDeclarationSQL(array $columnDef) : string
7070
{
7171
return $this->prepareDeclarationSQL(
72-
UnsignedNumericalClickHouseType::UNSIGNED_CHAR . NumericalClickHouseType::TYPE_INT . BitNumericalClickHouseType::EIGHT_BIT,
72+
UnsignedNumericalClickHouseType::UNSIGNED_CHAR .
73+
NumericalClickHouseType::TYPE_INT . BitNumericalClickHouseType::EIGHT_BIT,
7374
$columnDef
7475
);
7576
}
@@ -80,7 +81,8 @@ public function getBooleanTypeDeclarationSQL(array $columnDef) : string
8081
public function getIntegerTypeDeclarationSQL(array $columnDef) : string
8182
{
8283
return $this->prepareDeclarationSQL(
83-
$this->_getCommonIntegerTypeDeclarationSQL($columnDef) . NumericalClickHouseType::TYPE_INT . BitNumericalClickHouseType::THIRTY_TWO_BIT,
84+
$this->_getCommonIntegerTypeDeclarationSQL($columnDef) .
85+
NumericalClickHouseType::TYPE_INT . BitNumericalClickHouseType::THIRTY_TWO_BIT,
8486
$columnDef
8587
);
8688
}
@@ -99,7 +101,8 @@ public function getBigIntTypeDeclarationSQL(array $columnDef) : string
99101
public function getSmallIntTypeDeclarationSQL(array $columnDef) : string
100102
{
101103
return $this->prepareDeclarationSQL(
102-
$this->_getCommonIntegerTypeDeclarationSQL($columnDef) . NumericalClickHouseType::TYPE_INT . BitNumericalClickHouseType::SIXTEEN_BIT,
104+
$this->_getCommonIntegerTypeDeclarationSQL($columnDef) .
105+
NumericalClickHouseType::TYPE_INT . BitNumericalClickHouseType::SIXTEEN_BIT,
103106
$columnDef
104107
);
105108
}
@@ -199,6 +202,9 @@ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) : string
199202
: StringClickHouseType::TYPE_STRING;
200203
}
201204

205+
/**
206+
* {@inheritDoc}
207+
*/
202208
public function getVarcharTypeDeclarationSQL(array $field)
203209
{
204210
if (! isset($field['length'])) {
@@ -730,7 +736,8 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options
730736
$eventDateColumnName = $options['eventDateColumn'];
731737
}
732738
$dateColumnParams['name'] = $eventDateColumnName;
733-
$columns = [$eventDateColumnName => $dateColumnParams] + $columns; // insert into very beginning
739+
// insert into very beginning
740+
$columns = [$eventDateColumnName => $dateColumnParams] + $columns;
734741

735742
/**
736743
* Primary key section
@@ -762,7 +769,8 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options
762769
! $columns[$options['versionColumn']]['type'] instanceof DateTimeType
763770
) {
764771
throw new \Exception(
765-
'For ReplacingMergeTree tables `versionColumn` must be any of UInt* family, or Date, or DateTime types. ' .
772+
'For ReplacingMergeTree tables `versionColumn` must be any of UInt* family,
773+
or Date, or DateTime types. ' .
766774
get_class($columns[$options['versionColumn']]['type']) . ' given.'
767775
);
768776
}
@@ -773,10 +781,13 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options
773781
$engineOptions .= ')';
774782
}
775783

776-
$columnListSql = $this->getColumnDeclarationListSQL($columns);
777-
$query = 'CREATE TABLE ' . $tableName . ' (' . $columnListSql . ') ENGINE = ' . $engine . $engineOptions;
778-
779-
$sql[] = $query;
784+
$sql[] = sprintf(
785+
'CREATE TABLE %s (%s) ENGINE = %s%s',
786+
$tableName,
787+
$this->getColumnDeclarationListSQL($columns),
788+
$engine,
789+
$engineOptions
790+
);
780791

781792
return $sql;
782793
}
@@ -884,6 +895,9 @@ protected function _getAlterTableIndexForeignKeySQL(TableDiff $diff)
884895
throw DBALException::notSupported(__METHOD__);
885896
}
886897

898+
/**
899+
* @param mixed[] $columnDef
900+
*/
887901
protected function prepareDeclarationSQL(string $declarationSQL, array $columnDef) : string
888902
{
889903
if (array_key_exists('notnull', $columnDef) && $columnDef['notnull'] === false) {
@@ -1019,7 +1033,10 @@ public function getListDatabasesSQL() : string
10191033
*/
10201034
public function getListTableColumnsSQL($table, $database = null) : string
10211035
{
1022-
return 'DESCRIBE TABLE ' . ($database ? $this->quoteSingleIdentifier($database) . '.' : '') . $this->quoteSingleIdentifier($table);
1036+
return sprintf(
1037+
'DESCRIBE TABLE %s',
1038+
($database ? $this->quoteSingleIdentifier($database) . '.' : '') . $this->quoteSingleIdentifier($table)
1039+
);
10231040
}
10241041

10251042
/**
@@ -1078,6 +1095,9 @@ public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration) : strin
10781095
return $this->prepareDeclarationSQL(DatableClickHouseType::TYPE_DATE_TIME, $fieldDeclaration);
10791096
}
10801097

1098+
/**
1099+
* {@inheritDoc}
1100+
*/
10811101
public function getTimeTypeDeclarationSQL(array $fieldDeclaration) : string
10821102
{
10831103
return $this->prepareDeclarationSQL(StringClickHouseType::TYPE_STRING, $fieldDeclaration);
@@ -1234,17 +1254,25 @@ public function getDefaultValueDeclarationSQL($field) : string
12341254
return '';
12351255
}
12361256

1237-
$default = " DEFAULT '" . $field['default'] . "'";
1238-
if ($fieldType = (string) ($field['type'] ?? null)) {
1257+
$default = " DEFAULT '" . $field['default'] . "'";
1258+
$fieldType = $field['type'] ?? null;
1259+
if ($fieldType !== null) {
12391260
if (in_array($fieldType, [
12401261
'Integer',
12411262
'SmallInt',
12421263
'Float',
1243-
]) || ($fieldType === 'BigInt' && Type::getType('BigInt')->getBindingType() === ParameterType::INTEGER)) {
1264+
]) ||
1265+
(
1266+
$fieldType === 'BigInt'
1267+
&& Type::getType('BigInt')->getBindingType() === ParameterType::INTEGER)
1268+
) {
12441269
$default = ' DEFAULT ' . $field['default'];
1245-
} elseif ($fieldType === DatableClickHouseType::TYPE_DATE_TIME && $field['default'] === $this->getCurrentTimestampSQL()) {
1270+
} elseif ($fieldType === DatableClickHouseType::TYPE_DATE_TIME &&
1271+
$field['default'] === $this->getCurrentTimestampSQL()
1272+
) {
12461273
$default = ' DEFAULT ' . $this->getCurrentTimestampSQL();
1247-
} elseif ($fieldType === DatableClickHouseType::TYPE_DATE) { // TODO check if string matches constant date like 'dddd-yy-mm' and quote it
1274+
} elseif (// TODO check if string matches constant date like 'dddd-yy-mm' and quote it
1275+
$fieldType === DatableClickHouseType::TYPE_DATE) {
12481276
$default = ' DEFAULT ' . $field['default'];
12491277
}
12501278
}

0 commit comments

Comments
 (0)