Query   A
last analyzed

Complexity

Total Complexity 22

Size/Duplication

Total Lines 154
Duplicated Lines 0 %

Test Coverage

Coverage 88.24%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
eloc 57
dl 0
loc 154
ccs 30
cts 34
cp 0.8824
rs 10
c 5
b 1
f 0
wmc 22

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setFormat() 0 3 1
A __construct() 0 8 2
A applyFormatQuery() 0 25 5
A getUrlBindingsParams() 0 19 6
A __toString() 0 3 1
A getFormat() 0 3 1
A toSql() 0 17 5
A isUseInUrlBindingsParams() 0 4 1
1
<?php
0 ignored issues
show
introduced by
Missing declare(strict_types=1).
Loading history...
2
3
namespace ClickHouseDB\Query;
4
5
use ClickHouseDB\Exception\QueryException;
6
use function sizeof;
0 ignored issues
show
introduced by
Expected 1 lines between different types of use statement, found 0.
Loading history...
7
8
class Query
9
{
10
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Query\Query::$sql with single line content, use one-line comment instead.
Loading history...
11
     * @var string
12
     */
13
    protected $sql;
14
15
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Query\Query::$format with single line content, use one-line comment instead.
Loading history...
16
     * @var string|null
17
     */
18
    protected $format = null;
19
20
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Query\Query::$degenerations with single line content, use one-line comment instead.
Loading history...
21
     * @var array
0 ignored issues
show
introduced by
@var annotation of property \ClickHouseDB\Query\Query::$degenerations does not specify type hint for its items.
Loading history...
22
     */
23
    private $degenerations = [];
24
25
    private $supportFormats=[
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces
Loading history...
introduced by
Property \ClickHouseDB\Query\Query::$supportFormats does not have @var annotation for its value.
Loading history...
Coding Style introduced by
Expected at least 1 space before "="; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "="; 0 found
Loading history...
26
        "FORMAT\\s+TSVRaw",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TSVRaw does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
27
        "FORMAT\\s+TSVWithNamesAndTypes",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TSVWithNamesAndTypes does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
28
        "FORMAT\\s+TSVWithNames",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TSVWithNames does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
29
        "FORMAT\\s+TSV",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TSV does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
30
        "FORMAT\\s+Vertical",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+Vertical does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
31
        "FORMAT\\s+JSONCompact",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+JSONCompact does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
32
        "FORMAT\\s+JSONEachRow",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+JSONEachRow does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
33
        "FORMAT\\s+TSKV",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TSKV does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
34
        "FORMAT\\s+TabSeparatedWithNames",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TabSeparatedWithNames does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
35
        "FORMAT\\s+TabSeparatedWithNamesAndTypes",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TabSeparatedWithNamesAndTypes does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
36
        "FORMAT\\s+TabSeparatedRaw",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TabSeparatedRaw does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
37
        "FORMAT\\s+BlockTabSeparated",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+BlockTabSeparated does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
38
        "FORMAT\\s+CSVWithNames",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+CSVWithNames does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
39
        "FORMAT\\s+CSV",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+CSV does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
40
        "FORMAT\\s+JSON",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+JSON does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
41
        "FORMAT\\s+TabSeparated"
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal FORMAT\\s+TabSeparated does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
introduced by
Multi-line arrays must have a trailing comma after the last element.
Loading history...
42
    ];
43
44
    /**
45
     * Query constructor.
0 ignored issues
show
introduced by
Documentation comment contains forbidden comment "Query constructor.".
Loading history...
46
     * @param string $sql
0 ignored issues
show
introduced by
Expected 1 lines between description and annotations, found 0.
Loading history...
47
     * @param array $degenerations
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
introduced by
@param annotation of method \ClickHouseDB\Query\Query::__construct() does not specify type hint for items of its traversable parameter $degenerations.
Loading history...
48
     */
49 46
    public function __construct($sql, $degenerations = [])
0 ignored issues
show
introduced by
Method \ClickHouseDB\Query\Query::__construct() does not have native type hint for its parameter $sql but it should be possible to add it based on @param annotation "string".
Loading history...
introduced by
Method \ClickHouseDB\Query\Query::__construct() does not have native type hint for its parameter $degenerations but it should be possible to add it based on @param annotation "array".
Loading history...
50
    {
51 46
        if (!trim($sql))
0 ignored issues
show
introduced by
Function trim() should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Expected 1 lines after "if", found 0.
Loading history...
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
52
        {
53 1
            throw new QueryException('Empty Query');
54
        }
55 45
        $this->sql = $sql;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
56 45
        $this->degenerations = $degenerations;
57 45
    }
58
59
    /**
60
     * @param string|null $format
61
     */
62 39
    public function setFormat($format)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Query\Query::setFormat() does not have native type hint for its parameter $format but it should be possible to add it based on @param annotation "string|null".
Loading history...
introduced by
Method \ClickHouseDB\Query\Query::setFormat() does not have void return type hint.
Loading history...
63
    {
64 39
        $this->format = $format;
65 39
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
66
67
68 39
    private function applyFormatQuery()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Query\Query::applyFormatQuery() does not have return type hint nor @return annotation for its return value.
Loading history...
69
    {
70
        // FORMAT\s(\w)*$
71 39
        if (null === $this->format) {
0 ignored issues
show
introduced by
Yoda comparisons are disallowed.
Loading history...
introduced by
Expected 1 lines after "if", found 0.
Loading history...
72
            return false;
73
        }
74 39
        $supportFormats = implode("|",$this->supportFormats);
0 ignored issues
show
introduced by
Function implode() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style Comprehensibility introduced by
The string literal | does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
75
76 39
        $this->sql = trim($this->sql);
0 ignored issues
show
introduced by
Function trim() should not be referenced via a fallback global name, but via a use statement.
Loading history...
77 39
        if (substr($this->sql, -1) == ';') {
0 ignored issues
show
introduced by
Function substr() should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Operator == is disallowed, use === instead.
Loading history...
78
            $this->sql = substr($this->sql, 0, -1);
0 ignored issues
show
introduced by
Function substr() should not be referenced via a fallback global name, but via a use statement.
Loading history...
79
        }
80
81 39
        $matches = [];
82 39
        if (preg_match_all('%(' . $supportFormats . ')%ius', $this->sql, $matches)) {
0 ignored issues
show
introduced by
Function preg_match_all() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
introduced by
Expected 0 lines after "if", found 6.
Loading history...
83
84
            // skip add "format json"
85 2
            if (isset($matches[0]))
86
            {
0 ignored issues
show
Coding Style introduced by
Blank line found at start of control structure
Loading history...
87
88 2
                $this->format = trim(str_ireplace('format', '', $matches[0][0]));
0 ignored issues
show
introduced by
Function trim() should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Function str_ireplace() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Bug introduced by
It seems like str_ireplace('format', '', $matches[0][0]) can also be of type array; however, parameter $string of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

88
                $this->format = trim(/** @scrutinizer ignore-type */ str_ireplace('format', '', $matches[0][0]));
Loading history...
89
0 ignored issues
show
Coding Style introduced by
Blank line found at end of control structure
Loading history...
90
            }
91
        } else {
92 37
            $this->sql = $this->sql . ' FORMAT ' . $this->format;
0 ignored issues
show
introduced by
Use ".=" operator instead of "=" and ".".
Loading history...
93
        }
94
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 6 empty lines
Loading history...
95
96
97
98
99
100 39
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 6 blank lines before brace
Loading history...
101
102
    /**
103
     * @return null|string
0 ignored issues
show
introduced by
Null type hint should be on last position in "null|string".
Loading history...
104
     */
105 45
    public function getFormat()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Query\Query::getFormat() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "null|string".
Loading history...
106
    {
107
        return $this->format;
108 45
    }
109
110
    public function isUseInUrlBindingsParams():bool
0 ignored issues
show
introduced by
There must be exactly one space between return type hint colon and return type hint.
Loading history...
111 45
    {
112
        //  'query=select {p1:UInt8} + {p2:UInt8}' -F "param_p1=3" -F "param_p2=4"
113 45
        return preg_match('#{[\w+]+:[\w+()]+}#',$this->sql);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match('#{[\w...\w+()]+}#', $this->sql) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
introduced by
Expected 0 lines after "return", found 1.
Loading history...
introduced by
Function preg_match() should not be referenced via a fallback global name, but via a use statement.
Loading history...
114 39
115
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
116
    public function getUrlBindingsParams():array
0 ignored issues
show
introduced by
Method \ClickHouseDB\Query\Query::getUrlBindingsParams() does not have @return annotation for its traversable return value.
Loading history...
introduced by
There must be exactly one space between return type hint colon and return type hint.
Loading history...
117 45
    {
118
        $out=[];
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "="; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "="; 0 found
Loading history...
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces
Loading history...
119 45
        if (sizeof($this->degenerations)) {
0 ignored issues
show
Coding Style introduced by
The use of function sizeof() is forbidden; use count() instead
Loading history...
introduced by
Expected 1 lines after "if", found 0.
Loading history...
120
            foreach ($this->degenerations as $degeneration) {
121 45
                if ($degeneration instanceof Degeneration) {
122 45
                    $params=$degeneration->getBind();
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "="; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "="; 0 found
Loading history...
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces
Loading history...
123
                    break;
124
                    // need first response
125
                }
126
            }
127 45
        }
128
        if (sizeof($params)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $params does not seem to be defined for all execution paths leading up to this point.
Loading history...
introduced by
Expected 1 lines after "if", found 0.
Loading history...
Coding Style introduced by
The use of function sizeof() is forbidden; use count() instead
Loading history...
129
            foreach ($params as $key=>$value)
0 ignored issues
show
Coding Style introduced by
Expected 1 space before "=>"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space after "=>"; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space before "=>"; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "=>"; 0 found
Loading history...
130
            {
131
                $out['param_'.$key]=$value;
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "."; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "."; 0 found
Loading history...
Coding Style introduced by
Concat operator must be surrounded by a single space
Loading history...
Coding Style introduced by
Expected at least 1 space before "="; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "="; 0 found
Loading history...
Coding Style introduced by
Equals sign not aligned correctly; expected 1 space but found 0 spaces
Loading history...
132
            }
133
        }
134
        return $out;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
135
    }
136
137
    public function toSql()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Query\Query::toSql() does not have return type hint nor @return annotation for its return value.
Loading history...
138
    {
139
        if ($this->format !== null) {
140
            $this->applyFormatQuery();
141
        }
142
143
        if (sizeof($this->degenerations))
0 ignored issues
show
Coding Style introduced by
The use of function sizeof() is forbidden; use count() instead
Loading history...
144
        {
145
            foreach ($this->degenerations as $degeneration)
146
            {
147
                if ($degeneration instanceof Degeneration) {
0 ignored issues
show
introduced by
Use early exit to reduce code nesting.
Loading history...
148
                    $this->sql = $degeneration->process($this->sql);
149
                }
150
            }
151
        }
152
153
        return $this->sql;
154
    }
155
156
    /**
157
     * @return string
158
     */
159
    public function __toString()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Query\Query::__toString() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "string".
Loading history...
160
    {
161
        return $this->toSql();
162
    }
163
}
164