CurlerRequest::prepareRequest()   F
last analyzed

Complexity

Conditions 18
Paths 4032

Size

Total Lines 76
Code Lines 42

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 18.0207

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 18
eloc 42
c 1
b 0
f 0
nc 4032
nop 0
dl 0
loc 76
ccs 24
cts 25
cp 0.96
crap 18.0207
rs 0.7

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
introduced by
Missing declare(strict_types=1).
Loading history...
2
3
namespace ClickHouseDB\Transport;
4
5
use const CURLOPT_HTTPGET;
6
use const CURLOPT_POST;
7
8
class CurlerRequest
9
{
10
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$extendinfo with single line content, use one-line comment instead.
Loading history...
11
     * @var array
0 ignored issues
show
introduced by
@var annotation of property \ClickHouseDB\Transport\CurlerRequest::$extendinfo does not specify type hint for its items.
Loading history...
12
     */
13
    public $extendinfo = [];
14
15
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$parameters with single line content, use one-line comment instead.
Loading history...
16
     * @var string|array
0 ignored issues
show
introduced by
@var annotation of property \ClickHouseDB\Transport\CurlerRequest::$parameters does not specify type hint for its items.
Loading history...
17
     */
18
    private $parameters = '';
19
20
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$options 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\Transport\CurlerRequest::$options does not specify type hint for its items.
Loading history...
22
     */
23
    private $options;
24
25
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$headers with single line content, use one-line comment instead.
Loading history...
26
     * @var array
0 ignored issues
show
introduced by
@var annotation of property \ClickHouseDB\Transport\CurlerRequest::$headers does not specify type hint for its items.
Loading history...
27
     */
28
    private $headers; // Parsed reponse header object.
29
30
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$url with single line content, use one-line comment instead.
Loading history...
31
     * @var string
32
     */
33
    private $url;
34
35
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$method with single line content, use one-line comment instead.
Loading history...
36
     * @var string
37
     */
38
    private $method;
39
40
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$id with single line content, use one-line comment instead.
Loading history...
41
     * @var bool
42
     */
43
    private $id;
44
45
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$handle with single line content, use one-line comment instead.
Loading history...
46
     * @var resource|null
47
     */
48
    private $handle;
49
50
    /** @var CurlerResponse */
51
    private $response;
52
53
    /** @var bool */
54
    private $_persistent = false;
55
56
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$_attachFiles with single line content, use one-line comment instead.
Loading history...
57
     * @var bool
58
     */
59
    private $_attachFiles = false;
60
61
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$callback_class with single line content, use one-line comment instead.
Loading history...
62
     * @var string
63
     */
64
    private $callback_class = '';
0 ignored issues
show
Coding Style introduced by
Member variable "callback_class" is not in valid camel caps format
Loading history...
65
66
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$callback_functionName with single line content, use one-line comment instead.
Loading history...
67
     * @var string
68
     */
69
    private $callback_functionName = '';
0 ignored issues
show
Coding Style introduced by
Member variable "callback_functionName" is not in valid camel caps format
Loading history...
70
71
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$_httpCompression with single line content, use one-line comment instead.
Loading history...
72
     * @var bool
73
     */
74
    private $_httpCompression = false;
75
76
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$callback_function with single line content, use one-line comment instead.
Loading history...
77
     * @var callable
78
     */
79
    private $callback_function = null;
0 ignored issues
show
Coding Style introduced by
Member variable "callback_function" is not in valid camel caps format
Loading history...
80
81
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$infile_handle with single line content, use one-line comment instead.
Loading history...
82
     * @var bool|resource
83
     */
84
    private $infile_handle = false;
0 ignored issues
show
Coding Style introduced by
Member variable "infile_handle" is not in valid camel caps format
Loading history...
85
86
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$_dns_cache with single line content, use one-line comment instead.
Loading history...
87
     * @var int
88
     */
89
    private $_dns_cache = 120;
0 ignored issues
show
Coding Style introduced by
Member variable "_dns_cache" is not in valid camel caps format
Loading history...
90
91
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$resultFileHandle with single line content, use one-line comment instead.
Loading history...
92
     * @var resource
93
     */
94
    private $resultFileHandle = null;
95
96
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$sslCa with single line content, use one-line comment instead.
Loading history...
97
     * @var string
98
     */
99
    private $sslCa = null;
0 ignored issues
show
introduced by
The private property $sslCa is not used, and could be removed.
Loading history...
100
101
102
    /**
0 ignored issues
show
introduced by
Found multi-line comment for property \ClickHouseDB\Transport\CurlerRequest::$stdErrOut with single line content, use one-line comment instead.
Loading history...
103
     * @var null|resource
0 ignored issues
show
introduced by
Null type hint should be on last position in "null|resource".
Loading history...
104 54
     */
105
    private $stdErrOut = null;
106 54
    /**
107
     * @param bool $id
108 54
     */
109 54
    public function __construct($id = false)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::__construct() does not have native type hint for its parameter $id but it should be possible to add it based on @param annotation "bool".
Loading history...
Coding Style introduced by
Expected 1 blank line before function; 0 found
Loading history...
110 54
    {
111
        $this->id = $id;
112 54
113 54
        $this->header('Cache-Control', 'no-cache, no-store, must-revalidate');
114 54
        $this->header('Expires', '0');
115 54
        $this->header('Pragma', 'no-cache');
116 54
117 54
        $this->options = array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
118 54
            CURLOPT_SSL_VERIFYHOST => 0,
0 ignored issues
show
introduced by
Constant CURLOPT_SSL_VERIFYHOST should not be referenced via a fallback global name, but via a use statement.
Loading history...
119 54
            CURLOPT_SSL_VERIFYPEER => false,
0 ignored issues
show
introduced by
Constant CURLOPT_SSL_VERIFYPEER should not be referenced via a fallback global name, but via a use statement.
Loading history...
120 54
            CURLOPT_TIMEOUT => 10,
0 ignored issues
show
introduced by
Constant CURLOPT_TIMEOUT should not be referenced via a fallback global name, but via a use statement.
Loading history...
121 54
            CURLOPT_CONNECTTIMEOUT => 5, // Количество секунд ожидания при попытке соединения
0 ignored issues
show
introduced by
Constant CURLOPT_CONNECTTIMEOUT should not be referenced via a fallback global name, but via a use statement.
Loading history...
122 54
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
0 ignored issues
show
introduced by
Constant CURLOPT_HTTP_VERSION should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Constant CURL_HTTP_VERSION_1_1 should not be referenced via a fallback global name, but via a use statement.
Loading history...
123 54
            CURLOPT_MAXREDIRS => 10,
0 ignored issues
show
introduced by
Constant CURLOPT_MAXREDIRS should not be referenced via a fallback global name, but via a use statement.
Loading history...
124 54
            CURLOPT_HEADER => TRUE,
0 ignored issues
show
introduced by
Constant CURLOPT_HEADER should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected true, but found TRUE.
Loading history...
125
            CURLOPT_FOLLOWLOCATION => TRUE,
0 ignored issues
show
introduced by
Constant CURLOPT_FOLLOWLOCATION should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected true, but found TRUE.
Loading history...
126 54
            CURLOPT_AUTOREFERER => 1, // при редиректе подставлять в «Referer:» значение из «Location:»
0 ignored issues
show
introduced by
Constant CURLOPT_AUTOREFERER should not be referenced via a fallback global name, but via a use statement.
Loading history...
127
            CURLOPT_BINARYTRANSFER => 1, // передавать в binary-safe
0 ignored issues
show
introduced by
The constant CURLOPT_BINARYTRANSFER has been deprecated: 5.1.3 ( Ignorable by Annotation )

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

127
            /** @scrutinizer ignore-deprecated */ CURLOPT_BINARYTRANSFER => 1, // передавать в binary-safe
Loading history...
introduced by
Constant CURLOPT_BINARYTRANSFER should not be referenced via a fallback global name, but via a use statement.
Loading history...
128
            CURLOPT_RETURNTRANSFER => TRUE,
0 ignored issues
show
introduced by
Constant CURLOPT_RETURNTRANSFER should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected true, but found TRUE.
Loading history...
129
            CURLOPT_USERAGENT => 'smi2/PHPClickHouse/client',
0 ignored issues
show
introduced by
Constant CURLOPT_USERAGENT should not be referenced via a fallback global name, but via a use statement.
Loading history...
130
        );
131 49
    }
