Skip to content

Commit b6f8e3c

Browse files
committed
fix cs by Doctrine style
1 parent 3133b2f commit b6f8e3c

9 files changed

+386
-397
lines changed

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
],
1414
"require": {
1515
"php": "^7.1",
16+
"ext-PDO": "*",
17+
"ext-pcre": "*",
1618
"smi2/phpClickHouse": "^1.0",
1719
"doctrine/dbal": "^2.7"
1820
},

src/ClickHouseConnection.php

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/*
36
* This file is part of the FODDBALClickHouse package -- Doctrine DBAL library
47
* for ClickHouse (a column-oriented DBMS for OLAP <https://clickhouse.yandex/>)
@@ -12,38 +15,30 @@
1215
namespace FOD\DBALClickHouse;
1316

1417
use ClickHouseDB\Client as Smi2CHClient;
18+
use Doctrine\DBAL\Driver\Connection;
1519
use Doctrine\DBAL\ParameterType;
1620
use Doctrine\DBAL\Platforms\AbstractPlatform;
1721

1822
/**
1923
* ClickHouse implementation for the Connection interface.
20-
*
21-
* @author Mochalygin <[email protected]>
2224
*/
23-
class ClickHouseConnection implements \Doctrine\DBAL\Driver\Connection
25+
class ClickHouseConnection implements Connection
2426
{
25-
/**
26-
* @var Smi2CHClient
27-
*/
27+
/** @var Smi2CHClient */
2828
protected $smi2CHClient;
2929

30-
/**
31-
* @var AbstractPlatform
32-
*/
30+
/** @var AbstractPlatform */
3331
protected $platform;
3432

3533
/**
3634
* Connection constructor
3735
*
38-
* @param array $params
39-
* @param string $username The username to use when connecting.
40-
* @param string $password The password to use when connecting.
41-
* @param AbstractPlatform $platform
36+
* @param array $params Array with connection params.
4237
*/
4338
public function __construct(
4439
array $params,
45-
$username,
46-
$password,
40+
string $username,
41+
string $password,
4742
AbstractPlatform $platform
4843
) {
4944
$this->smi2CHClient = new Smi2CHClient([
@@ -64,10 +59,6 @@ public function __construct(
6459
*/
6560
public function prepare($prepareString)
6661
{
67-
if (!$this->smi2CHClient) {
68-
throw new \Exception('ClickHouse\Client was not initialized');
69-
}
70-
7162
return new ClickHouseStatement($this->smi2CHClient, $prepareString, $this->platform);
7263
}
7364

@@ -88,7 +79,7 @@ public function query()
8879
*/
8980
public function quote($input, $type = ParameterType::STRING)
9081
{
91-
if (ParameterType::INTEGER === $type) {
82+
if ($type === ParameterType::INTEGER) {
9283
return $input;
9384
}
9485

@@ -98,7 +89,7 @@ public function quote($input, $type = ParameterType::STRING)
9889
/**
9990
* {@inheritDoc}
10091
*/
101-
public function exec($statement)
92+
public function exec($statement) : int
10293
{
10394
$stmt = $this->prepare($statement);
10495
$stmt->execute();

src/ClickHouseException.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/*
36
* This file is part of the FODDBALClickHouse package -- Doctrine DBAL library
47
* for ClickHouse (a column-oriented DBMS for OLAP <https://clickhouse.yandex/>)
@@ -13,8 +16,6 @@
1316

1417
/**
1518
* Specific Exception for ClickHouse
16-
*
17-
* @author Mochalygin <[email protected]>
1819
*/
1920
class ClickHouseException extends \Exception
2021
{

src/ClickHouseKeywords.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
declare(strict_types=1);
4+
25
/*
36
* This file is part of the FODDBALClickHouse package -- Doctrine DBAL library
47
* for ClickHouse (a column-oriented DBMS for OLAP <https://clickhouse.yandex/>)
@@ -15,23 +18,21 @@
1518

1619
/**
1720
* ClickHouse Keywordlist
18-
*
19-
* @author Mochalygin <[email protected]>
2021
*/
2122
class ClickHouseKeywords extends KeywordList
2223
{
2324
/**
2425
* {@inheritdoc}
2526
*/
26-
public function getName()
27+
public function getName() : string
2728
{
2829
return 'ClickHouse';
2930
}
3031

3132
/**
3233
* {@inheritdoc}
3334
*/
34-
protected function getKeywords()
35+
protected function getKeywords() : array
3536
{
3637
//TODO actualize it!
3738
return [

0 commit comments

Comments
 (0)