@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | |
25 | 25 | // read chunk-size, chunk-extension (if any) and crlf |
26 | 26 | // get the position of the linebreak |
27 | - $chunkEnd = strpos($buffer, "\r\n") + 2; |
|
27 | + $chunkEnd = strpos($buffer, "\r\n")+2; |
|
28 | 28 | $temp = substr($buffer, 0, $chunkEnd); |
29 | 29 | $chunkSize = hexdec(trim($temp)); |
30 | 30 | $chunkStart = $chunkEnd; |
31 | - while ($chunkSize > 0) { |
|
32 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart + $chunkSize); |
|
31 | + while ($chunkSize>0) { |
|
32 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart+$chunkSize); |
|
33 | 33 | |
34 | 34 | // just in case we got a broken connection |
35 | 35 | if ($chunkEnd == false) { |
@@ -41,19 +41,19 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | // read chunk-data and crlf |
44 | - $chunk = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
44 | + $chunk = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
45 | 45 | // append chunk-data to entity-body |
46 | 46 | $new .= $chunk; |
47 | 47 | // length := length + chunk-size |
48 | 48 | $length += strlen($chunk); |
49 | 49 | // read chunk-size and crlf |
50 | - $chunkStart = $chunkEnd + 2; |
|
50 | + $chunkStart = $chunkEnd+2; |
|
51 | 51 | |
52 | - $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2; |
|
52 | + $chunkEnd = strpos($buffer, "\r\n", $chunkStart)+2; |
|
53 | 53 | if ($chunkEnd == false) { |
54 | 54 | break; //just in case we got a broken connection |
55 | 55 | } |
56 | - $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart); |
|
56 | + $temp = substr($buffer, $chunkStart, $chunkEnd-$chunkStart); |
|
57 | 57 | $chunkSize = hexdec(trim($temp)); |
58 | 58 | $chunkStart = $chunkEnd; |
59 | 59 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return array with keys 'headers', 'cookies', 'raw_data' and 'status_code' |
71 | 71 | * @throws HttpException |
72 | 72 | */ |
73 | - public function parseResponseHeaders(&$data, $headersProcessed = false, $debug=0) |
|
73 | + public function parseResponseHeaders(&$data, $headersProcessed = false, $debug = 0) |
|
74 | 74 | { |
75 | 75 | $httpResponse = array('raw_data' => $data, 'headers'=> array(), 'cookies' => array(), 'status_code' => null); |
76 | 76 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | // (even though it is not valid http) |
81 | 81 | $pos = strpos($data, "\r\n\r\n"); |
82 | 82 | if ($pos || is_int($pos)) { |
83 | - $bd = $pos + 4; |
|
83 | + $bd = $pos+4; |
|
84 | 84 | } else { |
85 | 85 | $pos = strpos($data, "\n\n"); |
86 | 86 | if ($pos || is_int($pos)) { |
87 | - $bd = $pos + 2; |
|
87 | + $bd = $pos+2; |
|
88 | 88 | } else { |
89 | 89 | // No separation between response headers and body: fault? |
90 | 90 | $bd = 0; |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | // maybe we could take them into account, too? |
96 | 96 | $data = substr($data, $bd); |
97 | 97 | } else { |
98 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed'); |
|
99 | - throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
98 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': HTTPS via proxy error, tunnel connection possibly failed'); |
|
99 | + throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' (HTTPS via proxy error, tunnel connection possibly failed)', PhpXmlRpc::$xmlrpcerr['http_error']); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -126,20 +126,20 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | if ($httpResponse['status_code'] !== '200') { |
129 | - $errstr = substr($data, 0, strpos($data, "\n") - 1); |
|
130 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTP error, got response: ' . $errstr); |
|
131 | - throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code'] ); |
|
129 | + $errstr = substr($data, 0, strpos($data, "\n")-1); |
|
130 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': HTTP error, got response: '.$errstr); |
|
131 | + throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'].' ('.$errstr.')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // be tolerant to usage of \n instead of \r\n to separate headers and data |
135 | 135 | // (even though it is not valid http) |
136 | 136 | $pos = strpos($data, "\r\n\r\n"); |
137 | 137 | if ($pos || is_int($pos)) { |
138 | - $bd = $pos + 4; |
|
138 | + $bd = $pos+4; |
|
139 | 139 | } else { |
140 | 140 | $pos = strpos($data, "\n\n"); |
141 | 141 | if ($pos || is_int($pos)) { |
142 | - $bd = $pos + 2; |
|
142 | + $bd = $pos+2; |
|
143 | 143 | } else { |
144 | 144 | // No separation between response headers and body: fault? |
145 | 145 | // we could take some action here instead of going on... |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | // be tolerant to line endings, and extra empty lines |
151 | 151 | $ar = preg_split("/\r?\n/", trim(substr($data, 0, $pos))); |
152 | 152 | |
153 | - foreach($ar as $line) { |
|
153 | + foreach ($ar as $line) { |
|
154 | 154 | // take care of multi-line headers and cookies |
155 | 155 | $arr = explode(':', $line, 2); |
156 | - if (count($arr) > 1) { |
|
156 | + if (count($arr)>1) { |
|
157 | 157 | $headerName = strtolower(trim($arr[0])); |
158 | 158 | /// @todo some other headers (the ones that allow a CSV list of values) |
159 | 159 | /// do allow many values to be passed using multiple header lines. |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | // glue together all received cookies, using a comma to separate them |
173 | 173 | // (same as php does with getallheaders()) |
174 | 174 | if (isset($httpResponse['headers'][$headerName])) { |
175 | - $httpResponse['headers'][$headerName] .= ', ' . trim($cookie); |
|
175 | + $httpResponse['headers'][$headerName] .= ', '.trim($cookie); |
|
176 | 176 | } else { |
177 | 177 | $httpResponse['headers'][$headerName] = trim($cookie); |
178 | 178 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | } elseif (isset($headerName)) { |
203 | 203 | /// @todo version1 cookies might span multiple lines, thus breaking the parsing above |
204 | - $httpResponse['headers'][$headerName] .= ' ' . trim($line); |
|
204 | + $httpResponse['headers'][$headerName] .= ' '.trim($line); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | // Decode chunked encoding sent by http 1.1 servers |
226 | 226 | if (isset($httpResponse['headers']['transfer-encoding']) && $httpResponse['headers']['transfer-encoding'] == 'chunked') { |
227 | 227 | if (!$data = static::decodeChunked($data)) { |
228 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to rebuild the chunked data received from server'); |
|
228 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to rebuild the chunked data received from server'); |
|
229 | 229 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['dechunk_fail'], PhpXmlRpc::$xmlrpcerr['dechunk_fail'], null, $httpResponse['status_code']); |
230 | 230 | } |
231 | 231 | } |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | if ($httpResponse['headers']['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) { |
241 | 241 | $data = $degzdata; |
242 | 242 | if ($debug) { |
243 | - Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
243 | + Logger::instance()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
244 | 244 | } |
245 | 245 | } elseif ($httpResponse['headers']['content-encoding'] == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { |
246 | 246 | $data = $degzdata; |
247 | 247 | if ($debug) { |
248 | - Logger::instance()->debugMessage("---INFLATED RESPONSE---[" . strlen($data) . " chars]---\n$data\n---END---"); |
|
248 | + Logger::instance()->debugMessage("---INFLATED RESPONSE---[".strlen($data)." chars]---\n$data\n---END---"); |
|
249 | 249 | } |
250 | 250 | } else { |
251 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': errors occurred when trying to decode the deflated data received from server'); |
|
251 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': errors occurred when trying to decode the deflated data received from server'); |
|
252 | 252 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['decompress_fail'], PhpXmlRpc::$xmlrpcerr['decompress_fail'], null, $httpResponse['status_code']); |
253 | 253 | } |
254 | 254 | } else { |
255 | - Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
255 | + Logger::instance()->errorLog('XML-RPC: '.__METHOD__.': the server sent deflated data. Your php install must have the Zlib extension compiled in to support this.'); |
|
256 | 256 | throw new HttpException(PhpXmlRpc::$xmlrpcstr['cannot_decompress'], PhpXmlRpc::$xmlrpcerr['cannot_decompress'], null, $httpResponse['status_code']); |
257 | 257 | } |
258 | 258 | } |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | - public static function getOpts($args=array(), $cliOpts=array()) |
|
65 | + public static function getOpts($args = array(), $cliOpts = array()) |
|
66 | 66 | { |
67 | - if (count($args) > 0) |
|
67 | + if (count($args)>0) |
|
68 | 68 | // throw new \Exception('Missing library version argument'); |
69 | 69 | self::$libVersion = $args[0]; |
70 | 70 | |
@@ -161,17 +161,17 @@ discard block |
||
161 | 161 | $out = ''; |
162 | 162 | while (($start = strpos($content, $startTag, $last)) !== false) { |
163 | 163 | $end = strpos($content, $endTag, $start); |
164 | - $code = substr($content, $start + strlen($startTag), $end - $start - strlen($startTag)); |
|
165 | - if ($code[strlen($code) - 1] == "\n") { |
|
164 | + $code = substr($content, $start+strlen($startTag), $end-$start-strlen($startTag)); |
|
165 | + if ($code[strlen($code)-1] == "\n") { |
|
166 | 166 | $code = substr($code, 0, -1); |
167 | 167 | } |
168 | 168 | |
169 | 169 | $code = str_replace(array('>', '<'), array('>', '<'), $code); |
170 | - $code = highlight_string('<?php ' . $code, true); |
|
170 | + $code = highlight_string('<?php '.$code, true); |
|
171 | 171 | $code = str_replace('<span style="color: #0000BB"><?php <br />', '<span style="color: #0000BB">', $code); |
172 | 172 | |
173 | - $out = $out . substr($content, $last, $start + strlen($startTag) - $last) . $code . $endTag; |
|
174 | - $last = $end + strlen($endTag); |
|
173 | + $out = $out.substr($content, $last, $start+strlen($startTag)-$last).$code.$endTag; |
|
174 | + $last = $end+strlen($endTag); |
|
175 | 175 | } |
176 | 176 | $out .= substr($content, $last, strlen($content)); |
177 | 177 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | use PhpXmlRpc\Builder; |
187 | 187 | |
188 | -function run_default($task=null, $args=array(), $cliOpts=array()) |
|
188 | +function run_default($task = null, $args = array(), $cliOpts = array()) |
|
189 | 189 | { |
190 | 190 | echo "Syntax: pake {\$pake-options} \$task \$lib-version [\$git-tag] {\$task-options}\n"; |
191 | 191 | echo "\n"; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | echo " --zip=ZIP Location of the zip tool\n"; |
203 | 203 | } |
204 | 204 | |
205 | -function run_getopts($task=null, $args=array(), $cliOpts=array()) |
|
205 | +function run_getopts($task = null, $args = array(), $cliOpts = array()) |
|
206 | 206 | { |
207 | 207 | Builder::getOpts($args, $cliOpts); |
208 | 208 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * Downloads source code in the build workspace directory, optionally checking out the given branch/tag |
212 | 212 | * @todo allow using current installation as source, bypassing git clone in workspace - at least for doc generation |
213 | 213 | */ |
214 | -function run_init($task=null, $args=array(), $cliOpts=array()) |
|
214 | +function run_init($task = null, $args = array(), $cliOpts = array()) |
|
215 | 215 | { |
216 | 216 | // download the current version into the workspace |
217 | 217 | $targetDir = Builder::workspaceDir(); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * |
240 | 240 | * (does nothing by itself, as all the steps are managed via task dependencies) |
241 | 241 | */ |
242 | -function run_build($task=null, $args=array(), $cliOpts=array()) |
|
242 | +function run_build($task = null, $args = array(), $cliOpts = array()) |
|
243 | 243 | { |
244 | 244 | } |
245 | 245 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * Generates documentation in all formats |
257 | 257 | */ |
258 | -function run_doc($task=null, $args=array(), $cliOpts=array()) |
|
258 | +function run_doc($task = null, $args = array(), $cliOpts = array()) |
|
259 | 259 | { |
260 | 260 | // in |
261 | 261 | $srcDir = Builder::workspaceDir(); |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | // from phpdoc comments using phpdocumentor |
268 | 268 | $cmd = Builder::tool('php'); |
269 | - pake_sh("$cmd " . Builder::toolsDir(). "/vendor/bin/phpdoc run --cache-folder ".Builder::buildDir()."/.phpdoc -d ".$srcDir.'/src'." -t ".$docDir.'/api --title PHP-XMLRPC'); |
|
269 | + pake_sh("$cmd ".Builder::toolsDir()."/vendor/bin/phpdoc run --cache-folder ".Builder::buildDir()."/.phpdoc -d ".$srcDir.'/src'." -t ".$docDir.'/api --title PHP-XMLRPC'); |
|
270 | 270 | |
271 | 271 | // from phpdoc comments using Sami |
272 | 272 | // deprecated on 2021/12, as Sami is abandonware |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | /** |
348 | 348 | * Creates the tarballs for a release |
349 | 349 | */ |
350 | -function run_dist($task=null, $args=array(), $cliOpts=array()) |
|
350 | +function run_dist($task = null, $args = array(), $cliOpts = array()) |
|
351 | 351 | { |
352 | 352 | // copy workspace dir into dist dir, without git |
353 | 353 | pake_mkdirs(Builder::distDir()); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | // create tarballs |
362 | 362 | $cwd = getcwd(); |
363 | 363 | chdir(dirname(Builder::distDir())); |
364 | - foreach(Builder::distFiles() as $distFile) { |
|
364 | + foreach (Builder::distFiles() as $distFile) { |
|
365 | 365 | // php can not really create good zip files via phar: they are not compressed! |
366 | 366 | if (substr($distFile, -4) == '.zip') { |
367 | 367 | $cmd = Builder::tool('zip'); |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | chdir($cwd); |
380 | 380 | } |
381 | 381 | |
382 | -function run_clean_workspace($task=null, $args=array(), $cliOpts=array()) |
|
382 | +function run_clean_workspace($task = null, $args = array(), $cliOpts = array()) |
|
383 | 383 | { |
384 | 384 | pake_remove_dir(Builder::workspaceDir()); |
385 | 385 | } |
@@ -388,13 +388,13 @@ discard block |
||
388 | 388 | * Cleans up the whole build directory |
389 | 389 | * @todo 'make clean' usually just removes the results of the build, distclean removes all but sources |
390 | 390 | */ |
391 | -function run_clean($task=null, $args=array(), $cliOpts=array()) |
|
391 | +function run_clean($task = null, $args = array(), $cliOpts = array()) |
|
392 | 392 | { |
393 | 393 | pake_remove_dir(Builder::buildDir()); |
394 | 394 | } |
395 | 395 | |
396 | 396 | // helper task: display help text |
397 | -pake_task( 'default' ); |
|
397 | +pake_task('default'); |
|
398 | 398 | // internal task: parse cli options |
399 | 399 | pake_task('getopts'); |
400 | 400 | pake_task('init', 'getopts'); |