@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class OperationResult_Collection extends OperationResult |
28 | 28 | { |
29 | - /** |
|
30 | - * @var OperationResult[] |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var OperationResult[] |
|
31 | + */ |
|
32 | 32 | protected $results = array(); |
33 | 33 | |
34 | 34 | public function makeError(string $message, int $code=0) : OperationResult |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | return $this; |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * @return OperationResult[] |
|
111 | - */ |
|
109 | + /** |
|
110 | + * @return OperationResult[] |
|
111 | + */ |
|
112 | 112 | public function getResults() : array |
113 | 113 | { |
114 | 114 | return $this->results; |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | */ |
40 | 40 | protected static $instance; |
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $baseURL = ''; |
46 | 46 | |
47 | 47 | public function __construct() |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | $this->init(); |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * Can be extended in a subclass, to avoid |
|
56 | - * redefining the constructor. |
|
57 | - */ |
|
54 | + /** |
|
55 | + * Can be extended in a subclass, to avoid |
|
56 | + * redefining the constructor. |
|
57 | + */ |
|
58 | 58 | protected function init() |
59 | 59 | { |
60 | 60 | |
@@ -126,30 +126,30 @@ discard block |
||
126 | 126 | return $this->buildURL($params, $dispatcher); |
127 | 127 | } |
128 | 128 | |
129 | - /** |
|
130 | - * Retrieves the name of the current dispatcher script / page. |
|
131 | - * This is made to be extended and implemented in a subclass. |
|
132 | - * |
|
133 | - * @return string |
|
134 | - */ |
|
129 | + /** |
|
130 | + * Retrieves the name of the current dispatcher script / page. |
|
131 | + * This is made to be extended and implemented in a subclass. |
|
132 | + * |
|
133 | + * @return string |
|
134 | + */ |
|
135 | 135 | public function getDispatcher() : string |
136 | 136 | { |
137 | 137 | return ''; |
138 | 138 | } |
139 | 139 | |
140 | - /** |
|
141 | - * Filters and retrieves the current request variables |
|
142 | - * to be used to build an URL to refresh the current page. |
|
143 | - * |
|
144 | - * For further customization options, use the |
|
145 | - * {@see Request::createRefreshParams()} method. |
|
146 | - * |
|
147 | - * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result. |
|
148 | - * @param string[] $exclude Names of parameters to exclude from the result. |
|
149 | - * @return array<string,mixed> |
|
150 | - * |
|
151 | - * @see Request::createRefreshParams() |
|
152 | - */ |
|
140 | + /** |
|
141 | + * Filters and retrieves the current request variables |
|
142 | + * to be used to build an URL to refresh the current page. |
|
143 | + * |
|
144 | + * For further customization options, use the |
|
145 | + * {@see Request::createRefreshParams()} method. |
|
146 | + * |
|
147 | + * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result. |
|
148 | + * @param string[] $exclude Names of parameters to exclude from the result. |
|
149 | + * @return array<string,mixed> |
|
150 | + * |
|
151 | + * @see Request::createRefreshParams() |
|
152 | + */ |
|
153 | 153 | public function getRefreshParams(array $params = array(), array $exclude = array()) |
154 | 154 | { |
155 | 155 | return $this->createRefreshParams() |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | ->getParams(); |
159 | 159 | } |
160 | 160 | |
161 | - /** |
|
162 | - * Creates an instance of the helper that can be used to |
|
163 | - * retrieve the request's parameters collection, with the |
|
164 | - * possiblity to exlude and override some by rules. |
|
165 | - * |
|
166 | - * @return Request_RefreshParams |
|
167 | - */ |
|
161 | + /** |
|
162 | + * Creates an instance of the helper that can be used to |
|
163 | + * retrieve the request's parameters collection, with the |
|
164 | + * possiblity to exlude and override some by rules. |
|
165 | + * |
|
166 | + * @return Request_RefreshParams |
|
167 | + */ |
|
168 | 168 | public function createRefreshParams() : Request_RefreshParams |
169 | 169 | { |
170 | 170 | return new Request_RefreshParams(); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | return $url; |
198 | 198 | } |
199 | 199 | |
200 | - /** |
|
201 | - * Retrieves the base URL of the application. |
|
202 | - * @return string |
|
203 | - */ |
|
200 | + /** |
|
201 | + * Retrieves the base URL of the application. |
|
202 | + * @return string |
|
203 | + */ |
|
204 | 204 | public function getBaseURL() : string |
205 | 205 | { |
206 | 206 | return $this->baseURL; |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | return $this->knownParams[$name]; |
231 | 231 | } |
232 | 232 | |
233 | - /** |
|
234 | - * Retrieves a previously registered parameter instance. |
|
235 | - * |
|
236 | - * @param string $name |
|
237 | - * @throws Request_Exception |
|
238 | - * @return Request_Param |
|
239 | - */ |
|
233 | + /** |
|
234 | + * Retrieves a previously registered parameter instance. |
|
235 | + * |
|
236 | + * @param string $name |
|
237 | + * @throws Request_Exception |
|
238 | + * @return Request_Param |
|
239 | + */ |
|
240 | 240 | public function getRegisteredParam(string $name) : Request_Param |
241 | 241 | { |
242 | 242 | if(isset($this->knownParams[$name])) { |
@@ -253,48 +253,48 @@ discard block |
||
253 | 253 | ); |
254 | 254 | } |
255 | 255 | |
256 | - /** |
|
257 | - * Checks whether a parameter with the specified name |
|
258 | - * has been registered. |
|
259 | - * |
|
260 | - * @param string $name |
|
261 | - * @return bool |
|
262 | - */ |
|
256 | + /** |
|
257 | + * Checks whether a parameter with the specified name |
|
258 | + * has been registered. |
|
259 | + * |
|
260 | + * @param string $name |
|
261 | + * @return bool |
|
262 | + */ |
|
263 | 263 | public function hasRegisteredParam(string $name) : bool |
264 | 264 | { |
265 | 265 | return isset($this->knownParams[$name]); |
266 | 266 | } |
267 | 267 | |
268 | - /** |
|
269 | - * Retrieves an indexed array with accept mime types |
|
270 | - * that the client sent, in the order of preference |
|
271 | - * the client specified. |
|
272 | - * |
|
273 | - * Example: |
|
274 | - * |
|
275 | - * array( |
|
276 | - * 'text/html', |
|
277 | - * 'application/xhtml+xml', |
|
278 | - * 'image/webp' |
|
279 | - * ... |
|
280 | - * ) |
|
281 | - * |
|
282 | - * @return array |
|
283 | - * @see Request::parseAcceptHeaders() |
|
284 | - */ |
|
268 | + /** |
|
269 | + * Retrieves an indexed array with accept mime types |
|
270 | + * that the client sent, in the order of preference |
|
271 | + * the client specified. |
|
272 | + * |
|
273 | + * Example: |
|
274 | + * |
|
275 | + * array( |
|
276 | + * 'text/html', |
|
277 | + * 'application/xhtml+xml', |
|
278 | + * 'image/webp' |
|
279 | + * ... |
|
280 | + * ) |
|
281 | + * |
|
282 | + * @return array |
|
283 | + * @see Request::parseAcceptHeaders() |
|
284 | + */ |
|
285 | 285 | public static function getAcceptHeaders() : array |
286 | 286 | { |
287 | 287 | return self::parseAcceptHeaders()->getMimeStrings(); |
288 | 288 | } |
289 | 289 | |
290 | - /** |
|
291 | - * Returns an instance of the accept headers parser, |
|
292 | - * to access information on the browser's accepted |
|
293 | - * mime types. |
|
294 | - * |
|
295 | - * @return Request_AcceptHeaders |
|
296 | - * @see Request::getAcceptHeaders() |
|
297 | - */ |
|
290 | + /** |
|
291 | + * Returns an instance of the accept headers parser, |
|
292 | + * to access information on the browser's accepted |
|
293 | + * mime types. |
|
294 | + * |
|
295 | + * @return Request_AcceptHeaders |
|
296 | + * @see Request::getAcceptHeaders() |
|
297 | + */ |
|
298 | 298 | public static function parseAcceptHeaders() : Request_AcceptHeaders |
299 | 299 | { |
300 | 300 | static $accept; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | |
345 | - /** |
|
346 | - * Removes a single parameter from the request. |
|
347 | - * If the parameter has been registered, also |
|
348 | - * removes the registration info. |
|
349 | - * |
|
350 | - * @param string $name |
|
351 | - * @return Request |
|
352 | - */ |
|
345 | + /** |
|
346 | + * Removes a single parameter from the request. |
|
347 | + * If the parameter has been registered, also |
|
348 | + * removes the registration info. |
|
349 | + * |
|
350 | + * @param string $name |
|
351 | + * @return Request |
|
352 | + */ |
|
353 | 353 | public function removeParam(string $name) : Request |
354 | 354 | { |
355 | 355 | if(isset($_REQUEST[$name])) { |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | return $this; |
364 | 364 | } |
365 | 365 | |
366 | - /** |
|
367 | - * Removes several parameters from the request. |
|
368 | - * |
|
369 | - * @param string[] $names |
|
370 | - * @return Request |
|
371 | - */ |
|
366 | + /** |
|
367 | + * Removes several parameters from the request. |
|
368 | + * |
|
369 | + * @param string[] $names |
|
370 | + * @return Request |
|
371 | + */ |
|
372 | 372 | public function removeParams(array $names) : Request |
373 | 373 | { |
374 | 374 | foreach($names as $name) { |
@@ -435,18 +435,18 @@ discard block |
||
435 | 435 | return $val; |
436 | 436 | } |
437 | 437 | |
438 | - /** |
|
439 | - * Treats the request parameter as a JSON string, and |
|
440 | - * if it exists and contains valid JSON, returns the |
|
441 | - * decoded JSON value as an array (default). |
|
442 | - * |
|
443 | - * @param string $name |
|
444 | - * @param bool $assoc |
|
445 | - * @return array|object |
|
446 | - * |
|
447 | - * @see Request::getJSONAssoc() |
|
448 | - * @see Request::getJSONObject() |
|
449 | - */ |
|
438 | + /** |
|
439 | + * Treats the request parameter as a JSON string, and |
|
440 | + * if it exists and contains valid JSON, returns the |
|
441 | + * decoded JSON value as an array (default). |
|
442 | + * |
|
443 | + * @param string $name |
|
444 | + * @param bool $assoc |
|
445 | + * @return array|object |
|
446 | + * |
|
447 | + * @see Request::getJSONAssoc() |
|
448 | + * @see Request::getJSONObject() |
|
449 | + */ |
|
450 | 450 | public function getJSON(string $name, bool $assoc=true) |
451 | 451 | { |
452 | 452 | $value = $this->getParam($name); |
@@ -471,13 +471,13 @@ discard block |
||
471 | 471 | return new \stdClass(); |
472 | 472 | } |
473 | 473 | |
474 | - /** |
|
475 | - * Like {@link Request::getJSON()}, but omitting the second |
|
476 | - * parameter. Use this for more readable code. |
|
477 | - * |
|
478 | - * @param string $name |
|
479 | - * @return array |
|
480 | - */ |
|
474 | + /** |
|
475 | + * Like {@link Request::getJSON()}, but omitting the second |
|
476 | + * parameter. Use this for more readable code. |
|
477 | + * |
|
478 | + * @param string $name |
|
479 | + * @return array |
|
480 | + */ |
|
481 | 481 | public function getJSONAssoc(string $name) : array |
482 | 482 | { |
483 | 483 | $result = $this->getJSON($name); |
@@ -488,13 +488,13 @@ discard block |
||
488 | 488 | return array(); |
489 | 489 | } |
490 | 490 | |
491 | - /** |
|
492 | - * Like {@link Request::getJSON()}, but omitting the second |
|
493 | - * parameter. Use this for more readable code. |
|
494 | - * |
|
495 | - * @param string $name |
|
496 | - * @return object |
|
497 | - */ |
|
491 | + /** |
|
492 | + * Like {@link Request::getJSON()}, but omitting the second |
|
493 | + * parameter. Use this for more readable code. |
|
494 | + * |
|
495 | + * @param string $name |
|
496 | + * @return object |
|
497 | + */ |
|
498 | 498 | public function getJSONObject(string $name) : object |
499 | 499 | { |
500 | 500 | $result = $this->getJSON($name, false); |
@@ -505,12 +505,12 @@ discard block |
||
505 | 505 | return new \stdClass(); |
506 | 506 | } |
507 | 507 | |
508 | - /** |
|
509 | - * Sends a JSON response with the correct headers. |
|
510 | - * |
|
511 | - * @param array|string $data |
|
512 | - * @param bool $exit Whether to exit the script afterwards. |
|
513 | - */ |
|
508 | + /** |
|
509 | + * Sends a JSON response with the correct headers. |
|
510 | + * |
|
511 | + * @param array|string $data |
|
512 | + * @param bool $exit Whether to exit the script afterwards. |
|
513 | + */ |
|
514 | 514 | public static function sendJSON($data, bool $exit=true) |
515 | 515 | { |
516 | 516 | $payload = $data; |
@@ -530,12 +530,12 @@ discard block |
||
530 | 530 | } |
531 | 531 | } |
532 | 532 | |
533 | - /** |
|
534 | - * Sends HTML to the browser with the correct headers. |
|
535 | - * |
|
536 | - * @param string $html |
|
537 | - * @param bool $exit Whether to exit the script afterwards. |
|
538 | - */ |
|
533 | + /** |
|
534 | + * Sends HTML to the browser with the correct headers. |
|
535 | + * |
|
536 | + * @param string $html |
|
537 | + * @param bool $exit Whether to exit the script afterwards. |
|
538 | + */ |
|
539 | 539 | public static function sendHTML(string $html, bool $exit=true) |
540 | 540 | { |
541 | 541 | header('Cache-Control: no-cache, must-revalidate'); |
@@ -550,16 +550,16 @@ discard block |
||
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
553 | - /** |
|
554 | - * Creates a new instance of the URL comparer, which can check |
|
555 | - * whether the specified URLs match, regardless of the order in |
|
556 | - * which the query parameters are, if any. |
|
557 | - * |
|
558 | - * @param string $sourceURL |
|
559 | - * @param string $targetURL |
|
560 | - * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
561 | - * @return Request_URLComparer |
|
562 | - */ |
|
553 | + /** |
|
554 | + * Creates a new instance of the URL comparer, which can check |
|
555 | + * whether the specified URLs match, regardless of the order in |
|
556 | + * which the query parameters are, if any. |
|
557 | + * |
|
558 | + * @param string $sourceURL |
|
559 | + * @param string $targetURL |
|
560 | + * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
561 | + * @return Request_URLComparer |
|
562 | + */ |
|
563 | 563 | public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
564 | 564 | { |
565 | 565 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | return $comparer; |
569 | 569 | } |
570 | 570 | |
571 | - /** |
|
572 | - * Retrieves the full URL that was used to access the current page. |
|
573 | - * @return string |
|
574 | - */ |
|
571 | + /** |
|
572 | + * Retrieves the full URL that was used to access the current page. |
|
573 | + * @return string |
|
574 | + */ |
|
575 | 575 | public function getCurrentURL() : string |
576 | 576 | { |
577 | 577 | return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
@@ -19,9 +19,9 @@ |
||
19 | 19 | */ |
20 | 20 | class Request_RefreshParams_Exclude_Name extends Request_RefreshParams_Exclude |
21 | 21 | { |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | private $name; |
26 | 26 | |
27 | 27 | public function __construct(string $paramName) |
@@ -22,9 +22,9 @@ |
||
22 | 22 | { |
23 | 23 | const ERROR_INVALID_CALLBACK = 62101; |
24 | 24 | |
25 | - /** |
|
26 | - * @var callable |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var callable |
|
27 | + */ |
|
28 | 28 | private $callback; |
29 | 29 | |
30 | 30 | public function __construct($callback) |
@@ -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 $overrides = array(); |
30 | 30 | |
31 | - /** |
|
32 | - * @var Request_RefreshParams_Exclude[] |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var Request_RefreshParams_Exclude[] |
|
33 | + */ |
|
34 | 34 | private $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); |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | return $this; |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Exclude a request using a callback function. |
|
83 | - * |
|
84 | - * The function gets two parameters: |
|
85 | - * |
|
86 | - * - The name of the request parameter |
|
87 | - * - The value of the request parameter |
|
88 | - * |
|
89 | - * If the callback returns a boolean true, the |
|
90 | - * parameter will be excluded. |
|
91 | - * |
|
92 | - * @param callable $callback |
|
93 | - * @return Request_RefreshParams |
|
94 | - */ |
|
81 | + /** |
|
82 | + * Exclude a request using a callback function. |
|
83 | + * |
|
84 | + * The function gets two parameters: |
|
85 | + * |
|
86 | + * - The name of the request parameter |
|
87 | + * - The value of the request parameter |
|
88 | + * |
|
89 | + * If the callback returns a boolean true, the |
|
90 | + * parameter will be excluded. |
|
91 | + * |
|
92 | + * @param callable $callback |
|
93 | + * @return Request_RefreshParams |
|
94 | + */ |
|
95 | 95 | public function excludeParamByCallback($callback) : Request_RefreshParams |
96 | 96 | { |
97 | 97 | $this->excludes[] = new Request_RefreshParams_Exclude_Callback($callback); |
@@ -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 $paramNames |
|
106 | - * @return Request_RefreshParams |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Excludes a request parameter by name. |
|
104 | + * |
|
105 | + * @param array $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 $params |
|
138 | - * @return Request_RefreshParams |
|
139 | - */ |
|
134 | + /** |
|
135 | + * Overrides an array of parameters. |
|
136 | + * |
|
137 | + * @param array $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(); |
@@ -19,51 +19,51 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class RequestHelper_Response |
21 | 21 | { |
22 | - /** |
|
23 | - * @var RequestHelper |
|
24 | - */ |
|
22 | + /** |
|
23 | + * @var RequestHelper |
|
24 | + */ |
|
25 | 25 | protected $request; |
26 | 26 | |
27 | - /** |
|
28 | - * @var string |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var string |
|
29 | + */ |
|
30 | 30 | protected $body = ''; |
31 | 31 | |
32 | - /** |
|
33 | - * @var array |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var array |
|
34 | + */ |
|
35 | 35 | protected $info; |
36 | 36 | |
37 | - /** |
|
38 | - * @var bool |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var bool |
|
39 | + */ |
|
40 | 40 | protected $isError = false; |
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $errorMessage = ''; |
46 | 46 | |
47 | - /** |
|
48 | - * @var integer |
|
49 | - */ |
|
47 | + /** |
|
48 | + * @var integer |
|
49 | + */ |
|
50 | 50 | protected $errorCode = 0; |
51 | 51 | |
52 | - /** |
|
53 | - * @param RequestHelper $helper |
|
54 | - * @param array $info The CURL info array from curl_getinfo(). |
|
55 | - */ |
|
52 | + /** |
|
53 | + * @param RequestHelper $helper |
|
54 | + * @param array $info The CURL info array from curl_getinfo(). |
|
55 | + */ |
|
56 | 56 | public function __construct(RequestHelper $helper, array $info) |
57 | 57 | { |
58 | 58 | $this->request = $helper; |
59 | 59 | $this->info = $info; |
60 | 60 | } |
61 | 61 | |
62 | - /** |
|
63 | - * Retrieves the request instance that initiated the request. |
|
64 | - * |
|
65 | - * @return RequestHelper |
|
66 | - */ |
|
62 | + /** |
|
63 | + * Retrieves the request instance that initiated the request. |
|
64 | + * |
|
65 | + * @return RequestHelper |
|
66 | + */ |
|
67 | 67 | public function getRequest() : RequestHelper |
68 | 68 | { |
69 | 69 | return $this->request; |
@@ -84,79 +84,79 @@ discard block |
||
84 | 84 | return $this; |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * Whether an error occurred in the request. |
|
89 | - * @return bool |
|
90 | - */ |
|
87 | + /** |
|
88 | + * Whether an error occurred in the request. |
|
89 | + * @return bool |
|
90 | + */ |
|
91 | 91 | public function isError() : bool |
92 | 92 | { |
93 | 93 | return $this->isError; |
94 | 94 | } |
95 | 95 | |
96 | - /** |
|
97 | - * Whether the request timed out. |
|
98 | - * @return bool |
|
99 | - */ |
|
96 | + /** |
|
97 | + * Whether the request timed out. |
|
98 | + * @return bool |
|
99 | + */ |
|
100 | 100 | public function isTimeout() : bool |
101 | 101 | { |
102 | 102 | return $this->errorCode === RequestHelper_CURL::OPERATION_TIMEDOUT; |
103 | 103 | } |
104 | 104 | |
105 | - /** |
|
106 | - * Retrieves the native error message, if an error occurred. |
|
107 | - * @return string |
|
108 | - */ |
|
105 | + /** |
|
106 | + * Retrieves the native error message, if an error occurred. |
|
107 | + * @return string |
|
108 | + */ |
|
109 | 109 | public function getErrorMessage() : string |
110 | 110 | { |
111 | 111 | return $this->errorMessage; |
112 | 112 | } |
113 | 113 | |
114 | - /** |
|
115 | - * Retrieves the native CURL error code, if an error occurred. |
|
116 | - * @return int |
|
117 | - * @see RequestHelper_CURL For a list of error codes. |
|
118 | - */ |
|
114 | + /** |
|
115 | + * Retrieves the native CURL error code, if an error occurred. |
|
116 | + * @return int |
|
117 | + * @see RequestHelper_CURL For a list of error codes. |
|
118 | + */ |
|
119 | 119 | public function getErrorCode() : int |
120 | 120 | { |
121 | 121 | return $this->errorCode; |
122 | 122 | } |
123 | 123 | |
124 | - /** |
|
125 | - * Retrieves the full body of the request. |
|
126 | - * |
|
127 | - * @return string |
|
128 | - */ |
|
124 | + /** |
|
125 | + * Retrieves the full body of the request. |
|
126 | + * |
|
127 | + * @return string |
|
128 | + */ |
|
129 | 129 | public function getRequestBody() : string |
130 | 130 | { |
131 | 131 | return $this->request->getBody(); |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Retrieves the body of the response, if any. |
|
136 | - * |
|
137 | - * @return string |
|
138 | - */ |
|
134 | + /** |
|
135 | + * Retrieves the body of the response, if any. |
|
136 | + * |
|
137 | + * @return string |
|
138 | + */ |
|
139 | 139 | public function getResponseBody() : string |
140 | 140 | { |
141 | 141 | return $this->body; |
142 | 142 | } |
143 | 143 | |
144 | - /** |
|
145 | - * The response HTTP code. |
|
146 | - * |
|
147 | - * @return int The code, or 0 if none was sent (on error). |
|
148 | - */ |
|
144 | + /** |
|
145 | + * The response HTTP code. |
|
146 | + * |
|
147 | + * @return int The code, or 0 if none was sent (on error). |
|
148 | + */ |
|
149 | 149 | public function getCode() : int |
150 | 150 | { |
151 | 151 | return intval($this->getInfoKey('http_code')); |
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * Retrieves the actual headers that were sent in the request: |
|
156 | - * one header by entry in the indexed array. |
|
157 | - * |
|
158 | - * @return array |
|
159 | - */ |
|
154 | + /** |
|
155 | + * Retrieves the actual headers that were sent in the request: |
|
156 | + * one header by entry in the indexed array. |
|
157 | + * |
|
158 | + * @return array |
|
159 | + */ |
|
160 | 160 | public function getHeaders() : array |
161 | 161 | { |
162 | 162 | return ConvertHelper::explodeTrim("\n", $this->getInfoKey('request_header')); |
@@ -32,62 +32,62 @@ discard block |
||
32 | 32 | const ERROR_CURL_INIT_FAILED = 17903; |
33 | 33 | const ERROR_CANNOT_OPEN_LOGFILE = 17904; |
34 | 34 | |
35 | - /** |
|
36 | - * @var string |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var string |
|
37 | + */ |
|
38 | 38 | protected $eol = "\r\n"; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $mimeBoundary; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + */ |
|
48 | 48 | protected $destination; |
49 | 49 | |
50 | - /** |
|
51 | - * @var array<string,string> |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var array<string,string> |
|
52 | + */ |
|
53 | 53 | protected $headers = array(); |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to verify SSL certificates. |
|
57 | - * @var bool |
|
58 | - */ |
|
55 | + /** |
|
56 | + * Whether to verify SSL certificates. |
|
57 | + * @var bool |
|
58 | + */ |
|
59 | 59 | protected $verifySSL = true; |
60 | 60 | |
61 | - /** |
|
62 | - * @var RequestHelper_Boundaries |
|
63 | - */ |
|
61 | + /** |
|
62 | + * @var RequestHelper_Boundaries |
|
63 | + */ |
|
64 | 64 | protected $boundaries; |
65 | 65 | |
66 | - /** |
|
67 | - * @var RequestHelper_Response|NULL |
|
68 | - */ |
|
66 | + /** |
|
67 | + * @var RequestHelper_Response|NULL |
|
68 | + */ |
|
69 | 69 | protected $response; |
70 | 70 | |
71 | - /** |
|
72 | - * Timeout duration, in seconds. |
|
73 | - * @var integer |
|
74 | - */ |
|
71 | + /** |
|
72 | + * Timeout duration, in seconds. |
|
73 | + * @var integer |
|
74 | + */ |
|
75 | 75 | protected $timeout = 30; |
76 | 76 | |
77 | - /** |
|
78 | - * @var string |
|
79 | - */ |
|
77 | + /** |
|
78 | + * @var string |
|
79 | + */ |
|
80 | 80 | protected $logfile = ''; |
81 | 81 | |
82 | - /** |
|
83 | - * @var resource|NULL |
|
84 | - */ |
|
82 | + /** |
|
83 | + * @var resource|NULL |
|
84 | + */ |
|
85 | 85 | protected $logfilePointer = null; |
86 | 86 | |
87 | - /** |
|
88 | - * Creates a new request helper to send POST data to the specified destination URL. |
|
89 | - * @param string $destinationURL |
|
90 | - */ |
|
87 | + /** |
|
88 | + * Creates a new request helper to send POST data to the specified destination URL. |
|
89 | + * @param string $destinationURL |
|
90 | + */ |
|
91 | 91 | public function __construct(string $destinationURL) |
92 | 92 | { |
93 | 93 | $this->destination = $destinationURL; |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | return $this->eol; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Sets the timeout for the request, in seconds. If the request |
|
117 | - * takes longer, it will be cancelled and an exception triggered. |
|
118 | - * |
|
119 | - * @param int $seconds |
|
120 | - * @return RequestHelper |
|
121 | - */ |
|
115 | + /** |
|
116 | + * Sets the timeout for the request, in seconds. If the request |
|
117 | + * takes longer, it will be cancelled and an exception triggered. |
|
118 | + * |
|
119 | + * @param int $seconds |
|
120 | + * @return RequestHelper |
|
121 | + */ |
|
122 | 122 | public function setTimeout(int $seconds) : RequestHelper |
123 | 123 | { |
124 | 124 | $this->timeout = $seconds; |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | return $this->timeout; |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Enables verbose logging of the CURL request, which |
|
136 | - * is then redirected to the target file. |
|
137 | - * |
|
138 | - * @param string $targetFile |
|
139 | - * @return RequestHelper |
|
140 | - */ |
|
134 | + /** |
|
135 | + * Enables verbose logging of the CURL request, which |
|
136 | + * is then redirected to the target file. |
|
137 | + * |
|
138 | + * @param string $targetFile |
|
139 | + * @return RequestHelper |
|
140 | + */ |
|
141 | 141 | public function enableLogging(string $targetFile) : RequestHelper |
142 | 142 | { |
143 | 143 | $this->logfile = $targetFile; |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | return $this; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * Adds a file to be sent with the request. |
|
150 | - * |
|
151 | - * @param string $varName The variable name to send the file in |
|
152 | - * @param string $fileName The name of the file as it should be received at the destination |
|
153 | - * @param string $content The raw content of the file |
|
154 | - * @param string $contentType The content type, use the constants to specify this |
|
155 | - * @param string $encoding The encoding of the file, use the constants to specify this |
|
156 | - */ |
|
148 | + /** |
|
149 | + * Adds a file to be sent with the request. |
|
150 | + * |
|
151 | + * @param string $varName The variable name to send the file in |
|
152 | + * @param string $fileName The name of the file as it should be received at the destination |
|
153 | + * @param string $content The raw content of the file |
|
154 | + * @param string $contentType The content type, use the constants to specify this |
|
155 | + * @param string $encoding The encoding of the file, use the constants to specify this |
|
156 | + */ |
|
157 | 157 | public function addFile(string $varName, string $fileName, string $content, string $contentType = '', string $encoding = '') : RequestHelper |
158 | 158 | { |
159 | 159 | $this->boundaries->addFile($varName, $fileName, $content, $contentType, $encoding); |
@@ -161,13 +161,13 @@ discard block |
||
161 | 161 | return $this; |
162 | 162 | } |
163 | 163 | |
164 | - /** |
|
165 | - * Adds arbitrary content. |
|
166 | - * |
|
167 | - * @param string $varName The variable name to send the content in. |
|
168 | - * @param string $content |
|
169 | - * @param string $contentType |
|
170 | - */ |
|
164 | + /** |
|
165 | + * Adds arbitrary content. |
|
166 | + * |
|
167 | + * @param string $varName The variable name to send the content in. |
|
168 | + * @param string $content |
|
169 | + * @param string $contentType |
|
170 | + */ |
|
171 | 171 | public function addContent(string $varName, string $content, string $contentType) : RequestHelper |
172 | 172 | { |
173 | 173 | $this->boundaries->addContent($varName, $content, $contentType); |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | return $this; |
176 | 176 | } |
177 | 177 | |
178 | - /** |
|
179 | - * Adds a variable to be sent with the request. If it |
|
180 | - * already exists, its value is overwritten. |
|
181 | - * |
|
182 | - * @param string $name |
|
183 | - * @param string $value |
|
184 | - */ |
|
178 | + /** |
|
179 | + * Adds a variable to be sent with the request. If it |
|
180 | + * already exists, its value is overwritten. |
|
181 | + * |
|
182 | + * @param string $name |
|
183 | + * @param string $value |
|
184 | + */ |
|
185 | 185 | public function addVariable(string $name, string $value) : RequestHelper |
186 | 186 | { |
187 | 187 | $this->boundaries->addVariable($name, $value); |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | return $this; |
190 | 190 | } |
191 | 191 | |
192 | - /** |
|
193 | - * Sets an HTTP header to include in the request. |
|
194 | - * |
|
195 | - * @param string $name |
|
196 | - * @param string $value |
|
197 | - * @return RequestHelper |
|
198 | - */ |
|
192 | + /** |
|
193 | + * Sets an HTTP header to include in the request. |
|
194 | + * |
|
195 | + * @param string $name |
|
196 | + * @param string $value |
|
197 | + * @return RequestHelper |
|
198 | + */ |
|
199 | 199 | public function setHeader(string $name, string $value) : RequestHelper |
200 | 200 | { |
201 | 201 | $this->headers[$name] = $value; |
@@ -203,36 +203,36 @@ discard block |
||
203 | 203 | return $this; |
204 | 204 | } |
205 | 205 | |
206 | - /** |
|
207 | - * Disables SSL certificate checking. |
|
208 | - * |
|
209 | - * @return RequestHelper |
|
210 | - */ |
|
206 | + /** |
|
207 | + * Disables SSL certificate checking. |
|
208 | + * |
|
209 | + * @return RequestHelper |
|
210 | + */ |
|
211 | 211 | public function disableSSLChecks() : RequestHelper |
212 | 212 | { |
213 | 213 | $this->verifySSL = false; |
214 | 214 | return $this; |
215 | 215 | } |
216 | 216 | |
217 | - /** |
|
218 | - * @var integer |
|
219 | - */ |
|
217 | + /** |
|
218 | + * @var integer |
|
219 | + */ |
|
220 | 220 | protected $contentLength = 0; |
221 | 221 | |
222 | - /** |
|
223 | - * Sends the POST request to the destination, and returns |
|
224 | - * the response text. |
|
225 | - * |
|
226 | - * The response object is stored internally, so after calling |
|
227 | - * this method it may be retrieved at any moment using the |
|
228 | - * {@link getResponse()} method. |
|
229 | - * |
|
230 | - * @return string |
|
231 | - * @see RequestHelper::getResponse() |
|
232 | - * @throws RequestHelper_Exception |
|
233 | - * |
|
234 | - * @see RequestHelper::ERROR_REQUEST_FAILED |
|
235 | - */ |
|
222 | + /** |
|
223 | + * Sends the POST request to the destination, and returns |
|
224 | + * the response text. |
|
225 | + * |
|
226 | + * The response object is stored internally, so after calling |
|
227 | + * this method it may be retrieved at any moment using the |
|
228 | + * {@link getResponse()} method. |
|
229 | + * |
|
230 | + * @return string |
|
231 | + * @see RequestHelper::getResponse() |
|
232 | + * @throws RequestHelper_Exception |
|
233 | + * |
|
234 | + * @see RequestHelper::ERROR_REQUEST_FAILED |
|
235 | + */ |
|
236 | 236 | public function send() : string |
237 | 237 | { |
238 | 238 | $info = parseURL($this->destination); |
@@ -272,26 +272,26 @@ discard block |
||
272 | 272 | return $this->response->getResponseBody(); |
273 | 273 | } |
274 | 274 | |
275 | - /** |
|
276 | - * Retrieves the request's body content. This is an alias |
|
277 | - * for {@see RequestHelper::getMimeBody()}. |
|
278 | - * |
|
279 | - * @return string |
|
280 | - * @see RequestHelper::getMimeBody() |
|
281 | - */ |
|
275 | + /** |
|
276 | + * Retrieves the request's body content. This is an alias |
|
277 | + * for {@see RequestHelper::getMimeBody()}. |
|
278 | + * |
|
279 | + * @return string |
|
280 | + * @see RequestHelper::getMimeBody() |
|
281 | + */ |
|
282 | 282 | public function getBody() : string |
283 | 283 | { |
284 | 284 | return $this->getMimeBody(); |
285 | 285 | } |
286 | 286 | |
287 | - /** |
|
288 | - * Creates a new CURL resource configured according to the |
|
289 | - * request's settings. |
|
290 | - * |
|
291 | - * @param URLInfo $url |
|
292 | - * @throws RequestHelper_Exception |
|
293 | - * @return resource |
|
294 | - */ |
|
287 | + /** |
|
288 | + * Creates a new CURL resource configured according to the |
|
289 | + * request's settings. |
|
290 | + * |
|
291 | + * @param URLInfo $url |
|
292 | + * @throws RequestHelper_Exception |
|
293 | + * @return resource |
|
294 | + */ |
|
295 | 295 | protected function createCURL(URLInfo $url) |
296 | 296 | { |
297 | 297 | $ch = curl_init(); |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | return $ch; |
340 | 340 | } |
341 | 341 | |
342 | - /** |
|
343 | - * @param resource $ch |
|
344 | - * @return bool Whether logging is enabled. |
|
345 | - */ |
|
342 | + /** |
|
343 | + * @param resource $ch |
|
344 | + * @return bool Whether logging is enabled. |
|
345 | + */ |
|
346 | 346 | protected function configureLogging($ch) : bool |
347 | 347 | { |
348 | 348 | if(empty($this->logfile)) |
@@ -369,13 +369,13 @@ discard block |
||
369 | 369 | return true; |
370 | 370 | } |
371 | 371 | |
372 | - /** |
|
373 | - * Compiles the associative headers array into |
|
374 | - * the format understood by CURL, namely an indexed |
|
375 | - * array with one header string per entry. |
|
376 | - * |
|
377 | - * @return array |
|
378 | - */ |
|
372 | + /** |
|
373 | + * Compiles the associative headers array into |
|
374 | + * the format understood by CURL, namely an indexed |
|
375 | + * array with one header string per entry. |
|
376 | + * |
|
377 | + * @return array |
|
378 | + */ |
|
379 | 379 | protected function renderHeaders() : array |
380 | 380 | { |
381 | 381 | $result = array(); |
@@ -389,12 +389,12 @@ discard block |
||
389 | 389 | return $result; |
390 | 390 | } |
391 | 391 | |
392 | - /** |
|
393 | - * Retrieves the raw response header, in the form of an indexed |
|
394 | - * array containing all response header lines. |
|
395 | - * |
|
396 | - * @return array |
|
397 | - */ |
|
392 | + /** |
|
393 | + * Retrieves the raw response header, in the form of an indexed |
|
394 | + * array containing all response header lines. |
|
395 | + * |
|
396 | + * @return array |
|
397 | + */ |
|
398 | 398 | public function getResponseHeader() : array |
399 | 399 | { |
400 | 400 | $response = $this->getResponse(); |
@@ -406,33 +406,33 @@ discard block |
||
406 | 406 | return array(); |
407 | 407 | } |
408 | 408 | |
409 | - /** |
|
410 | - * After calling the {@link send()} method, this may be used to |
|
411 | - * retrieve the response text from the POST request. |
|
412 | - * |
|
413 | - * @return RequestHelper_Response|NULL |
|
414 | - */ |
|
409 | + /** |
|
410 | + * After calling the {@link send()} method, this may be used to |
|
411 | + * retrieve the response text from the POST request. |
|
412 | + * |
|
413 | + * @return RequestHelper_Response|NULL |
|
414 | + */ |
|
415 | 415 | public function getResponse() : ?RequestHelper_Response |
416 | 416 | { |
417 | 417 | return $this->response; |
418 | 418 | } |
419 | 419 | |
420 | - /** |
|
421 | - * Retrieves all headers set until now. |
|
422 | - * |
|
423 | - * @return array<string,string> |
|
424 | - */ |
|
420 | + /** |
|
421 | + * Retrieves all headers set until now. |
|
422 | + * |
|
423 | + * @return array<string,string> |
|
424 | + */ |
|
425 | 425 | public function getHeaders() : array |
426 | 426 | { |
427 | 427 | return $this->headers; |
428 | 428 | } |
429 | 429 | |
430 | - /** |
|
431 | - * Retrieves the value of a header by its name. |
|
432 | - * |
|
433 | - * @param string $name |
|
434 | - * @return string The header value, or an empty string if not set. |
|
435 | - */ |
|
430 | + /** |
|
431 | + * Retrieves the value of a header by its name. |
|
432 | + * |
|
433 | + * @param string $name |
|
434 | + * @return string The header value, or an empty string if not set. |
|
435 | + */ |
|
436 | 436 | public function getHeader(string $name) : string |
437 | 437 | { |
438 | 438 | if(isset($this->headers[$name])) |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | { |
29 | 29 | const ERROR_CANNOT_APPEND_FRAGMENT = 491001; |
30 | 30 | |
31 | - /** |
|
32 | - * @var boolean |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var boolean |
|
33 | + */ |
|
34 | 34 | private static $simulation = false; |
35 | 35 | |
36 | 36 | /** |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | */ |
39 | 39 | private $dom; |
40 | 40 | |
41 | - /** |
|
42 | - * Creates a new XMLHelper instance. |
|
43 | - * |
|
44 | - * @return XMLHelper |
|
45 | - */ |
|
41 | + /** |
|
42 | + * Creates a new XMLHelper instance. |
|
43 | + * |
|
44 | + * @return XMLHelper |
|
45 | + */ |
|
46 | 46 | public static function create() : XMLHelper |
47 | 47 | { |
48 | 48 | $dom = new DOMDocument('1.0', 'UTF-8'); |
@@ -51,72 +51,72 @@ discard block |
||
51 | 51 | return new XMLHelper($dom); |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * Creates a converter instance from an XML file. |
|
56 | - * @param string $xmlFile |
|
57 | - * @return XMLHelper_Converter |
|
58 | - */ |
|
54 | + /** |
|
55 | + * Creates a converter instance from an XML file. |
|
56 | + * @param string $xmlFile |
|
57 | + * @return XMLHelper_Converter |
|
58 | + */ |
|
59 | 59 | public static function convertFile(string $xmlFile) : XMLHelper_Converter |
60 | 60 | { |
61 | 61 | return XMLHelper_Converter::fromFile($xmlFile); |
62 | 62 | } |
63 | 63 | |
64 | - /** |
|
65 | - * Creates a converter from an XML string. |
|
66 | - * @param string $xmlString |
|
67 | - * @return XMLHelper_Converter |
|
68 | - */ |
|
64 | + /** |
|
65 | + * Creates a converter from an XML string. |
|
66 | + * @param string $xmlString |
|
67 | + * @return XMLHelper_Converter |
|
68 | + */ |
|
69 | 69 | public static function convertString(string $xmlString) : XMLHelper_Converter |
70 | 70 | { |
71 | 71 | return XMLHelper_Converter::fromString($xmlString); |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Creates a converter from a SimpleXMLElement instance. |
|
76 | - * @param SimpleXMLElement $element |
|
77 | - * @return XMLHelper_Converter |
|
78 | - */ |
|
74 | + /** |
|
75 | + * Creates a converter from a SimpleXMLElement instance. |
|
76 | + * @param SimpleXMLElement $element |
|
77 | + * @return XMLHelper_Converter |
|
78 | + */ |
|
79 | 79 | public static function convertElement(SimpleXMLElement $element) : XMLHelper_Converter |
80 | 80 | { |
81 | 81 | return XMLHelper_Converter::fromElement($element); |
82 | 82 | } |
83 | 83 | |
84 | - /** |
|
85 | - * Creates a converter from a DOMElement instance. |
|
86 | - * @param DOMElement $element |
|
87 | - * @return XMLHelper_Converter |
|
88 | - */ |
|
84 | + /** |
|
85 | + * Creates a converter from a DOMElement instance. |
|
86 | + * @param DOMElement $element |
|
87 | + * @return XMLHelper_Converter |
|
88 | + */ |
|
89 | 89 | public static function convertDOMElement(DOMElement $element) : XMLHelper_Converter |
90 | 90 | { |
91 | 91 | return XMLHelper_Converter::fromDOMElement($element); |
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * Creates a new helper using an existing DOMDocument object. |
|
96 | - * @param DOMDocument $dom |
|
97 | - */ |
|
94 | + /** |
|
95 | + * Creates a new helper using an existing DOMDocument object. |
|
96 | + * @param DOMDocument $dom |
|
97 | + */ |
|
98 | 98 | public function __construct(DOMDocument $dom) |
99 | 99 | { |
100 | 100 | $this->dom = $dom; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * @return DOMDocument |
|
105 | - */ |
|
103 | + /** |
|
104 | + * @return DOMDocument |
|
105 | + */ |
|
106 | 106 | public function getDOM() : DOMDocument |
107 | 107 | { |
108 | 108 | return $this->dom; |
109 | 109 | } |
110 | 110 | |
111 | - /** |
|
112 | - * Adds an attribute to an existing tag with |
|
113 | - * the specified value. |
|
114 | - * |
|
115 | - * @param DOMNode $parent |
|
116 | - * @param string $name |
|
117 | - * @param mixed $value |
|
118 | - * @return DOMNode |
|
119 | - */ |
|
111 | + /** |
|
112 | + * Adds an attribute to an existing tag with |
|
113 | + * the specified value. |
|
114 | + * |
|
115 | + * @param DOMNode $parent |
|
116 | + * @param string $name |
|
117 | + * @param mixed $value |
|
118 | + * @return DOMNode |
|
119 | + */ |
|
120 | 120 | public function addAttribute(DOMNode $parent, string $name, $value) |
121 | 121 | { |
122 | 122 | $node = $this->dom->createAttribute($name); |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | return $parent->appendChild($node); |
127 | 127 | } |
128 | 128 | |
129 | - /** |
|
130 | - * Adds several attributes to the target node. |
|
131 | - * |
|
132 | - * @param DOMNode $parent |
|
133 | - * @param array<string,mixed> $attributes |
|
134 | - */ |
|
129 | + /** |
|
130 | + * Adds several attributes to the target node. |
|
131 | + * |
|
132 | + * @param DOMNode $parent |
|
133 | + * @param array<string,mixed> $attributes |
|
134 | + */ |
|
135 | 135 | public function addAttributes(DOMNode $parent, array $attributes) : void |
136 | 136 | { |
137 | 137 | foreach ($attributes as $name => $value) { |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | - /** |
|
143 | - * Adds a tag without content. |
|
144 | - * |
|
145 | - * @param DOMNode $parent |
|
146 | - * @param string $name |
|
147 | - * @param integer $indent |
|
148 | - * @return DOMNode |
|
149 | - */ |
|
142 | + /** |
|
143 | + * Adds a tag without content. |
|
144 | + * |
|
145 | + * @param DOMNode $parent |
|
146 | + * @param string $name |
|
147 | + * @param integer $indent |
|
148 | + * @return DOMNode |
|
149 | + */ |
|
150 | 150 | public function addTag(DOMNode $parent, string $name, int $indent = 0) : DOMNode |
151 | 151 | { |
152 | 152 | if ($indent > 0) { |
@@ -168,17 +168,17 @@ discard block |
||
168 | 168 | $parent->appendChild($this->dom->createTextNode(str_repeat("\t", $amount))); |
169 | 169 | } |
170 | 170 | |
171 | - /** |
|
172 | - * Adds a tag with textual content, like: |
|
173 | - * |
|
174 | - * <tagname>text</tagname> |
|
175 | - * |
|
176 | - * @param DOMNode $parent |
|
177 | - * @param string $name |
|
178 | - * @param string $text |
|
179 | - * @param integer $indent |
|
180 | - * @return DOMNode |
|
181 | - */ |
|
171 | + /** |
|
172 | + * Adds a tag with textual content, like: |
|
173 | + * |
|
174 | + * <tagname>text</tagname> |
|
175 | + * |
|
176 | + * @param DOMNode $parent |
|
177 | + * @param string $name |
|
178 | + * @param string $text |
|
179 | + * @param integer $indent |
|
180 | + * @return DOMNode |
|
181 | + */ |
|
182 | 182 | public function addTextTag(DOMNode $parent, string $name, string $text, int $indent = 0) : DOMNode |
183 | 183 | { |
184 | 184 | if ($indent > 0) { |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | return $parent->appendChild($tag); |
193 | 193 | } |
194 | 194 | |
195 | - /** |
|
196 | - * Adds a tag with textual content, like: |
|
197 | - * |
|
198 | - * <tagname>text</tagname> |
|
199 | - * |
|
200 | - * and removes <p> tags |
|
201 | - * |
|
202 | - * @param DOMNode $parent |
|
203 | - * @param string $name |
|
204 | - * @param string $text |
|
205 | - * @param integer $indent |
|
206 | - * @return DOMNode |
|
207 | - */ |
|
195 | + /** |
|
196 | + * Adds a tag with textual content, like: |
|
197 | + * |
|
198 | + * <tagname>text</tagname> |
|
199 | + * |
|
200 | + * and removes <p> tags |
|
201 | + * |
|
202 | + * @param DOMNode $parent |
|
203 | + * @param string $name |
|
204 | + * @param string $text |
|
205 | + * @param integer $indent |
|
206 | + * @return DOMNode |
|
207 | + */ |
|
208 | 208 | public function addEscapedTag(DOMNode $parent, string $name, string $text, int $indent = 0) |
209 | 209 | { |
210 | 210 | if ($indent > 0) { |
@@ -220,19 +220,19 @@ discard block |
||
220 | 220 | return $parent->appendChild($tag); |
221 | 221 | } |
222 | 222 | |
223 | - /** |
|
224 | - * Adds a tag with HTML content, like: |
|
225 | - * |
|
226 | - * <tagname><i>text</i></tagname> |
|
227 | - * |
|
228 | - * Tags will not be escaped. |
|
229 | - * |
|
230 | - * @param DOMNode $parent |
|
231 | - * @param string $name |
|
232 | - * @param string $text |
|
233 | - * @param integer $indent |
|
234 | - * @return DOMNode |
|
235 | - */ |
|
223 | + /** |
|
224 | + * Adds a tag with HTML content, like: |
|
225 | + * |
|
226 | + * <tagname><i>text</i></tagname> |
|
227 | + * |
|
228 | + * Tags will not be escaped. |
|
229 | + * |
|
230 | + * @param DOMNode $parent |
|
231 | + * @param string $name |
|
232 | + * @param string $text |
|
233 | + * @param integer $indent |
|
234 | + * @return DOMNode |
|
235 | + */ |
|
236 | 236 | public function addFragmentTag(DOMNode $parent, string $name, string $text, int $indent = 0) |
237 | 237 | { |
238 | 238 | if ($indent > 0) { |
@@ -260,16 +260,16 @@ discard block |
||
260 | 260 | return $parent->appendChild($tag); |
261 | 261 | } |
262 | 262 | |
263 | - /** |
|
264 | - * Adds a tag with CDATA content, like: |
|
265 | - * |
|
266 | - * <tagname><![CDATA[value]]></tagname> |
|
267 | - * |
|
268 | - * @param DOMNode $parent |
|
269 | - * @param string $name |
|
270 | - * @param string $content |
|
271 | - * @return DOMNode |
|
272 | - */ |
|
263 | + /** |
|
264 | + * Adds a tag with CDATA content, like: |
|
265 | + * |
|
266 | + * <tagname><![CDATA[value]]></tagname> |
|
267 | + * |
|
268 | + * @param DOMNode $parent |
|
269 | + * @param string $name |
|
270 | + * @param string $content |
|
271 | + * @return DOMNode |
|
272 | + */ |
|
273 | 273 | public function addCDATATag(DOMNode $parent, string $name, string $content) : DOMNode |
274 | 274 | { |
275 | 275 | $tag = $this->dom->createElement($name); |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | return $parent->appendChild($tag); |
280 | 280 | } |
281 | 281 | |
282 | - /** |
|
283 | - * Creates the root element of the document. |
|
284 | - * @param string $name |
|
285 | - * @param array<string,mixed> $attributes |
|
286 | - * @return DOMNode |
|
287 | - */ |
|
282 | + /** |
|
283 | + * Creates the root element of the document. |
|
284 | + * @param string $name |
|
285 | + * @param array<string,mixed> $attributes |
|
286 | + * @return DOMNode |
|
287 | + */ |
|
288 | 288 | public function createRoot(string $name, array $attributes=array()) |
289 | 289 | { |
290 | 290 | $root = $this->dom->appendChild($this->dom->createElement($name)); |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | return $root; |
293 | 293 | } |
294 | 294 | |
295 | - /** |
|
296 | - * Escaped the string for use in XML. |
|
297 | - * |
|
298 | - * @param string $string |
|
299 | - * @return string |
|
300 | - */ |
|
295 | + /** |
|
296 | + * Escaped the string for use in XML. |
|
297 | + * |
|
298 | + * @param string $string |
|
299 | + * @return string |
|
300 | + */ |
|
301 | 301 | public function escape(string $string) : string |
302 | 302 | { |
303 | 303 | $string = preg_replace('#<p>(.*)</p>#isUm', '$1', $string); |
@@ -317,18 +317,18 @@ discard block |
||
317 | 317 | return $string; |
318 | 318 | } |
319 | 319 | |
320 | - /** |
|
321 | - * Sends the specified XML string to the browser with |
|
322 | - * the correct headers to trigger a download of the XML |
|
323 | - * to a local file. |
|
324 | - * |
|
325 | - * NOTE: Ensure calling exit after this is done, and to |
|
326 | - * not send additional content, which would corrupt the |
|
327 | - * download. |
|
328 | - * |
|
329 | - * @param string $xml |
|
330 | - * @param string $filename |
|
331 | - */ |
|
320 | + /** |
|
321 | + * Sends the specified XML string to the browser with |
|
322 | + * the correct headers to trigger a download of the XML |
|
323 | + * to a local file. |
|
324 | + * |
|
325 | + * NOTE: Ensure calling exit after this is done, and to |
|
326 | + * not send additional content, which would corrupt the |
|
327 | + * download. |
|
328 | + * |
|
329 | + * @param string $xml |
|
330 | + * @param string $filename |
|
331 | + */ |
|
332 | 332 | public static function downloadXML(string $xml, string $filename = 'download.xml') : void |
333 | 333 | { |
334 | 334 | if(!headers_sent() && !self::$simulation) |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | echo $xml; |
340 | 340 | } |
341 | 341 | |
342 | - /** |
|
343 | - * Sends the specified XML string to the browser with |
|
344 | - * the correct headers and terminates the request. |
|
345 | - * |
|
346 | - * @param string $xml |
|
347 | - */ |
|
342 | + /** |
|
343 | + * Sends the specified XML string to the browser with |
|
344 | + * the correct headers and terminates the request. |
|
345 | + * |
|
346 | + * @param string $xml |
|
347 | + */ |
|
348 | 348 | public static function displayXML(string $xml) : void |
349 | 349 | { |
350 | 350 | if(!headers_sent() && !self::$simulation) |
@@ -411,23 +411,23 @@ discard block |
||
411 | 411 | return $xml->saveXML(); |
412 | 412 | } |
413 | 413 | |
414 | - /** |
|
415 | - * Creates XML markup to describe an application error |
|
416 | - * when using XML services. Creates XML with the |
|
417 | - * following structure: |
|
418 | - * |
|
419 | - * <error> |
|
420 | - * <id>99</id> |
|
421 | - * <message>Full error message text</message> |
|
422 | - * <title>Short error label</title> |
|
423 | - * </error> |
|
424 | - * |
|
425 | - * @param string|number $code |
|
426 | - * @param string $message |
|
427 | - * @param string $title |
|
428 | - * @param array<string,string> $customInfo |
|
429 | - * @return string |
|
430 | - */ |
|
414 | + /** |
|
415 | + * Creates XML markup to describe an application error |
|
416 | + * when using XML services. Creates XML with the |
|
417 | + * following structure: |
|
418 | + * |
|
419 | + * <error> |
|
420 | + * <id>99</id> |
|
421 | + * <message>Full error message text</message> |
|
422 | + * <title>Short error label</title> |
|
423 | + * </error> |
|
424 | + * |
|
425 | + * @param string|number $code |
|
426 | + * @param string $message |
|
427 | + * @param string $title |
|
428 | + * @param array<string,string> $customInfo |
|
429 | + * @return string |
|
430 | + */ |
|
431 | 431 | public static function buildErrorXML($code, string $message, string $title, array $customInfo=array()) |
432 | 432 | { |
433 | 433 | $xml = new DOMDocument('1.0', 'UTF-8'); |
@@ -460,31 +460,31 @@ discard block |
||
460 | 460 | return $this->dom->saveXML(); |
461 | 461 | } |
462 | 462 | |
463 | - /** |
|
464 | - * Creates a new SimpleXML helper instance: this |
|
465 | - * object is useful to work with loading XML strings |
|
466 | - * and files with easy access to any errors that |
|
467 | - * may occurr, since the simplexml functions can be |
|
468 | - * somewhat cryptic. |
|
469 | - * |
|
470 | - * @return XMLHelper_SimpleXML |
|
471 | - */ |
|
463 | + /** |
|
464 | + * Creates a new SimpleXML helper instance: this |
|
465 | + * object is useful to work with loading XML strings |
|
466 | + * and files with easy access to any errors that |
|
467 | + * may occurr, since the simplexml functions can be |
|
468 | + * somewhat cryptic. |
|
469 | + * |
|
470 | + * @return XMLHelper_SimpleXML |
|
471 | + */ |
|
472 | 472 | public static function createSimplexml() : XMLHelper_SimpleXML |
473 | 473 | { |
474 | 474 | return new XMLHelper_SimpleXML(); |
475 | 475 | } |
476 | 476 | |
477 | - /** |
|
478 | - * Converts a string to valid XML: can be a text only string |
|
479 | - * or an HTML string. Returns valid XML code. |
|
480 | - * |
|
481 | - * NOTE: The string may contain custom tags, which are |
|
482 | - * preserved. |
|
483 | - * |
|
484 | - * @param string $string |
|
485 | - * @throws XMLHelper_Exception |
|
486 | - * @return string |
|
487 | - */ |
|
477 | + /** |
|
478 | + * Converts a string to valid XML: can be a text only string |
|
479 | + * or an HTML string. Returns valid XML code. |
|
480 | + * |
|
481 | + * NOTE: The string may contain custom tags, which are |
|
482 | + * preserved. |
|
483 | + * |
|
484 | + * @param string $string |
|
485 | + * @throws XMLHelper_Exception |
|
486 | + * @return string |
|
487 | + */ |
|
488 | 488 | public static function string2xml(string $string) : string |
489 | 489 | { |
490 | 490 | return XMLHelper_HTMLLoader::loadFragment($string)->fragmentToXML(); |
@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class ConvertHelper_TimeConverter |
25 | 25 | { |
26 | - /** |
|
27 | - * @var float |
|
28 | - */ |
|
26 | + /** |
|
27 | + * @var float |
|
28 | + */ |
|
29 | 29 | private $seconds; |
30 | 30 | |
31 | - /** |
|
32 | - * @var array<int,array<string,string|int>> |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var array<int,array<string,string|int>> |
|
33 | + */ |
|
34 | 34 | private static $units; |
35 | 35 | |
36 | - /** |
|
37 | - * @param float $seconds |
|
38 | - */ |
|
36 | + /** |
|
37 | + * @param float $seconds |
|
38 | + */ |
|
39 | 39 | public function __construct($seconds) |
40 | 40 | { |
41 | 41 | $this->seconds = $seconds; |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | $this->initUnits(); |
44 | 44 | } |
45 | 45 | |
46 | - /** |
|
47 | - * Creates the list of units once per request as needed. |
|
48 | - */ |
|
46 | + /** |
|
47 | + * Creates the list of units once per request as needed. |
|
48 | + */ |
|
49 | 49 | private function initUnits() : void |
50 | 50 | { |
51 | 51 | if(isset(self::$units)) |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
113 | 113 | } |
114 | 114 | |
115 | - /** |
|
116 | - * Resolves the list of converted units. |
|
117 | - * |
|
118 | - * @return string[] |
|
119 | - */ |
|
115 | + /** |
|
116 | + * Resolves the list of converted units. |
|
117 | + * |
|
118 | + * @return string[] |
|
119 | + */ |
|
120 | 120 | private function resolveTokens() : array |
121 | 121 | { |
122 | 122 | $seconds = $this->seconds; |