132
133 49
    /**
0 ignored issues
show
introduced by
Empty comment
Loading history...
134 49
     *
135
     */
136
    public function __destruct()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::__destruct() does not need documentation comment.
Loading history...
137 49
    {
138
        $this->close();
139 49
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
140 49
141
142 49
    public function close()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::close() does not have void return type hint.
Loading history...
143 49
    {
144
        if ($this->handle) {
0 ignored issues
show
introduced by
Expected 1 lines after "if", found 0.
Loading history...
145
            curl_close($this->handle);
0 ignored issues
show
introduced by
Function curl_close() should not be referenced via a fallback global name, but via a use statement.
Loading history...
146
        }
147
        $this->handle = null;
148 1
    }
149
150 1
    /**
151
     * @param array $attachFiles
0 ignored issues
show
introduced by
@param annotation of method \ClickHouseDB\Transport\CurlerRequest::attachFiles() does not specify type hint for items of its traversable parameter $attachFiles.
Loading history...
152 1
     */
153 1
    public function attachFiles($attachFiles)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::attachFiles() does not have native type hint for its parameter $attachFiles but it should be possible to add it based on @param annotation "array".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::attachFiles() does not have void return type hint.
Loading history...
154 1
    {
155
        $this->header("Content-Type", "multipart/form-data");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Content-Type 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...
Coding Style Comprehensibility introduced by
The string literal multipart/form-data 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...
156
157 1
        $out = [];
158 1
        foreach ($attachFiles as $post_name => $file_path) {
0 ignored issues
show
Coding Style introduced by
The variable $post_name should be in camel caps format.
Loading history...
Coding Style introduced by
The variable $file_path should be in camel caps format.
Loading history...
159 1
            $out[$post_name] = new \CURLFile($file_path);
0 ignored issues
show
Coding Style introduced by
The variable $post_name should be in camel caps format.
Loading history...
introduced by
Class \CURLFile should not be referenced via a fully qualified name, but via a use statement.
Loading history...
Coding Style introduced by
The variable $file_path should be in camel caps format.
Loading history...
160
        }
161
162
        $this->_attachFiles = true;
163
        $this->parameters($out);
164
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
165
166
167
    /**
168
     * @param bool $set
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
169
     * @return $this
170
     */
171
    public function id($set = false)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::id() does not have native type hint for its parameter $set but it should be possible to add it based on @param annotation "bool".
Loading history...
172
    {
173
        if ($set) {
174
            $this->id = $set;
175
        }
176
177
        return $this;
178
    }
179 45
180
    /**
181 45
     * @param array $params
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
@param annotation of method \ClickHouseDB\Transport\CurlerRequest::setRequestExtendedInfo() does not specify type hint for items of its traversable parameter $params.
Loading history...
182 45
     * @return $this
183
     */
184
    public function setRequestExtendedInfo($params)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setRequestExtendedInfo() does not have native type hint for its parameter $params but it should be possible to add it based on @param annotation "array".
Loading history...
185
    {
186
        $this->extendinfo = $params;
187
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
188
    }
189 45
190
    /**
191 45
     * @param string|integer|null $key
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Expected "int" but found "integer" in @param annotation.
Loading history...
192 45
     * @return mixed
193
     */
194
    public function getRequestExtendedInfo($key = null)
195
    {
196
        if ($key) {
197
            return isset($this->extendinfo[$key]) ? $this->extendinfo[$key] : false;
0 ignored issues
show
introduced by
Use null coalesce operator instead of ternary operator.
Loading history...
198
        }
199
200
        return $this->extendinfo;
201 8
    }
202
203 8
    /**
204
     * @return bool|resource
205
     */
206
    public function getInfileHandle()
207
    {
208
        return $this->infile_handle;
0 ignored issues
show
Coding Style introduced by
Member variable "infile_handle" is not in valid camel caps format
Loading history...
209
    }
210 8
211
    /**
212 8
     * @param string $file_name
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
213 8
     * @return bool|resource
214 8
     */
215
    public function setInfile($file_name)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setInfile() does not have native type hint for its parameter $file_name but it should be possible to add it based on @param annotation "string".
Loading history...
Coding Style introduced by
The variable $file_name should be in camel caps format.
Loading history...
216 8
    {
217 8
        $this->header('Expect', '');
218 8
        $this->infile_handle = fopen($file_name, 'r');
0 ignored issues
show
Coding Style introduced by
Member variable "infile_handle" is not in valid camel caps format
Loading history...
introduced by
Function fopen() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
The variable $file_name should be in camel caps format.
Loading history...
219
        if (is_resource($this->infile_handle)) {
0 ignored issues
show
introduced by
Function is_resource() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Member variable "infile_handle" is not in valid camel caps format
Loading history...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
220 8
221
            if ($this->_httpCompression) {
222 8
                $this->header('Content-Encoding', 'gzip');
223
                $this->header('Content-Type', 'application/x-www-form-urlencoded');
224
225
                stream_filter_append($this->infile_handle, 'zlib.deflate', STREAM_FILTER_READ, ["window" => 30]);
0 ignored issues
show
introduced by
Function stream_filter_append() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Member variable "infile_handle" is not in valid camel caps format
Loading history...
introduced by
Constant STREAM_FILTER_READ should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style Comprehensibility introduced by
The string literal window 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...
226
227 8
                $this->options[CURLOPT_SAFE_UPLOAD] = 1;
0 ignored issues
show
introduced by
The constant CURLOPT_SAFE_UPLOAD has been deprecated: 7.0 Use <b>CURLFile</b> for uploads instead. ( Ignorable by Annotation )

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

227
                $this->options[/** @scrutinizer ignore-deprecated */ CURLOPT_SAFE_UPLOAD] = 1;
Loading history...
introduced by
Constant CURLOPT_SAFE_UPLOAD should not be referenced via a fallback global name, but via a use statement.
Loading history...
228
            } else {
229
                $this->options[CURLOPT_INFILESIZE] = filesize($file_name);
0 ignored issues
show
introduced by
Constant CURLOPT_INFILESIZE should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Function filesize() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
The variable $file_name should be in camel caps format.
Loading history...
230 8
            }
231
232
            $this->options[CURLOPT_INFILE] = $this->infile_handle;
0 ignored issues
show
introduced by
Constant CURLOPT_INFILE should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Member variable "infile_handle" is not in valid camel caps format
Loading history...
233
        }
234
235
        return $this->infile_handle;
0 ignored issues
show
Coding Style introduced by
Member variable "infile_handle" is not in valid camel caps format
Loading history...
236 8
    }
237
238 8
    /**
239 8
     * @param callable $callback
240
     */
241
    public function setCallbackFunction($callback)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setCallbackFunction() does not have native type hint for its parameter $callback but it should be possible to add it based on @param annotation "callable".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setCallbackFunction() does not have void return type hint.
Loading history...
242
    {
243
        $this->callback_function = $callback;
0 ignored issues
show
Coding Style introduced by
Member variable "callback_function" is not in valid camel caps format
Loading history...
244 1
    }
245
246 1
    /**
247 1
     * @param callable $callback
248
     */
249
    public function setWriteFunction($callback)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setWriteFunction() does not have native type hint for its parameter $callback but it should be possible to add it based on @param annotation "callable".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setWriteFunction() does not have void return type hint.
Loading history...
250
    {
251
        $this->options[CURLOPT_WRITEFUNCTION] = $callback;
0 ignored issues
show
introduced by
Constant CURLOPT_WRITEFUNCTION should not be referenced via a fallback global name, but via a use statement.
Loading history...
252 3
    }
253
254 3
    /**
255 3
     * @param callable $callback
256
     */
257
    public function setReadFunction($callback)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setReadFunction() does not have native type hint for its parameter $callback but it should be possible to add it based on @param annotation "callable".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setReadFunction() does not have void return type hint.
Loading history...
258
    {
259
        $this->options[CURLOPT_READFUNCTION] = $callback;
0 ignored issues
show
introduced by
Constant CURLOPT_READFUNCTION should not be referenced via a fallback global name, but via a use statement.
Loading history...
260
    }
261
262
    public function setHeaderFunction($callback)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setHeaderFunction() does not have parameter type hint nor @param annotation for its parameter $callback.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setHeaderFunction() does not have void return type hint.
Loading history...
263
    {
264
        $this->options[CURLOPT_HEADERFUNCTION] = $callback;
0 ignored issues
show
introduced by
Constant CURLOPT_HEADERFUNCTION should not be referenced via a fallback global name, but via a use statement.
Loading history...
265
    }
266
267
    /**
268
     * @param string $classCallBack
269
     * @param string $functionName
270
     */
271
    public function setCallback($classCallBack, $functionName)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setCallback() does not have native type hint for its parameter $classCallBack but it should be possible to add it based on @param annotation "string".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setCallback() does not have native type hint for its parameter $functionName but it should be possible to add it based on @param annotation "string".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setCallback() does not have void return type hint.
Loading history...
272
    {
273
        $this->callback_class = $classCallBack;
0 ignored issues
show
Coding Style introduced by
Member variable "callback_class" is not in valid camel caps format
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 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...
274
        $this->callback_functionName = $functionName;
0 ignored issues
show
Coding Style introduced by
Member variable "callback_functionName" is not in valid camel caps format
Loading history...
275 10
    }
276
277 10
    /**
0 ignored issues
show
introduced by
Empty comment
Loading history...
278 8
     *
279 8
     */
280
    public function onCallback()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::onCallback() does not have void return type hint.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::onCallback() does not need documentation comment.
Loading history...
281
    {
282 10
        if ($this->callback_function) {
0 ignored issues
show
Coding Style introduced by
Member variable "callback_function" is not in valid camel caps format
Loading history...
283
            $x = $this->callback_function;
0 ignored issues
show
Coding Style introduced by
Member variable "callback_function" is not in valid camel caps format
Loading history...
284
            $x($this);
285
        }
286 10
287
        if ($this->callback_class && $this->callback_functionName) {
0 ignored issues
show
introduced by
Use early exit to reduce code nesting.
Loading history...
Coding Style introduced by
Member variable "callback_class" is not in valid camel caps format
Loading history...
Coding Style introduced by
Member variable "callback_functionName" is not in valid camel caps format
Loading history...
288 1
            $c = $this->callback_functionName;
0 ignored issues
show
Coding Style introduced by
Member variable "callback_functionName" is not in valid camel caps format
Loading history...
289
            $this->callback_class->$c($this);
0 ignored issues
show
Coding Style introduced by
Member variable "callback_class" is not in valid camel caps format
Loading history...
290
        }
291 1
    }
292 1
293 1
    public function getDetails(): array
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::getDetails() does not have @return annotation for its traversable return value.
Loading history...
294 1
    {
295
        return [
296
            'url'        => $this->url,
297
            'method'     => $this->method,
298
            'parameters' => $this->parameters,
299
            'headers'    => $this->headers,
300
        ];
301
    }
302
303
    /**
304
     * @param resource $stream
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
305
     * @return void
306
     */
307
    public function setStdErrOut($stream)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setStdErrOut() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "void".
Loading history...
308
    {
309
        if (is_resource($stream)) {
0 ignored issues
show
introduced by
Expected 0 lines after "if", found 1.
Loading history...
introduced by
Use early exit to reduce code nesting.
Loading history...
introduced by
Function is_resource() should not be referenced via a fallback global name, but via a use statement.
Loading history...
310
            $this->stdErrOut=$stream;
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...
311
        }
312
313
    }
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...
314
315
    /**
316
     * @param bool $result
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
317
     * @return string
318
     */
319
    public function dump($result = false)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::dump() does not have native type hint for its parameter $result but it should be possible to add it based on @param annotation "bool".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::dump() 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...
320
    {
321
        $message = "\n------------  Request ------------\n";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 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...
322 15
        $message .= 'URL:' . $this->url . "\n\n";
323
        $message .= 'METHOD:' . $this->method . "\n\n";
324 15
        $message .= 'PARAMS:' . print_r($this->parameters, true) . "\n";
0 ignored issues
show
Bug introduced by
Are you sure print_r($this->parameters, true) of type string|true can be used in concatenation? ( Ignorable by Annotation )

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

324
        $message .= 'PARAMS:' . /** @scrutinizer ignore-type */ print_r($this->parameters, true) . "\n";
Loading history...
introduced by
Function print_r() should not be referenced via a fallback global name, but via a use statement.
Loading history...
325
        $message .= 'PARAMS:' . print_r($this->headers, true) . "\n";
0 ignored issues
show
Bug introduced by
Are you sure print_r($this->headers, true) of type string|true can be used in concatenation? ( Ignorable by Annotation )

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

325
        $message .= 'PARAMS:' . /** @scrutinizer ignore-type */ print_r($this->headers, true) . "\n";
Loading history...
introduced by
Function print_r() should not be referenced via a fallback global name, but via a use statement.
Loading history...
326
        $message .= "-----------------------------------\n";
327
328
        if ($result) {
329
            return $message;
330
        }
331
332 1
        echo $message;
333
        return '';
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
334 1
    }
335 1
336
    /**
337
     * @return bool
338
     */
339
    public function getId()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::getId() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "bool".
Loading history...
340
    {
341 1
        return $this->id;
342
    }
343 1
344 1
    /**
345
     * @param integer $key
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Expected "int" but found "integer" in @param annotation.
Loading history...
346
     * @param mixed $value
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
347
     * @return $this
348
     */
349
    private function option($key, $value)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::option() does not have native type hint for its parameter $key but it should be possible to add it based on @param annotation "integer".
Loading history...
350 10
    {
351
        $this->options[$key] = $value;
352 10
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
353
    }
354
355
    /**
356
     * @return $this
357
     */
358
    public function persistent()
359
    {
360
        $this->_persistent = true;
361
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
362
    }
363
364
    /**
365
     * @return bool
366
     */
367
    public function isPersistent()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::isPersistent() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "bool".
Loading history...
368
    {
369
        return $this->_persistent;
370
    }
371
372 54
    /**
373
     * @param int $sec
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::keepAlive() has useless @param annotation for parameter $sec.
Loading history...
374 54
     * @return $this
375 54
     */
376
    public function keepAlive(int $sec = 60)
377
    {
378
        $this->options[CURLOPT_FORBID_REUSE] = TRUE;
0 ignored issues
show
introduced by
Constant CURLOPT_FORBID_REUSE should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL must be lowercase; expected true, but found TRUE.
Loading history...
379
        $this->headers['Connection'] = 'Keep-Alive';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
380
        $this->headers['Keep-Alive'] = $sec;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
381
382
        return $this;
383 54
    }
384
385 54
    /**
386 54
     * @param bool $flag
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::verbose() has useless @param annotation for parameter $flag.
Loading history...
387
     * @return $this
388
     */
389
    public function verbose(bool $flag = true)
390
    {
391
        $this->options[CURLOPT_VERBOSE] = $flag;
0 ignored issues
show
introduced by
Constant CURLOPT_VERBOSE should not be referenced via a fallback global name, but via a use statement.
Loading history...
392
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
393
    }
394
395
    /**
396
     * @param string $key
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::header() has useless @param annotation for parameter $key.
Loading history...
397
     * @param string $value
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::header() has useless @param annotation for parameter $value.
Loading history...
398
     * @return $this
399
     */
400
    public function header(string $key, string $value)
401
    {
402
        $this->headers[$key] = $value;
403
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
404
    }
405 54
406
    /**
407 54
     * @return array
0 ignored issues
show
introduced by
@return annotation of method \ClickHouseDB\Transport\CurlerRequest::getHeaders() does not specify type hint for items of its traversable return value.
Loading history...
408 54
     */
409
    public function getHeaders():array
0 ignored issues
show
introduced by
There must be exactly one space between return type hint colon and return type hint.
Loading history...
410
    {
411
        $head = [];
412
        foreach ($this->headers as $key => $value) {
0 ignored issues
show
introduced by
Expected 1 lines after "foreach", found 0.
Loading history...
413
            $head[] = sprintf("%s: %s", $key, $value);
0 ignored issues
show
introduced by
Function sprintf() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style Comprehensibility introduced by
The string literal %s: %s 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...
414
        }
415
        return $head;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
416
    }
417
418
    /**
419
     * @param string $url
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::url() has useless @param annotation for parameter $url.
Loading history...
420
     * @return $this
421
     */
422
    public function url(string $url)
423
    {
424 15
        $this->url = $url;
425
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
426 15
    }
427
428
    /**
429
     * @return string
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::getUrl() has useless @return annotation.
Loading history...
430
     */
431
    public function getUrl():string
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::getUrl() does not need documentation comment.
Loading history...
introduced by
There must be exactly one space between return type hint colon and return type hint.
Loading history...
432 45
    {
433
        return $this->url;
434 45
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
435 45
436 45
437
    /**
438
     * @param string $id
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::getUniqHash() has useless @param annotation for parameter $id.
Loading history...
439
     * @return string
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::getUniqHash() has useless @return annotation.
Loading history...
440
     */
441 45
    public function getUniqHash(string $id):string
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::getUniqHash() does not need documentation comment.
Loading history...
introduced by
There must be exactly one space between return type hint colon and return type hint.
Loading history...
442
    {
443
        return $id . '.' . microtime() . mt_rand(0, 1000000);
0 ignored issues
show
introduced by
Function microtime() should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Function mt_rand() should not be referenced via a fallback global name, but via a use statement.
Loading history...
444
    }
445
446
    /**
447
     * @param bool $flag
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::httpCompression() has useless @param annotation for parameter $flag.
Loading history...
448
     */
449
    public function httpCompression(bool $flag):void
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::httpCompression() does not need documentation comment.
Loading history...
introduced by
There must be exactly one space between return type hint colon and return type hint.
Loading history...
450
    {
451
        if ($flag) {
452
            $this->_httpCompression = $flag;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 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...
453
            $this->options[CURLOPT_ENCODING] = 'gzip';
0 ignored issues
show
introduced by
Constant CURLOPT_ENCODING should not be referenced via a fallback global name, but via a use statement.
Loading history...
454 45
        } else {
455
            $this->_httpCompression = false;
456 45
            unset($this->options[CURLOPT_ENCODING]);
0 ignored issues
show
introduced by
Constant CURLOPT_ENCODING should not be referenced via a fallback global name, but via a use statement.
Loading history...
457 45
        }
458 45
    }
459
460
    /**
461
     * @param string $username
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
462
     * @param string $password
463
     * @return $this
464
     */
465 1
    public function authByBasicAuth($username, $password)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::authByBasicAuth() does not have native type hint for its parameter $username but it should be possible to add it based on @param annotation "string".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::authByBasicAuth() does not have native type hint for its parameter $password but it should be possible to add it based on @param annotation "string".
Loading history...
466
    {
467 1
        $this->options[CURLOPT_USERPWD] = sprintf("%s:%s", $username, $password);
0 ignored issues
show
introduced by
Constant CURLOPT_USERPWD should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Function sprintf() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style Comprehensibility introduced by
The string literal %s:%s 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...
468 1
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
469
    }
470
471
    public function authByHeaders($username, $password)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::authByHeaders() does not have parameter type hint nor @param annotation for its parameter $username.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::authByHeaders() does not have parameter type hint nor @param annotation for its parameter $password.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::authByHeaders() does not have return type hint nor @return annotation for its return value.
Loading history...
472
    {
473
        $this->headers['X-ClickHouse-User'] = $username;
474
        $this->headers['X-ClickHouse-Key'] = $password;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 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...
475
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
476
    }
477 54
478
    /**
479 54
     * @param array|string $data
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
@param annotation of method \ClickHouseDB\Transport\CurlerRequest::parameters() does not specify type hint for items of its traversable parameter $data.
Loading history...
480 54
     * @return $this
481
     */
482
    public function parameters($data)
483
    {
484
        $this->parameters = $data;
485
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
486
    }
487
488
    /**
489 45
     * The number of seconds to wait when trying to connect. Use 0 for infinite waiting.
490
     *
491 45
     * @param float $seconds
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::connectTimeOut() has useless @param annotation for parameter $seconds.
Loading history...
492
     * @return $this
493
     */
494
    public function connectTimeOut(float $seconds = 1.0)
495
    {
496
        $this->options[CURLOPT_CONNECTTIMEOUT_MS] = (int) ($seconds*1000.0);
0 ignored issues
show
introduced by
Constant CURLOPT_CONNECTTIMEOUT_MS should not be referenced via a fallback global name, but via a use statement.
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...
497
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
498
    }
499
500 45
    /**
501
     * The maximum number of seconds (float) allowed to execute cURL functions.
502 45
     *
503 45
     * @param float $seconds
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::timeOut() has useless @param annotation for parameter $seconds.
Loading history...
504
     * @return $this
505
     */
506
    public function timeOut(float $seconds = 10)
507
    {
508
        return $this->timeOutMs((int) ($seconds * 1000.0));
509
    }
510
511
    /**
512 45
     * The maximum allowed number of milliseconds to perform cURL functions.
513
     *
514
     * @param int $ms millisecond
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
515 45
     * @return $this
516 45
     */
517
    protected function timeOutMs(int $ms = 10000)
518 45
    {
519
        $this->options[CURLOPT_TIMEOUT_MS] = $ms;
0 ignored issues
show
introduced by
Constant CURLOPT_TIMEOUT_MS should not be referenced via a fallback global name, but via a use statement.
Loading history...
520
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
521
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
522
523 45
524 45
    /**
525 45
     * @param array|mixed $data
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
@param annotation of method \ClickHouseDB\Transport\CurlerRequest::parameters_json() does not specify type hint for items of its traversable parameter $data.
Loading history...
526
     * @return $this
527
     * @throws \ClickHouseDB\Exception\TransportException
0 ignored issues
show
introduced by
Class \ClickHouseDB\Exception\TransportException should not be referenced via a fully qualified name, but via a use statement.
Loading history...
528
     */
529
    public function parameters_json($data)
0 ignored issues
show
Coding Style introduced by
Method name "CurlerRequest::parameters_json" is not in camel caps format
Loading history...
530
    {
0 ignored issues
show
Coding Style introduced by
Expected 0 blank lines after opening function brace; 1 found
Loading history...
531
532
        $this->header("Content-Type", "application/json, text/javascript; charset=utf-8");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Content-Type 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...
Coding Style Comprehensibility introduced by
The string literal application/json, text/javascript; charset=utf-8 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...
533
        $this->header("Accept", "application/json, text/javascript, */*; q=0.01");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Accept 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...
Coding Style Comprehensibility introduced by
The string literal application/json, text/javascript, */*; q=0.01 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...
534
535
        if ($data === null) {
536
            $this->parameters = '{}';
537
            return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
538
        }
539
540
        if (is_string($data)) {
0 ignored issues
show
introduced by
Function is_string() should not be referenced via a fallback global name, but via a use statement.
Loading history...
541
            $this->parameters = $data;
542
            return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
543
        }
544
545
        $this->parameters = json_encode($data);
0 ignored issues
show
introduced by
Function json_encode() should not be referenced via a fallback global name, but via a use statement.
Loading history...
546
547
        if (!$this->parameters && $data) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
548
            throw new \ClickHouseDB\Exception\TransportException('Cant json_encode: ' . strval($data));
0 ignored issues
show
introduced by
Class \ClickHouseDB\Exception\TransportException should not be referenced via a fully qualified name, but via a use statement.
Loading history...
introduced by
Function strval() should not be referenced via a fallback global name, but via a use statement.
Loading history...
549
        }
550
551
        return $this;
552
    }
553
554
    /**
555
     * @return resource
556
     */
557
    public function getResultFileHandle()
558 1
    {
559
        return $this->resultFileHandle;
560 1
    }
561 1
562
    /**
563
     * @return bool
564
     */
565 1
    public function isResultFile()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::isResultFile() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "bool".
Loading history...
566
    {
567
        return ($this->resultFileHandle ? true : false);
0 ignored issues
show
introduced by
Usage of language construct "return" with parentheses is disallowed.
Loading history...
introduced by
Useless ternary operator.
Loading history...
568
    }
569
570
    /**
571
     * @param resource $h resource
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter name; 1 found
Loading history...
572
     * @param bool $zlib
0 ignored issues
show
Coding Style introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
573
     * @return $this
574
     */
575
    public function setResultFileHandle($h, $zlib = false)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setResultFileHandle() does not have native type hint for its parameter $zlib but it should be possible to add it based on @param annotation "bool".
Loading history...
576
    {
577
        $this->resultFileHandle = $h;
578
        if ($zlib) {
0 ignored issues
show
introduced by
Expected 1 lines after "if", found 0.
Loading history...
579 45
            $params = array('level' => 6, 'window' => 15, 'memory' => 9);
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
580
            stream_filter_append($this->resultFileHandle, 'zlib.deflate', STREAM_FILTER_WRITE, $params);
0 ignored issues
show
introduced by
Function stream_filter_append() should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Constant STREAM_FILTER_WRITE should not be referenced via a fallback global name, but via a use statement.
Loading history...
581 45
        }
582
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
583
    }
584
585
    /**
586
     * @return CurlerRequest
587
     */
588
    public function PUT()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::PUT() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "CurlerRequest".
Loading history...
589
    {
590
        return $this->execute('PUT');
591
    }
592
593
    /**
594
     * @return CurlerRequest
595 38
     */
596
    public function POST()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::POST() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "CurlerRequest".
Loading history...
597 38
    {
598
        return $this->execute('POST');
599
    }
600
601
    /**
602
     * @return CurlerRequest
603
     */
604
    public function OPTIONS()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::OPTIONS() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "CurlerRequest".
Loading history...
605
    {
606
        return $this->execute('OPTIONS');
607
    }
608
609
    /**
610
     * @return CurlerRequest
611
     */
612
    public function GET()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::GET() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "CurlerRequest".
Loading history...
613
    {
614
        return $this->execute('GET');
615
    }
616
617 49
    /**
618
     * The number of seconds that DNS records are stored in memory. By default this parameter is 120 (2 minutes).
619 49
     *
620
     * @param integer $set
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
introduced by
Expected "int" but found "integer" in @param annotation.
Loading history...
621
     * @return $this
622
     */
623
    public function setDnsCache($set)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setDnsCache() does not have native type hint for its parameter $set but it should be possible to add it based on @param annotation "integer".
Loading history...
624
    {
625
        $this->_dns_cache = $set;
0 ignored issues
show
Coding Style introduced by
Member variable "_dns_cache" is not in valid camel caps format
Loading history...
626
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
627
    }
628
629
    /**
630
     * The number of seconds that DNS records are stored in memory. By default this parameter is 120 (2 minutes).
631
     *
632
     * @return int
633
     */
634
    public function getDnsCache()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::getDnsCache() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "int".
Loading history...
635
    {
636
        return $this->_dns_cache;
0 ignored issues
show
Coding Style introduced by
Member variable "_dns_cache" is not in valid camel caps format
Loading history...
637 54
    }
638
639 54
    /**
640 54
     * Sets client certificate
641
     *
642
     * @param string $filePath
643
     */
644
    public function setSslCa($filePath)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setSslCa() does not have native type hint for its parameter $filePath but it should be possible to add it based on @param annotation "string".
Loading history...
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setSslCa() does not have void return type hint.
Loading history...
645
    {
646
        $this->option(CURLOPT_SSL_VERIFYPEER, true);
0 ignored issues
show
introduced by
Constant CURLOPT_SSL_VERIFYPEER should not be referenced via a fallback global name, but via a use statement.
Loading history...
647 49
        $this->option(CURLOPT_CAINFO, $filePath);
0 ignored issues
show
introduced by
Constant CURLOPT_CAINFO should not be referenced via a fallback global name, but via a use statement.
Loading history...
648
    }
649 49
650
    /**
651
     * @param string $method
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
652
     * @return $this
653 49
     */
654
    private function execute($method)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::execute() does not have native type hint for its parameter $method but it should be possible to add it based on @param annotation "string".
Loading history...
655
    {
656 32
        $this->method = $method;
657
        return $this;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
658 32
    }
659
660
    /**
661 49
     * @return CurlerResponse
0 ignored issues
show
introduced by
Incorrect annotations group.
Loading history...
662
     * @throws \ClickHouseDB\Exception\TransportException
0 ignored issues
show
introduced by
Class \ClickHouseDB\Exception\TransportException should not be referenced via a fully qualified name, but via a use statement.
Loading history...
663 49
     */
664 49
    public function response()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::response() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "CurlerResponse".
Loading history...
665
    {
666
        if (!$this->response) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
667
            throw new \ClickHouseDB\Exception\TransportException('Can`t fetch response - is empty');
0 ignored issues
show
introduced by
Class \ClickHouseDB\Exception\TransportException should not be referenced via a fully qualified name, but via a use statement.
Loading history...
668
        }
669 49
670
        return $this->response;
671 49
    }
672 49
673
    public function isResponseExists(): bool
674
    {
675
        return $this->response !== null;
676
    }
677
678
    public function setResponse(CurlerResponse $response): void
679 1
    {
680
        $this->response = $response;
681 1
    }
682
683
    /**
684
     * @return mixed
685 1
     */
686 1
    public function handle()
687 1
    {
688
        $this->prepareRequest();
689
        return $this->handle;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
690
    }
691
692
    /**
693 49
     * @param callable $callback
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setFunctionProgress() has useless @param annotation for parameter $callback.
Loading history...
introduced by
Incorrect annotations group.
Loading history...
694
     * @throws \Exception
0 ignored issues
show
introduced by
Class \Exception should not be referenced via a fully qualified name, but via a use statement.
Loading history...
695 49
     */
696 49
    public function setFunctionProgress(callable $callback)
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::setFunctionProgress() does not have void return type hint.
Loading history...
697
    {
698
        if (!is_callable($callback)) {
0 ignored issues
show
introduced by
Function is_callable() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
699 49
            throw new \Exception('setFunctionProgress not is_callable');
0 ignored issues
show
introduced by
Class \Exception should not be referenced via a fully qualified name, but via a use statement.
Loading history...
700 49
        }
701
702 49
        $this->option(CURLOPT_NOPROGRESS, false);
0 ignored issues
show
introduced by
Constant CURLOPT_NOPROGRESS should not be referenced via a fallback global name, but via a use statement.
Loading history...
703 1
        $this->option(CURLOPT_PROGRESSFUNCTION, $callback); // version 5.5.0
0 ignored issues
show
introduced by
Constant CURLOPT_PROGRESSFUNCTION should not be referenced via a fallback global name, but via a use statement.
Loading history...
704
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 2 found
Loading history...
705
706
707 49
    /**
708 38
     * @return bool
709 38
     */
710 38
    private function prepareRequest()
0 ignored issues
show
introduced by
Method \ClickHouseDB\Transport\CurlerRequest::prepareRequest() does not have native return type hint for its return value but it should be possible to add it based on @return annotation "bool".
Loading history...
711
    {
712 40
        if (!$this->handle) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
713 40
            $this->handle = curl_init();
0 ignored issues
show
Documentation Bug introduced by
It seems like curl_init() can also be of type CurlHandle. However, the property $handle is declared as type null|resource. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
introduced by
Function curl_init() should not be referenced via a fallback global name, but via a use statement.
Loading history...
714
        }
715
716 40
        $curl_opt = $this->options;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
717
        $method = $this->method;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
718 40
719 40
        if ($this->_attachFiles) {
0 ignored issues
show
introduced by
Expected 1 lines after "if", found 2.
Loading history...
720
            $curl_opt[CURLOPT_SAFE_UPLOAD] = true;
0 ignored issues
show
introduced by
The constant CURLOPT_SAFE_UPLOAD has been deprecated: 7.0 Use <b>CURLFile</b> for uploads instead. ( Ignorable by Annotation )

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

720
            $curl_opt[/** @scrutinizer ignore-deprecated */ CURLOPT_SAFE_UPLOAD] = true;
Loading history...
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_SAFE_UPLOAD should not be referenced via a fallback global name, but via a use statement.
Loading history...
721 40
        }
722 40
0 ignored issues
show
Coding Style introduced by
Functions must not contain multiple empty lines in a row; found 2 empty lines
Loading history...
723
724
        if (strtoupper($method) == 'GET') {
0 ignored issues
show
introduced by
Expected 1 lines after "if", found 0.
Loading history...
introduced by
Function strtoupper() 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...
725
            $curl_opt[CURLOPT_HTTPGET] = true;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 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...
726
            $curl_opt[CURLOPT_CUSTOMREQUEST] = strtoupper($method);
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_CUSTOMREQUEST should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Function strtoupper() should not be referenced via a fallback global name, but via a use statement.
Loading history...
727 49
            $curl_opt[CURLOPT_POSTFIELDS] = false;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_POSTFIELDS should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
728 49
        } else {
729
            if (strtoupper($method) === 'POST') {
0 ignored issues
show
introduced by
Function strtoupper() should not be referenced via a fallback global name, but via a use statement.
Loading history...
730 49
                $curl_opt[CURLOPT_POST] = true;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
731 49
            }
732
733 49
            $curl_opt[CURLOPT_CUSTOMREQUEST] = strtoupper($method);
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_CUSTOMREQUEST should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Function strtoupper() should not be referenced via a fallback global name, but via a use statement.
Loading history...
734 49
735
            if ($this->parameters) {
736
                $curl_opt[CURLOPT_POSTFIELDS] = $this->parameters;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_POSTFIELDS should not be referenced via a fallback global name, but via a use statement.
Loading history...
737
738 49
                if (!is_array($this->parameters)) {
0 ignored issues
show
introduced by
Function is_array() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
739
                    $this->header('Content-Length',  mb_strlen($this->parameters, '8bit'));
0 ignored issues
show
Coding Style introduced by
Expected 1 space after comma in argument list; 2 found
Loading history...
introduced by
Function mb_strlen() should not be referenced via a fallback global name, but via a use statement.
Loading history...
740 8
                }
741
            }
742
        }
743 49
        // CURLOPT_DNS_CACHE_TIMEOUT - Количество секунд, в течение которых в памяти хранятся DNS-записи.
744 1
        $curl_opt[CURLOPT_DNS_CACHE_TIMEOUT] = $this->getDnsCache();
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_DNS_CACHE_TIMEOUT should not be referenced via a fallback global name, but via a use statement.
Loading history...
745
        $curl_opt[CURLOPT_URL] = $this->url;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_URL should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 15 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...
746
747 49
        if (!empty($this->headers) && sizeof($this->headers)) {
0 ignored issues
show
introduced by
Function sizeof() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
The use of function sizeof() is forbidden; use count() instead
Loading history...
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
748 1
            $curl_opt[CURLOPT_HTTPHEADER] = [];
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_HTTPHEADER should not be referenced via a fallback global name, but via a use statement.
Loading history...
749 1
750
            foreach ($this->headers as $key => $value) {
751
                $curl_opt[CURLOPT_HTTPHEADER][] = sprintf("%s: %s", $key, $value);
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_HTTPHEADER should not be referenced via a fallback global name, but via a use statement.
Loading history...
introduced by
Function sprintf() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style Comprehensibility introduced by
The string literal %s: %s 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...
752 49
            }
753
        }
754
755 49
        if (!empty($curl_opt[CURLOPT_INFILE])) {
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_INFILE 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...
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
756 49
757
            $curl_opt[CURLOPT_PUT] = true;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_PUT should not be referenced via a fallback global name, but via a use statement.
Loading history...
758
        }
759
760
        if (!empty($curl_opt[CURLOPT_WRITEFUNCTION])) {
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_WRITEFUNCTION should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Expected 1 space after NOT operator; 0 found
Loading history...
761
            $curl_opt[CURLOPT_HEADER] = false;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_HEADER should not be referenced via a fallback global name, but via a use statement.
Loading history...
762
        }
763
764
        if ($this->resultFileHandle) {
765
            $curl_opt[CURLOPT_FILE] = $this->resultFileHandle;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_FILE should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
766
            $curl_opt[CURLOPT_HEADER] = false;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_HEADER should not be referenced via a fallback global name, but via a use statement.
Loading history...
767
        }
768
769
        if ($this->options[CURLOPT_VERBOSE]) {
0 ignored issues
show
introduced by
Constant CURLOPT_VERBOSE should not be referenced via a fallback global name, but via a use statement.
Loading history...
770
            $msg="\n-----------BODY REQUEST----------\n" . $curl_opt[CURLOPT_POSTFIELDS] . "\n------END--------\n";
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_POSTFIELDS should not be referenced via a fallback global name, but via a use statement.
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...
771
            if ($this->stdErrOut && is_resource($this->stdErrOut)) {
0 ignored issues
show
introduced by
Function is_resource() should not be referenced via a fallback global name, but via a use statement.
Loading history...
772
                fwrite($this->stdErrOut,$msg);
0 ignored issues
show
introduced by
Function fwrite() should not be referenced via a fallback global name, but via a use statement.
Loading history...
773
            } else {
774
                echo $msg;
775
            }
776
        }
777
778
        if ($this->stdErrOut) {
779
            if (is_resource($this->stdErrOut)) {
0 ignored issues
show
introduced by
Function is_resource() should not be referenced via a fallback global name, but via a use statement.
Loading history...
780
                $curl_opt[CURLOPT_STDERR]=$this->stdErrOut;
0 ignored issues
show
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
introduced by
Constant CURLOPT_STDERR should not be referenced via a fallback global name, but via a use statement.
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...
781
            }
782
        }
783
784
        curl_setopt_array($this->handle, $curl_opt);
0 ignored issues
show
introduced by
Function curl_setopt_array() should not be referenced via a fallback global name, but via a use statement.
Loading history...
Coding Style introduced by
The variable $curl_opt should be in camel caps format.
Loading history...
785
        return true;
0 ignored issues
show
introduced by
Expected 1 lines before "return", found 0.
Loading history...
786
    }
787
}
788