@@ -10,9 +10,9 @@ |
||
| 10 | 10 | { |
| 11 | 11 | protected XMLHelper_SimpleXML $xml; |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @var LibXMLError |
|
| 15 | - */ |
|
| 13 | + /** |
|
| 14 | + * @var LibXMLError |
|
| 15 | + */ |
|
| 16 | 16 | protected LibXMLError $nativeError; |
| 17 | 17 | |
| 18 | 18 | public function __construct(XMLHelper_SimpleXML $xml, LibXMLError $nativeError) |
@@ -42,18 +42,18 @@ discard block |
||
| 42 | 42 | protected bool $isValid = false; |
| 43 | 43 | protected bool $encodeUTF = false; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var array{code:int,message:string}|NULL |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var array{code:int,message:string}|NULL |
|
| 47 | + */ |
|
| 48 | 48 | protected ?array $error = null; |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Stores a list of all unicode characters in the URL |
|
| 52 | - * that have been filtered out before parsing it with |
|
| 53 | - * parse_url. |
|
| 54 | - * |
|
| 55 | - * @var array<string,string> |
|
| 56 | - */ |
|
| 50 | + /** |
|
| 51 | + * Stores a list of all unicode characters in the URL |
|
| 52 | + * that have been filtered out before parsing it with |
|
| 53 | + * parse_url. |
|
| 54 | + * |
|
| 55 | + * @var array<string,string> |
|
| 56 | + */ |
|
| 57 | 57 | protected array $unicodeChars = array(); |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * |
|
| 82 | - * @param string $url The target URL. |
|
| 83 | - * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 84 | - */ |
|
| 81 | + * |
|
| 82 | + * @param string $url The target URL. |
|
| 83 | + * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 84 | + */ |
|
| 85 | 85 | public function __construct(string $url, bool $encodeUTF) |
| 86 | 86 | { |
| 87 | 87 | $this->url = $url; |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | $this->validate(); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Retrieves the array as parsed by PHP's parse_url, |
|
| 97 | - * filtered and adjusted as necessary. |
|
| 98 | - * |
|
| 99 | - * @return array<string,mixed> |
|
| 100 | - */ |
|
| 95 | + /** |
|
| 96 | + * Retrieves the array as parsed by PHP's parse_url, |
|
| 97 | + * filtered and adjusted as necessary. |
|
| 98 | + * |
|
| 99 | + * @return array<string,mixed> |
|
| 100 | + */ |
|
| 101 | 101 | public function getInfo() : array |
| 102 | 102 | { |
| 103 | 103 | return $this->info; |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Finds any non-url encoded unicode characters in |
|
| 124 | - * the URL, and encodes them before the URL is |
|
| 125 | - * passed to parse_url. |
|
| 126 | - */ |
|
| 122 | + /** |
|
| 123 | + * Finds any non-url encoded unicode characters in |
|
| 124 | + * the URL, and encodes them before the URL is |
|
| 125 | + * passed to parse_url. |
|
| 126 | + */ |
|
| 127 | 127 | protected function filterUnicodeChars() : void |
| 128 | 128 | { |
| 129 | 129 | $chars = ConvertHelper::string2array($this->url); |
@@ -194,23 +194,23 @@ discard block |
||
| 194 | 194 | $this->isValid = true; |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - /** |
|
| 198 | - * Goes through all information in the parse_url result |
|
| 199 | - * array, and attempts to fix any user errors in formatting |
|
| 200 | - * that can be recovered from, mostly regarding stray spaces. |
|
| 201 | - */ |
|
| 197 | + /** |
|
| 198 | + * Goes through all information in the parse_url result |
|
| 199 | + * array, and attempts to fix any user errors in formatting |
|
| 200 | + * that can be recovered from, mostly regarding stray spaces. |
|
| 201 | + */ |
|
| 202 | 202 | protected function filterParsed() : void |
| 203 | 203 | { |
| 204 | 204 | $this->info = (new ParsedInfoFilter($this->url, $this->info))->filter(); |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - /** |
|
| 208 | - * Recursively goes through the array, and converts all previously |
|
| 209 | - * URL encoded characters with their unicode character counterparts. |
|
| 210 | - * |
|
| 211 | - * @param array<string,mixed> $subject |
|
| 212 | - * @return array<string,mixed> |
|
| 213 | - */ |
|
| 207 | + /** |
|
| 208 | + * Recursively goes through the array, and converts all previously |
|
| 209 | + * URL encoded characters with their unicode character counterparts. |
|
| 210 | + * |
|
| 211 | + * @param array<string,mixed> $subject |
|
| 212 | + * @return array<string,mixed> |
|
| 213 | + */ |
|
| 214 | 214 | protected function restoreUnicodeChars(array $subject) : array |
| 215 | 215 | { |
| 216 | 216 | $result = array(); |
@@ -234,13 +234,13 @@ discard block |
||
| 234 | 234 | return $result; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Replaces all URL encoded unicode characters |
|
| 239 | - * in the string with the unicode character. |
|
| 240 | - * |
|
| 241 | - * @param string $string |
|
| 242 | - * @return string |
|
| 243 | - */ |
|
| 237 | + /** |
|
| 238 | + * Replaces all URL encoded unicode characters |
|
| 239 | + * in the string with the unicode character. |
|
| 240 | + * |
|
| 241 | + * @param string $string |
|
| 242 | + * @return string |
|
| 243 | + */ |
|
| 244 | 244 | protected function restoreUnicodeChar(string $string) : string |
| 245 | 245 | { |
| 246 | 246 | if(strpos($string, '%') !== false) |
@@ -261,32 +261,32 @@ discard block |
||
| 261 | 261 | ); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - /** |
|
| 265 | - * Checks whether the URL that was parsed is valid. |
|
| 266 | - * @return bool |
|
| 267 | - */ |
|
| 264 | + /** |
|
| 265 | + * Checks whether the URL that was parsed is valid. |
|
| 266 | + * @return bool |
|
| 267 | + */ |
|
| 268 | 268 | public function isValid() : bool |
| 269 | 269 | { |
| 270 | 270 | return $this->isValid; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - /** |
|
| 274 | - * If the validation failed, retrieves the validation |
|
| 275 | - * error message. |
|
| 276 | - * |
|
| 277 | - * @return string |
|
| 278 | - */ |
|
| 273 | + /** |
|
| 274 | + * If the validation failed, retrieves the validation |
|
| 275 | + * error message. |
|
| 276 | + * |
|
| 277 | + * @return string |
|
| 278 | + */ |
|
| 279 | 279 | public function getErrorMessage() : string |
| 280 | 280 | { |
| 281 | 281 | return $this->error['message'] ?? ''; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - /** |
|
| 285 | - * If the validation failed, retrieves the validation |
|
| 286 | - * error code. |
|
| 287 | - * |
|
| 288 | - * @return int |
|
| 289 | - */ |
|
| 284 | + /** |
|
| 285 | + * If the validation failed, retrieves the validation |
|
| 286 | + * error code. |
|
| 287 | + * |
|
| 288 | + * @return int |
|
| 289 | + */ |
|
| 290 | 290 | public function getErrorCode() : int |
| 291 | 291 | { |
| 292 | 292 | return $this->error['code'] ?? -1; |
@@ -44,19 +44,19 @@ discard block |
||
| 44 | 44 | protected int $contentLength = 0; |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * @var array<string,string> |
|
| 48 | - */ |
|
| 47 | + * @var array<string,string> |
|
| 48 | + */ |
|
| 49 | 49 | protected $headers = array(); |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var resource|NULL |
|
| 53 | - */ |
|
| 51 | + /** |
|
| 52 | + * @var resource|NULL |
|
| 53 | + */ |
|
| 54 | 54 | protected $logfilePointer; |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Creates a new request helper to send POST data to the specified destination URL. |
|
| 58 | - * @param string $destinationURL |
|
| 59 | - */ |
|
| 56 | + /** |
|
| 57 | + * Creates a new request helper to send POST data to the specified destination URL. |
|
| 58 | + * @param string $destinationURL |
|
| 59 | + */ |
|
| 60 | 60 | public function __construct(string $destinationURL) |
| 61 | 61 | { |
| 62 | 62 | $this->destination = $destinationURL; |
@@ -79,13 +79,13 @@ discard block |
||
| 79 | 79 | return $this->eol; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Sets the timeout for the request, in seconds. If the request |
|
| 84 | - * takes longer, it will be cancelled and an exception triggered. |
|
| 85 | - * |
|
| 86 | - * @param int $seconds |
|
| 87 | - * @return RequestHelper |
|
| 88 | - */ |
|
| 82 | + /** |
|
| 83 | + * Sets the timeout for the request, in seconds. If the request |
|
| 84 | + * takes longer, it will be cancelled and an exception triggered. |
|
| 85 | + * |
|
| 86 | + * @param int $seconds |
|
| 87 | + * @return RequestHelper |
|
| 88 | + */ |
|
| 89 | 89 | public function setTimeout(int $seconds) : RequestHelper |
| 90 | 90 | { |
| 91 | 91 | $this->timeout = $seconds; |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | return $this->timeout; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Enables verbose logging of the CURL request, which |
|
| 103 | - * is then redirected to the target file. |
|
| 104 | - * |
|
| 105 | - * @param string $targetFile |
|
| 106 | - * @return RequestHelper |
|
| 107 | - */ |
|
| 101 | + /** |
|
| 102 | + * Enables verbose logging of the CURL request, which |
|
| 103 | + * is then redirected to the target file. |
|
| 104 | + * |
|
| 105 | + * @param string $targetFile |
|
| 106 | + * @return RequestHelper |
|
| 107 | + */ |
|
| 108 | 108 | public function enableLogging(string $targetFile) : RequestHelper |
| 109 | 109 | { |
| 110 | 110 | $this->logfile = $targetFile; |
@@ -112,15 +112,15 @@ discard block |
||
| 112 | 112 | return $this; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Adds a file to be sent with the request. |
|
| 117 | - * |
|
| 118 | - * @param string $varName The variable name to send the file in |
|
| 119 | - * @param string $fileName The name of the file as it should be received at the destination |
|
| 120 | - * @param string $content The raw content of the file |
|
| 121 | - * @param string $contentType The content type, use the constants to specify this |
|
| 122 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
| 123 | - */ |
|
| 115 | + /** |
|
| 116 | + * Adds a file to be sent with the request. |
|
| 117 | + * |
|
| 118 | + * @param string $varName The variable name to send the file in |
|
| 119 | + * @param string $fileName The name of the file as it should be received at the destination |
|
| 120 | + * @param string $content The raw content of the file |
|
| 121 | + * @param string $contentType The content type, use the constants to specify this |
|
| 122 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
| 123 | + */ |
|
| 124 | 124 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper |
| 125 | 125 | { |
| 126 | 126 | $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding); |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | return $this; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Sets an HTTP header to include in the request. |
|
| 163 | - * |
|
| 164 | - * @param string $name |
|
| 165 | - * @param string $value |
|
| 166 | - * @return RequestHelper |
|
| 167 | - */ |
|
| 161 | + /** |
|
| 162 | + * Sets an HTTP header to include in the request. |
|
| 163 | + * |
|
| 164 | + * @param string $name |
|
| 165 | + * @param string $value |
|
| 166 | + * @return RequestHelper |
|
| 167 | + */ |
|
| 168 | 168 | public function setHeader(string $name, string $value) : RequestHelper |
| 169 | 169 | { |
| 170 | 170 | $this->headers[$name] = $value; |
@@ -172,31 +172,31 @@ discard block |
||
| 172 | 172 | return $this; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Disables SSL certificate checking. |
|
| 177 | - * |
|
| 178 | - * @return RequestHelper |
|
| 179 | - */ |
|
| 175 | + /** |
|
| 176 | + * Disables SSL certificate checking. |
|
| 177 | + * |
|
| 178 | + * @return RequestHelper |
|
| 179 | + */ |
|
| 180 | 180 | public function disableSSLChecks() : RequestHelper |
| 181 | 181 | { |
| 182 | 182 | $this->verifySSL = false; |
| 183 | 183 | return $this; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Sends the POST request to the destination, and returns |
|
| 188 | - * the response text. |
|
| 189 | - * |
|
| 190 | - * The response object is stored internally, so after calling |
|
| 191 | - * this method it may be retrieved at any moment using the |
|
| 192 | - * {@link getResponse()} method. |
|
| 193 | - * |
|
| 194 | - * @return string |
|
| 195 | - * @see RequestHelper::getResponse() |
|
| 196 | - * @throws RequestHelper_Exception |
|
| 197 | - * |
|
| 198 | - * @see RequestHelper::ERROR_REQUEST_FAILED |
|
| 199 | - */ |
|
| 186 | + /** |
|
| 187 | + * Sends the POST request to the destination, and returns |
|
| 188 | + * the response text. |
|
| 189 | + * |
|
| 190 | + * The response object is stored internally, so after calling |
|
| 191 | + * this method it may be retrieved at any moment using the |
|
| 192 | + * {@link getResponse()} method. |
|
| 193 | + * |
|
| 194 | + * @return string |
|
| 195 | + * @see RequestHelper::getResponse() |
|
| 196 | + * @throws RequestHelper_Exception |
|
| 197 | + * |
|
| 198 | + * @see RequestHelper::ERROR_REQUEST_FAILED |
|
| 199 | + */ |
|
| 200 | 200 | public function send() : string |
| 201 | 201 | { |
| 202 | 202 | $info = parseURL($this->destination); |
@@ -236,26 +236,26 @@ discard block |
||
| 236 | 236 | return $this->response->getResponseBody(); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * Retrieves the request's body content. This is an alias |
|
| 241 | - * for {@see RequestHelper::getMimeBody()}. |
|
| 242 | - * |
|
| 243 | - * @return string |
|
| 244 | - * @see RequestHelper::getMimeBody() |
|
| 245 | - */ |
|
| 239 | + /** |
|
| 240 | + * Retrieves the request's body content. This is an alias |
|
| 241 | + * for {@see RequestHelper::getMimeBody()}. |
|
| 242 | + * |
|
| 243 | + * @return string |
|
| 244 | + * @see RequestHelper::getMimeBody() |
|
| 245 | + */ |
|
| 246 | 246 | public function getBody() : string |
| 247 | 247 | { |
| 248 | 248 | return $this->getMimeBody(); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * Creates a new CURL resource configured according to the |
|
| 253 | - * request's settings. |
|
| 254 | - * |
|
| 255 | - * @param URLInfo $url |
|
| 256 | - * @throws RequestHelper_Exception |
|
| 257 | - * @return resource |
|
| 258 | - */ |
|
| 251 | + /** |
|
| 252 | + * Creates a new CURL resource configured according to the |
|
| 253 | + * request's settings. |
|
| 254 | + * |
|
| 255 | + * @param URLInfo $url |
|
| 256 | + * @throws RequestHelper_Exception |
|
| 257 | + * @return resource |
|
| 258 | + */ |
|
| 259 | 259 | protected function createCURL(URLInfo $url) |
| 260 | 260 | { |
| 261 | 261 | $ch = curl_init(); |
@@ -334,13 +334,13 @@ discard block |
||
| 334 | 334 | return true; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - /** |
|
| 338 | - * Compiles the associative headers array into |
|
| 339 | - * the format understood by CURL, namely an indexed |
|
| 340 | - * array with one header string per entry. |
|
| 341 | - * |
|
| 342 | - * @return string[] |
|
| 343 | - */ |
|
| 337 | + /** |
|
| 338 | + * Compiles the associative headers array into |
|
| 339 | + * the format understood by CURL, namely an indexed |
|
| 340 | + * array with one header string per entry. |
|
| 341 | + * |
|
| 342 | + * @return string[] |
|
| 343 | + */ |
|
| 344 | 344 | protected function renderHeaders() : array |
| 345 | 345 | { |
| 346 | 346 | $result = array(); |
@@ -354,12 +354,12 @@ discard block |
||
| 354 | 354 | return $result; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - /** |
|
| 358 | - * Retrieves the raw response header, in the form of an indexed |
|
| 359 | - * array containing all response header lines. |
|
| 360 | - * |
|
| 361 | - * @return string[] |
|
| 362 | - */ |
|
| 357 | + /** |
|
| 358 | + * Retrieves the raw response header, in the form of an indexed |
|
| 359 | + * array containing all response header lines. |
|
| 360 | + * |
|
| 361 | + * @return string[] |
|
| 362 | + */ |
|
| 363 | 363 | public function getResponseHeader() : array |
| 364 | 364 | { |
| 365 | 365 | $response = $this->getResponse(); |
@@ -371,33 +371,33 @@ discard block |
||
| 371 | 371 | return array(); |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - /** |
|
| 375 | - * After calling the {@link send()} method, this may be used to |
|
| 376 | - * retrieve the response text from the POST request. |
|
| 377 | - * |
|
| 378 | - * @return RequestHelper_Response|NULL |
|
| 379 | - */ |
|
| 374 | + /** |
|
| 375 | + * After calling the {@link send()} method, this may be used to |
|
| 376 | + * retrieve the response text from the POST request. |
|
| 377 | + * |
|
| 378 | + * @return RequestHelper_Response|NULL |
|
| 379 | + */ |
|
| 380 | 380 | public function getResponse() : ?RequestHelper_Response |
| 381 | 381 | { |
| 382 | 382 | return $this->response; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - /** |
|
| 386 | - * Retrieves all headers set until now. |
|
| 387 | - * |
|
| 388 | - * @return array<string,string> |
|
| 389 | - */ |
|
| 385 | + /** |
|
| 386 | + * Retrieves all headers set until now. |
|
| 387 | + * |
|
| 388 | + * @return array<string,string> |
|
| 389 | + */ |
|
| 390 | 390 | public function getHeaders() : array |
| 391 | 391 | { |
| 392 | 392 | return $this->headers; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - /** |
|
| 396 | - * Retrieves the value of a header by its name. |
|
| 397 | - * |
|
| 398 | - * @param string $name |
|
| 399 | - * @return string The header value, or an empty string if not set. |
|
| 400 | - */ |
|
| 395 | + /** |
|
| 396 | + * Retrieves the value of a header by its name. |
|
| 397 | + * |
|
| 398 | + * @param string $name |
|
| 399 | + * @return string The header value, or an empty string if not set. |
|
| 400 | + */ |
|
| 401 | 401 | public function getHeader(string $name) : string |
| 402 | 402 | { |
| 403 | 403 | return $this->headers[$name] ?? ''; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | $output = curl_exec($ch); |
| 207 | 207 | |
| 208 | - if(isset($this->logfilePointer)) |
|
| 208 | + if (isset($this->logfilePointer)) |
|
| 209 | 209 | { |
| 210 | 210 | fclose($this->logfilePointer); |
| 211 | 211 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | // CURL will complain about an empty response when the |
| 218 | 218 | // server sends a 100-continue code. That should not be |
| 219 | 219 | // regarded as an error. |
| 220 | - if($output === false && $this->response->getCode() !== 100) |
|
| 220 | + if ($output === false && $this->response->getCode() !== 100) |
|
| 221 | 221 | { |
| 222 | 222 | $curlCode = curl_errno($ch); |
| 223 | 223 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | { |
| 261 | 261 | $ch = curl_init(); |
| 262 | 262 | |
| 263 | - if(!is_resource($ch)) |
|
| 263 | + if (!is_resource($ch)) |
|
| 264 | 264 | { |
| 265 | 265 | throw new RequestHelper_Exception( |
| 266 | 266 | 'Could not initialize a new cURL instance.', |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | $this->setHeader('Content-Length', (string)$this->boundaries->getContentLength()); |
| 273 | - $this->setHeader('Content-Type', 'multipart/form-data; boundary=' . $this->mimeBoundary); |
|
| 273 | + $this->setHeader('Content-Type', 'multipart/form-data; boundary='.$this->mimeBoundary); |
|
| 274 | 274 | |
| 275 | 275 | curl_setopt($ch, CURLOPT_POST, true); |
| 276 | 276 | curl_setopt($ch, CURLOPT_URL, $url->getNormalizedWithoutAuth()); |
@@ -283,18 +283,18 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $loggingEnabled = $this->configureLogging($ch); |
| 285 | 285 | |
| 286 | - if(!$loggingEnabled) |
|
| 286 | + if (!$loggingEnabled) |
|
| 287 | 287 | { |
| 288 | 288 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if($this->verifySSL) |
|
| 291 | + if ($this->verifySSL) |
|
| 292 | 292 | { |
| 293 | 293 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); |
| 294 | 294 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - if($url->hasUsername()) |
|
| 297 | + if ($url->hasUsername()) |
|
| 298 | 298 | { |
| 299 | 299 | curl_setopt($ch, CURLOPT_USERNAME, $url->getUsername()); |
| 300 | 300 | curl_setopt($ch, CURLOPT_PASSWORD, $url->getPassword()); |
@@ -310,14 +310,14 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | protected function configureLogging($ch) : bool |
| 312 | 312 | { |
| 313 | - if(empty($this->logfile)) |
|
| 313 | + if (empty($this->logfile)) |
|
| 314 | 314 | { |
| 315 | 315 | return false; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | $res = fopen($this->logfile, 'wb+'); |
| 319 | 319 | |
| 320 | - if($res === false) |
|
| 320 | + if ($res === false) |
|
| 321 | 321 | { |
| 322 | 322 | throw new RequestHelper_Exception( |
| 323 | 323 | 'Cannot open logfile for writing.', |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | $this->setHeader('Expect', ''); |
| 349 | 349 | |
| 350 | - foreach($this->headers as $name => $value) { |
|
| 350 | + foreach ($this->headers as $name => $value) { |
|
| 351 | 351 | $result[] = $name.': '.$value; |
| 352 | 352 | } |
| 353 | 353 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | { |
| 365 | 365 | $response = $this->getResponse(); |
| 366 | 366 | |
| 367 | - if($response !== null) { |
|
| 367 | + if ($response !== null) { |
|
| 368 | 368 | return $response->getHeaders(); |
| 369 | 369 | } |
| 370 | 370 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public const ERROR_OPENING_ZIP_FILE = 338003; |
| 34 | 34 | |
| 35 | - public const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
| 35 | + public const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @var array<string,mixed> |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
| 87 | 87 | */ |
| 88 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
| 88 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
| 89 | 89 | { |
| 90 | 90 | $this->open(); |
| 91 | 91 | |
@@ -138,16 +138,16 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | protected function open() : void |
| 140 | 140 | { |
| 141 | - if($this->open) { |
|
| 141 | + if ($this->open) { |
|
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if(!isset($this->zip)) { |
|
| 145 | + if (!isset($this->zip)) { |
|
| 146 | 146 | $this->zip = new ZipArchive(); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $flag = null; |
| 150 | - if(!file_exists($this->file)) { |
|
| 150 | + if (!file_exists($this->file)) { |
|
| 151 | 151 | $flag = ZipArchive::CREATE; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | { |
| 191 | 191 | $this->fileTracker++; |
| 192 | 192 | |
| 193 | - if($this->options['WriteThreshold'] < 1) { |
|
| 193 | + if ($this->options['WriteThreshold'] < 1) { |
|
| 194 | 194 | return; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | protected function close() : void |
| 205 | 205 | { |
| 206 | - if(!$this->open) { |
|
| 206 | + if (!$this->open) { |
|
| 207 | 207 | return; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | throw new ZIPHelper_Exception( |
| 213 | 213 | 'Could not save ZIP file to disk', |
| 214 | 214 | sprintf( |
| 215 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
| 216 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
| 215 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
| 216 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
| 217 | 217 | 'or trying to save to a directory that does not exist.', |
| 218 | 218 | $this->file |
| 219 | 219 | ), |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | { |
| 229 | 229 | $this->open(); |
| 230 | 230 | |
| 231 | - if($this->countFiles() < 1) |
|
| 231 | + if ($this->countFiles() < 1) |
|
| 232 | 232 | { |
| 233 | 233 | throw new ZIPHelper_Exception( |
| 234 | 234 | 'No files in the zip file', |
@@ -254,18 +254,18 @@ discard block |
||
| 254 | 254 | * @throws ZIPHelper_Exception |
| 255 | 255 | * @return string The file name that was sent (useful in case none was specified). |
| 256 | 256 | */ |
| 257 | - public function download(?string $fileName=null) : string |
|
| 257 | + public function download(?string $fileName = null) : string |
|
| 258 | 258 | { |
| 259 | 259 | $this->save(); |
| 260 | 260 | |
| 261 | - if(empty($fileName)) |
|
| 261 | + if (empty($fileName)) |
|
| 262 | 262 | { |
| 263 | 263 | $fileName = basename($this->file); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | header('Content-type: application/zip'); |
| 267 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
| 268 | - header('Content-length: ' . filesize($this->file)); |
|
| 267 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
| 268 | + header('Content-length: '.filesize($this->file)); |
|
| 269 | 269 | header('Pragma: no-cache'); |
| 270 | 270 | header('Expires: 0'); |
| 271 | 271 | readfile($this->file); |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | * @throws ZIPHelper_Exception |
| 284 | 284 | * @see ZIPHelper::download() |
| 285 | 285 | */ |
| 286 | - public function downloadAndDelete(?string $fileName=null) : ZIPHelper |
|
| 286 | + public function downloadAndDelete(?string $fileName = null) : ZIPHelper |
|
| 287 | 287 | { |
| 288 | 288 | $this->download($fileName); |
| 289 | 289 | |
@@ -300,9 +300,9 @@ discard block |
||
| 300 | 300 | * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
| 301 | 301 | * @return boolean |
| 302 | 302 | */ |
| 303 | - public function extractAll(?string $outputFolder=null) : bool |
|
| 303 | + public function extractAll(?string $outputFolder = null) : bool |
|
| 304 | 304 | { |
| 305 | - if(empty($outputFolder)) { |
|
| 305 | + if (empty($outputFolder)) { |
|
| 306 | 306 | $outputFolder = dirname($this->file); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | { |
| 24 | 24 | use Traits_Optionable; |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var array<string,mixed> |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var array<string,mixed> |
|
| 28 | + */ |
|
| 29 | 29 | private array $overrides = array(); |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var Request_RefreshParams_Exclude[] |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var Request_RefreshParams_Exclude[] |
|
| 33 | + */ |
|
| 34 | 34 | private array $excludes = array(); |
| 35 | 35 | |
| 36 | 36 | public function getDefaultOptions() : array |
@@ -41,27 +41,27 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Whether to automatically exclude the session variable |
|
| 46 | - * from the parameters. |
|
| 47 | - * |
|
| 48 | - * @param bool $exclude |
|
| 49 | - * @return Request_RefreshParams |
|
| 50 | - */ |
|
| 44 | + /** |
|
| 45 | + * Whether to automatically exclude the session variable |
|
| 46 | + * from the parameters. |
|
| 47 | + * |
|
| 48 | + * @param bool $exclude |
|
| 49 | + * @return Request_RefreshParams |
|
| 50 | + */ |
|
| 51 | 51 | public function setExcludeSessionName(bool $exclude=true) : Request_RefreshParams |
| 52 | 52 | { |
| 53 | 53 | $this->setOption('exclude-session-name', $exclude); |
| 54 | 54 | return $this; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Whether to automatically exclude the HTML_QuickForm2 |
|
| 59 | - * request variable used to track whether a form has been |
|
| 60 | - * submitted. |
|
| 61 | - * |
|
| 62 | - * @param bool $exclude |
|
| 63 | - * @return Request_RefreshParams |
|
| 64 | - */ |
|
| 57 | + /** |
|
| 58 | + * Whether to automatically exclude the HTML_QuickForm2 |
|
| 59 | + * request variable used to track whether a form has been |
|
| 60 | + * submitted. |
|
| 61 | + * |
|
| 62 | + * @param bool $exclude |
|
| 63 | + * @return Request_RefreshParams |
|
| 64 | + */ |
|
| 65 | 65 | public function setExcludeQuickform(bool $exclude) : Request_RefreshParams |
| 66 | 66 | { |
| 67 | 67 | $this->setOption('exclude-quickform-submitter', $exclude); |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | return $this; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Excludes a request parameter by name. |
|
| 104 | - * |
|
| 105 | - * @param array<int,string|number> $paramNames |
|
| 106 | - * @return Request_RefreshParams |
|
| 107 | - */ |
|
| 102 | + /** |
|
| 103 | + * Excludes a request parameter by name. |
|
| 104 | + * |
|
| 105 | + * @param array<int,string|number> $paramNames |
|
| 106 | + * @return Request_RefreshParams |
|
| 107 | + */ |
|
| 108 | 108 | public function excludeParamsByName(array $paramNames) : Request_RefreshParams |
| 109 | 109 | { |
| 110 | 110 | foreach($paramNames as $name) |
@@ -115,15 +115,15 @@ discard block |
||
| 115 | 115 | return $this; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Overrides a parameter: even if it exists, this |
|
| 120 | - * value will be used instead - even if it is on |
|
| 121 | - * the list of excluded parameters. |
|
| 122 | - * |
|
| 123 | - * @param string $paramName |
|
| 124 | - * @param mixed $paramValue |
|
| 125 | - * @return Request_RefreshParams |
|
| 126 | - */ |
|
| 118 | + /** |
|
| 119 | + * Overrides a parameter: even if it exists, this |
|
| 120 | + * value will be used instead - even if it is on |
|
| 121 | + * the list of excluded parameters. |
|
| 122 | + * |
|
| 123 | + * @param string $paramName |
|
| 124 | + * @param mixed $paramValue |
|
| 125 | + * @return Request_RefreshParams |
|
| 126 | + */ |
|
| 127 | 127 | public function overrideParam(string $paramName, $paramValue) : Request_RefreshParams |
| 128 | 128 | { |
| 129 | 129 | $this->overrides[$paramName] = $paramValue; |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | return $this; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Overrides an array of parameters. |
|
| 136 | - * |
|
| 137 | - * @param array<string|number,mixed> $params |
|
| 138 | - * @return Request_RefreshParams |
|
| 139 | - */ |
|
| 134 | + /** |
|
| 135 | + * Overrides an array of parameters. |
|
| 136 | + * |
|
| 137 | + * @param array<string|number,mixed> $params |
|
| 138 | + * @return Request_RefreshParams |
|
| 139 | + */ |
|
| 140 | 140 | public function overrideParams(array $params) : Request_RefreshParams |
| 141 | 141 | { |
| 142 | 142 | foreach($params as $name => $value) |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | return $this; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Resolves all the parameter exclusions that should |
|
| 152 | - * be applied to the list of parameters. This includes |
|
| 153 | - * the manually added exclusions and the dynamic exclusions |
|
| 154 | - * like the session name. |
|
| 155 | - * |
|
| 156 | - * @return Request_RefreshParams_Exclude[] |
|
| 157 | - */ |
|
| 150 | + /** |
|
| 151 | + * Resolves all the parameter exclusions that should |
|
| 152 | + * be applied to the list of parameters. This includes |
|
| 153 | + * the manually added exclusions and the dynamic exclusions |
|
| 154 | + * like the session name. |
|
| 155 | + * |
|
| 156 | + * @return Request_RefreshParams_Exclude[] |
|
| 157 | + */ |
|
| 158 | 158 | private function resolveExcludes() : array |
| 159 | 159 | { |
| 160 | 160 | $excludes = $this->excludes; |
@@ -165,12 +165,12 @@ discard block |
||
| 165 | 165 | return $excludes; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Automatically excludes the session name from the |
|
| 170 | - * parameters, if present. |
|
| 171 | - * |
|
| 172 | - * @param Request_RefreshParams_Exclude[] $excludes |
|
| 173 | - */ |
|
| 168 | + /** |
|
| 169 | + * Automatically excludes the session name from the |
|
| 170 | + * parameters, if present. |
|
| 171 | + * |
|
| 172 | + * @param Request_RefreshParams_Exclude[] $excludes |
|
| 173 | + */ |
|
| 174 | 174 | private function autoExcludeSessionName(array &$excludes) : void |
| 175 | 175 | { |
| 176 | 176 | if($this->getBoolOption('exclude-session-name')) |
@@ -179,12 +179,12 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Automatically excludes the HTML_QuickForm2 submit |
|
| 184 | - * tracking variable, when enabled. |
|
| 185 | - * |
|
| 186 | - * @param Request_RefreshParams_Exclude[] $excludes |
|
| 187 | - */ |
|
| 182 | + /** |
|
| 183 | + * Automatically excludes the HTML_QuickForm2 submit |
|
| 184 | + * tracking variable, when enabled. |
|
| 185 | + * |
|
| 186 | + * @param Request_RefreshParams_Exclude[] $excludes |
|
| 187 | + */ |
|
| 188 | 188 | private function autoExcludeQuickform(array &$excludes) : void |
| 189 | 189 | { |
| 190 | 190 | if($this->getBoolOption('exclude-quickform-submitter')) |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * Retrieves the list of parameters matching the |
|
| 201 | - * current settings. |
|
| 202 | - * |
|
| 203 | - * @return array<string,mixed> |
|
| 204 | - */ |
|
| 199 | + /** |
|
| 200 | + * Retrieves the list of parameters matching the |
|
| 201 | + * current settings. |
|
| 202 | + * |
|
| 203 | + * @return array<string,mixed> |
|
| 204 | + */ |
|
| 205 | 205 | public function getParams() : array |
| 206 | 206 | { |
| 207 | 207 | $params = $this->removeExcluded($_REQUEST); |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | return $params; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * Removes all excluded parameters from the array. |
|
| 222 | - * |
|
| 223 | - * @param array<string,mixed> $params |
|
| 224 | - * @return array<string,mixed> |
|
| 225 | - */ |
|
| 220 | + /** |
|
| 221 | + * Removes all excluded parameters from the array. |
|
| 222 | + * |
|
| 223 | + * @param array<string,mixed> $params |
|
| 224 | + * @return array<string,mixed> |
|
| 225 | + */ |
|
| 226 | 226 | private function removeExcluded(array $params) : array |
| 227 | 227 | { |
| 228 | 228 | $result = array(); |
@@ -240,14 +240,14 @@ discard block |
||
| 240 | 240 | return $result; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * Checks all configured exclusions to see if the |
|
| 245 | - * parameter should be excluded or not. |
|
| 246 | - * |
|
| 247 | - * @param string $paramName |
|
| 248 | - * @param mixed $paramValue |
|
| 249 | - * @return bool |
|
| 250 | - */ |
|
| 243 | + /** |
|
| 244 | + * Checks all configured exclusions to see if the |
|
| 245 | + * parameter should be excluded or not. |
|
| 246 | + * |
|
| 247 | + * @param string $paramName |
|
| 248 | + * @param mixed $paramValue |
|
| 249 | + * @return bool |
|
| 250 | + */ |
|
| 251 | 251 | public function isExcluded(string $paramName, $paramValue) : bool |
| 252 | 252 | { |
| 253 | 253 | $excludes = $this->resolveExcludes(); |
@@ -20,9 +20,9 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class Request_RefreshParams_Exclude_Callback extends Request_RefreshParams_Exclude |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var callable |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var callable |
|
| 25 | + */ |
|
| 26 | 26 | private $callback; |
| 27 | 27 | |
| 28 | 28 | public function __construct(callable $callback) |
@@ -6,9 +6,9 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | abstract class VariableInfo_Renderer |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * @var mixed|NULL |
|
| 11 | - */ |
|
| 9 | + /** |
|
| 10 | + * @var mixed|NULL |
|
| 11 | + */ |
|
| 12 | 12 | protected $value; |
| 13 | 13 | |
| 14 | 14 | protected VariableInfo $info; |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | abstract protected function init() : void; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Renders the value to the target format. |
|
| 29 | - * |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 27 | + /** |
|
| 28 | + * Renders the value to the target format. |
|
| 29 | + * |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | 32 | public function render() : string |
| 33 | 33 | { |
| 34 | 34 | return $this->_render(); |
@@ -18,15 +18,15 @@ |
||
| 18 | 18 | * @param int $level |
| 19 | 19 | * @return array<mixed> |
| 20 | 20 | */ |
| 21 | - protected function traverseArray(array $array, int $level=0) : array |
|
| 21 | + protected function traverseArray(array $array, int $level = 0) : array |
|
| 22 | 22 | { |
| 23 | 23 | $result = array(); |
| 24 | 24 | |
| 25 | - foreach($array as $key => $val) |
|
| 25 | + foreach ($array as $key => $val) |
|
| 26 | 26 | { |
| 27 | - if(is_array($val)) |
|
| 27 | + if (is_array($val)) |
|
| 28 | 28 | { |
| 29 | - $result[$key] = $this->traverseArray($val, ($level+1)); |
|
| 29 | + $result[$key] = $this->traverseArray($val, ($level + 1)); |
|
| 30 | 30 | } |
| 31 | 31 | else |
| 32 | 32 | { |