@@ -20,24 +20,24 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class URLInfo_Parser |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | 26 | protected $url; |
27 | 27 | |
28 | - /** |
|
29 | - * @var bool |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var bool |
|
30 | + */ |
|
31 | 31 | protected $isValid = false; |
32 | 32 | |
33 | - /** |
|
34 | - * @var array |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var array |
|
35 | + */ |
|
36 | 36 | protected $info; |
37 | 37 | |
38 | - /** |
|
39 | - * @var array|NULL |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var array|NULL |
|
40 | + */ |
|
41 | 41 | protected $error; |
42 | 42 | |
43 | 43 | /** |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | - /** |
|
181 | - * Goes through all information in the parse_url result |
|
182 | - * array, and attempts to fix any user errors in formatting |
|
183 | - * that can be recovered from, mostly regarding stray spaces. |
|
184 | - */ |
|
180 | + /** |
|
181 | + * Goes through all information in the parse_url result |
|
182 | + * array, and attempts to fix any user errors in formatting |
|
183 | + * that can be recovered from, mostly regarding stray spaces. |
|
184 | + */ |
|
185 | 185 | protected function filterParsed() |
186 | 186 | { |
187 | 187 | foreach($this->info as $key => $val) |
@@ -20,9 +20,9 @@ |
||
20 | 20 | */ |
21 | 21 | class URLInfo_Highlighter |
22 | 22 | { |
23 | - /** |
|
24 | - * @var URLInfo |
|
25 | - */ |
|
23 | + /** |
|
24 | + * @var URLInfo |
|
25 | + */ |
|
26 | 26 | protected $info; |
27 | 27 | |
28 | 28 | public function __construct(URLInfo $info) |
@@ -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 | |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | return $this->buildURL($params, $dispatcher); |
125 | 125 | } |
126 | 126 | |
127 | - /** |
|
128 | - * Retrieves the name of the current dispatcher script / page. |
|
129 | - * This is made to be extended and implemented in a subclass. |
|
130 | - * |
|
131 | - * @return string |
|
132 | - */ |
|
127 | + /** |
|
128 | + * Retrieves the name of the current dispatcher script / page. |
|
129 | + * This is made to be extended and implemented in a subclass. |
|
130 | + * |
|
131 | + * @return string |
|
132 | + */ |
|
133 | 133 | public function getDispatcher() : string |
134 | 134 | { |
135 | 135 | return ''; |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | return $url; |
199 | 199 | } |
200 | 200 | |
201 | - /** |
|
202 | - * Retrieves the base URL of the application. |
|
203 | - * @return string |
|
204 | - */ |
|
201 | + /** |
|
202 | + * Retrieves the base URL of the application. |
|
203 | + * @return string |
|
204 | + */ |
|
205 | 205 | public function getBaseURL() : string |
206 | 206 | { |
207 | 207 | return $this->baseURL; |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | return $this->knownParams[$name]; |
232 | 232 | } |
233 | 233 | |
234 | - /** |
|
235 | - * Retrieves a previously registered parameter instance. |
|
236 | - * |
|
237 | - * @param string $name |
|
238 | - * @throws Request_Exception |
|
239 | - * @return Request_Param |
|
240 | - */ |
|
234 | + /** |
|
235 | + * Retrieves a previously registered parameter instance. |
|
236 | + * |
|
237 | + * @param string $name |
|
238 | + * @throws Request_Exception |
|
239 | + * @return Request_Param |
|
240 | + */ |
|
241 | 241 | public function getRegisteredParam(string $name) : Request_Param |
242 | 242 | { |
243 | 243 | if(isset($this->knownParams[$name])) { |
@@ -254,48 +254,48 @@ discard block |
||
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
257 | - /** |
|
258 | - * Checks whether a parameter with the specified name |
|
259 | - * has been registered. |
|
260 | - * |
|
261 | - * @param string $name |
|
262 | - * @return bool |
|
263 | - */ |
|
257 | + /** |
|
258 | + * Checks whether a parameter with the specified name |
|
259 | + * has been registered. |
|
260 | + * |
|
261 | + * @param string $name |
|
262 | + * @return bool |
|
263 | + */ |
|
264 | 264 | public function hasRegisteredParam(string $name) : bool |
265 | 265 | { |
266 | 266 | return isset($this->knownParams[$name]); |
267 | 267 | } |
268 | 268 | |
269 | - /** |
|
270 | - * Retrieves an indexed array with accept mime types |
|
271 | - * that the client sent, in the order of preference |
|
272 | - * the client specified. |
|
273 | - * |
|
274 | - * Example: |
|
275 | - * |
|
276 | - * array( |
|
277 | - * 'text/html', |
|
278 | - * 'application/xhtml+xml', |
|
279 | - * 'image/webp' |
|
280 | - * ... |
|
281 | - * ) |
|
282 | - * |
|
283 | - * @return array |
|
284 | - * @see Request::parseAcceptHeaders() |
|
285 | - */ |
|
269 | + /** |
|
270 | + * Retrieves an indexed array with accept mime types |
|
271 | + * that the client sent, in the order of preference |
|
272 | + * the client specified. |
|
273 | + * |
|
274 | + * Example: |
|
275 | + * |
|
276 | + * array( |
|
277 | + * 'text/html', |
|
278 | + * 'application/xhtml+xml', |
|
279 | + * 'image/webp' |
|
280 | + * ... |
|
281 | + * ) |
|
282 | + * |
|
283 | + * @return array |
|
284 | + * @see Request::parseAcceptHeaders() |
|
285 | + */ |
|
286 | 286 | public static function getAcceptHeaders() : array |
287 | 287 | { |
288 | 288 | return self::parseAcceptHeaders()->getMimeStrings(); |
289 | 289 | } |
290 | 290 | |
291 | - /** |
|
292 | - * Returns an instance of the accept headers parser, |
|
293 | - * to access information on the browser's accepted |
|
294 | - * mime types. |
|
295 | - * |
|
296 | - * @return Request_AcceptHeaders |
|
297 | - * @see Request::getAcceptHeaders() |
|
298 | - */ |
|
291 | + /** |
|
292 | + * Returns an instance of the accept headers parser, |
|
293 | + * to access information on the browser's accepted |
|
294 | + * mime types. |
|
295 | + * |
|
296 | + * @return Request_AcceptHeaders |
|
297 | + * @see Request::getAcceptHeaders() |
|
298 | + */ |
|
299 | 299 | public static function parseAcceptHeaders() : Request_AcceptHeaders |
300 | 300 | { |
301 | 301 | static $accept; |
@@ -343,14 +343,14 @@ discard block |
||
343 | 343 | return false; |
344 | 344 | } |
345 | 345 | |
346 | - /** |
|
347 | - * Removes a single parameter from the request. |
|
348 | - * If the parameter has been registered, also |
|
349 | - * removes the registration info. |
|
350 | - * |
|
351 | - * @param string $name |
|
352 | - * @return Request |
|
353 | - */ |
|
346 | + /** |
|
347 | + * Removes a single parameter from the request. |
|
348 | + * If the parameter has been registered, also |
|
349 | + * removes the registration info. |
|
350 | + * |
|
351 | + * @param string $name |
|
352 | + * @return Request |
|
353 | + */ |
|
354 | 354 | public function removeParam(string $name) : Request |
355 | 355 | { |
356 | 356 | if(isset($_REQUEST[$name])) { |
@@ -364,12 +364,12 @@ discard block |
||
364 | 364 | return $this; |
365 | 365 | } |
366 | 366 | |
367 | - /** |
|
368 | - * Removes several parameters from the request. |
|
369 | - * |
|
370 | - * @param string[] $names |
|
371 | - * @return Request |
|
372 | - */ |
|
367 | + /** |
|
368 | + * Removes several parameters from the request. |
|
369 | + * |
|
370 | + * @param string[] $names |
|
371 | + * @return Request |
|
372 | + */ |
|
373 | 373 | public function removeParams(array $names) : Request |
374 | 374 | { |
375 | 375 | foreach($names as $name) { |
@@ -434,18 +434,18 @@ discard block |
||
434 | 434 | return $val; |
435 | 435 | } |
436 | 436 | |
437 | - /** |
|
438 | - * Treats the request parameter as a JSON string, and |
|
439 | - * if it exists and contains valid JSON, returns the |
|
440 | - * decoded JSON value as an array (default). |
|
441 | - * |
|
442 | - * @param string $name |
|
443 | - * @param bool $assoc |
|
444 | - * @return array|object |
|
445 | - * |
|
446 | - * @see Request::getJSONAssoc() |
|
447 | - * @see Request::getJSONObject() |
|
448 | - */ |
|
437 | + /** |
|
438 | + * Treats the request parameter as a JSON string, and |
|
439 | + * if it exists and contains valid JSON, returns the |
|
440 | + * decoded JSON value as an array (default). |
|
441 | + * |
|
442 | + * @param string $name |
|
443 | + * @param bool $assoc |
|
444 | + * @return array|object |
|
445 | + * |
|
446 | + * @see Request::getJSONAssoc() |
|
447 | + * @see Request::getJSONObject() |
|
448 | + */ |
|
449 | 449 | public function getJSON(string $name, bool $assoc=true) |
450 | 450 | { |
451 | 451 | $value = $this->getParam($name); |
@@ -470,13 +470,13 @@ discard block |
||
470 | 470 | return new \stdClass(); |
471 | 471 | } |
472 | 472 | |
473 | - /** |
|
474 | - * Like {@link Request::getJSON()}, but omitting the second |
|
475 | - * parameter. Use this for more readable code. |
|
476 | - * |
|
477 | - * @param string $name |
|
478 | - * @return array |
|
479 | - */ |
|
473 | + /** |
|
474 | + * Like {@link Request::getJSON()}, but omitting the second |
|
475 | + * parameter. Use this for more readable code. |
|
476 | + * |
|
477 | + * @param string $name |
|
478 | + * @return array |
|
479 | + */ |
|
480 | 480 | public function getJSONAssoc(string $name) : array |
481 | 481 | { |
482 | 482 | $result = $this->getJSON($name); |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | return array(); |
488 | 488 | } |
489 | 489 | |
490 | - /** |
|
491 | - * Like {@link Request::getJSON()}, but omitting the second |
|
492 | - * parameter. Use this for more readable code. |
|
493 | - * |
|
494 | - * @param string $name |
|
495 | - * @return object |
|
496 | - */ |
|
490 | + /** |
|
491 | + * Like {@link Request::getJSON()}, but omitting the second |
|
492 | + * parameter. Use this for more readable code. |
|
493 | + * |
|
494 | + * @param string $name |
|
495 | + * @return object |
|
496 | + */ |
|
497 | 497 | public function getJSONObject(string $name) : object |
498 | 498 | { |
499 | 499 | $result = $this->getJSON($name, false); |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | return new \stdClass(); |
505 | 505 | } |
506 | 506 | |
507 | - /** |
|
508 | - * Sends a JSON response with the correct headers. |
|
509 | - * |
|
510 | - * @param array|string $data |
|
511 | - * @param bool $exit Whether to exit the script afterwards. |
|
512 | - */ |
|
507 | + /** |
|
508 | + * Sends a JSON response with the correct headers. |
|
509 | + * |
|
510 | + * @param array|string $data |
|
511 | + * @param bool $exit Whether to exit the script afterwards. |
|
512 | + */ |
|
513 | 513 | public static function sendJSON($data, bool $exit=true) |
514 | 514 | { |
515 | 515 | $payload = $data; |
@@ -529,12 +529,12 @@ discard block |
||
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
532 | - /** |
|
533 | - * Sends HTML to the browser with the correct headers. |
|
534 | - * |
|
535 | - * @param string $html |
|
536 | - * @param bool $exit Whether to exit the script afterwards. |
|
537 | - */ |
|
532 | + /** |
|
533 | + * Sends HTML to the browser with the correct headers. |
|
534 | + * |
|
535 | + * @param string $html |
|
536 | + * @param bool $exit Whether to exit the script afterwards. |
|
537 | + */ |
|
538 | 538 | public static function sendHTML(string $html, bool $exit=true) |
539 | 539 | { |
540 | 540 | header('Cache-Control: no-cache, must-revalidate'); |
@@ -549,16 +549,16 @@ discard block |
||
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - /** |
|
553 | - * Creates a new instance of the URL comparer, which can check |
|
554 | - * whether the specified URLs match, regardless of the order in |
|
555 | - * which the query parameters are, if any. |
|
556 | - * |
|
557 | - * @param string $sourceURL |
|
558 | - * @param string $targetURL |
|
559 | - * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
560 | - * @return Request_URLComparer |
|
561 | - */ |
|
552 | + /** |
|
553 | + * Creates a new instance of the URL comparer, which can check |
|
554 | + * whether the specified URLs match, regardless of the order in |
|
555 | + * which the query parameters are, if any. |
|
556 | + * |
|
557 | + * @param string $sourceURL |
|
558 | + * @param string $targetURL |
|
559 | + * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
560 | + * @return Request_URLComparer |
|
561 | + */ |
|
562 | 562 | public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
563 | 563 | { |
564 | 564 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
@@ -567,10 +567,10 @@ discard block |
||
567 | 567 | return $comparer; |
568 | 568 | } |
569 | 569 | |
570 | - /** |
|
571 | - * Retrieves the full URL that was used to access the current page. |
|
572 | - * @return string |
|
573 | - */ |
|
570 | + /** |
|
571 | + * Retrieves the full URL that was used to access the current page. |
|
572 | + * @return string |
|
573 | + */ |
|
574 | 574 | public function getCurrentURL() : string |
575 | 575 | { |
576 | 576 | return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | $this->parse(); |
29 | 29 | } |
30 | 30 | |
31 | - /** |
|
32 | - * Retrieves an indexed array with accept mime types |
|
33 | - * that the client sent, in the order of preference |
|
34 | - * the client specified. |
|
35 | - * |
|
36 | - * Example: |
|
37 | - * |
|
38 | - * array( |
|
39 | - * 'text/html', |
|
40 | - * 'application/xhtml+xml', |
|
41 | - * 'image/webp' |
|
42 | - * ... |
|
43 | - * ) |
|
44 | - */ |
|
31 | + /** |
|
32 | + * Retrieves an indexed array with accept mime types |
|
33 | + * that the client sent, in the order of preference |
|
34 | + * the client specified. |
|
35 | + * |
|
36 | + * Example: |
|
37 | + * |
|
38 | + * array( |
|
39 | + * 'text/html', |
|
40 | + * 'application/xhtml+xml', |
|
41 | + * 'image/webp' |
|
42 | + * ... |
|
43 | + * ) |
|
44 | + */ |
|
45 | 45 | public function getMimeStrings() : array |
46 | 46 | { |
47 | 47 | $result = array(); |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | return $result; |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * Checks that an accept header string exists, and tries to parse it. |
|
59 | - */ |
|
57 | + /** |
|
58 | + * Checks that an accept header string exists, and tries to parse it. |
|
59 | + */ |
|
60 | 60 | protected function parse() : void |
61 | 61 | { |
62 | 62 | // we may be in a CLI environment where the headers |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | $this->headers = $this->parseHeader($_SERVER['HTTP_ACCEPT']); |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * Splits the accept header string and parses the mime types. |
|
73 | - * |
|
74 | - * @param string $acceptHeader |
|
75 | - */ |
|
71 | + /** |
|
72 | + * Splits the accept header string and parses the mime types. |
|
73 | + * |
|
74 | + * @param string $acceptHeader |
|
75 | + */ |
|
76 | 76 | protected function parseHeader(string $acceptHeader) : array |
77 | 77 | { |
78 | 78 | $tokens = preg_split('/\s*,\s*/', $acceptHeader); |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | return $accept; |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * Parses a single mime type entry. |
|
94 | - * |
|
95 | - * @param int $i The position in the accept string |
|
96 | - * @param string $mime The mime type |
|
97 | - * @return array |
|
98 | - */ |
|
92 | + /** |
|
93 | + * Parses a single mime type entry. |
|
94 | + * |
|
95 | + * @param int $i The position in the accept string |
|
96 | + * @param string $mime The mime type |
|
97 | + * @return array |
|
98 | + */ |
|
99 | 99 | protected function parseEntry(int $i, string $mime) : array |
100 | 100 | { |
101 | 101 | $entry = array( |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | return $entry; |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * Sorts the mime types collection, first by quality |
|
130 | - * and then by position in the list. |
|
131 | - * |
|
132 | - * @param array $a |
|
133 | - * @param array $b |
|
134 | - * @return number |
|
135 | - */ |
|
128 | + /** |
|
129 | + * Sorts the mime types collection, first by quality |
|
130 | + * and then by position in the list. |
|
131 | + * |
|
132 | + * @param array $a |
|
133 | + * @param array $b |
|
134 | + * @return number |
|
135 | + */ |
|
136 | 136 | protected function sortMimeTypes(array $a, array $b) |
137 | 137 | { |
138 | 138 | /* first tier: highest q factor wins */ |
@@ -22,9 +22,9 @@ |
||
22 | 22 | { |
23 | 23 | use Traits_Optionable; |
24 | 24 | |
25 | - /** |
|
26 | - * @var Request_Param |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var Request_Param |
|
27 | + */ |
|
28 | 28 | protected $param; |
29 | 29 | |
30 | 30 | protected $value; |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - /** |
|
118 | - * Adds a callback as a validation method. The callback gets the |
|
119 | - * value to validate as first parameter, and any additional |
|
120 | - * parameters passed here get appended to that. |
|
121 | - * |
|
122 | - * The callback must return boolean true or false depending on |
|
123 | - * whether the value is valid. |
|
124 | - * |
|
125 | - * @param callable $callback |
|
126 | - * @param array $args |
|
127 | - * @return Request_Param |
|
128 | - */ |
|
117 | + /** |
|
118 | + * Adds a callback as a validation method. The callback gets the |
|
119 | + * value to validate as first parameter, and any additional |
|
120 | + * parameters passed here get appended to that. |
|
121 | + * |
|
122 | + * The callback must return boolean true or false depending on |
|
123 | + * whether the value is valid. |
|
124 | + * |
|
125 | + * @param callable $callback |
|
126 | + * @param array $args |
|
127 | + * @return Request_Param |
|
128 | + */ |
|
129 | 129 | public function setCallback($callback, array $args=array()) : Request_Param |
130 | 130 | { |
131 | 131 | if(!is_callable($callback)) { |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | return $value; |
170 | 170 | } |
171 | 171 | |
172 | - /** |
|
173 | - * Validates the specified value using the validation type. Returns |
|
174 | - * the validated value. |
|
175 | - * |
|
176 | - * @param mixed $value |
|
177 | - * @param string $type |
|
178 | - * @param array $params |
|
179 | - * @throws Request_Exception |
|
180 | - * @return mixed |
|
181 | - */ |
|
172 | + /** |
|
173 | + * Validates the specified value using the validation type. Returns |
|
174 | + * the validated value. |
|
175 | + * |
|
176 | + * @param mixed $value |
|
177 | + * @param string $type |
|
178 | + * @param array $params |
|
179 | + * @throws Request_Exception |
|
180 | + * @return mixed |
|
181 | + */ |
|
182 | 182 | protected function validateType($value, string $type, array $params) |
183 | 183 | { |
184 | 184 | $class = '\AppUtils\Request_Param_Validator_'.ucfirst($type); |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | |
277 | 277 | protected $valueType = self::VALUE_TYPE_STRING; |
278 | 278 | |
279 | - /** |
|
280 | - * Sets the variable to contain a comma-separated list of integer IDs. |
|
281 | - * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
282 | - * <code>145</code>. |
|
283 | - * |
|
284 | - * @return Request_Param |
|
285 | - */ |
|
279 | + /** |
|
280 | + * Sets the variable to contain a comma-separated list of integer IDs. |
|
281 | + * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
282 | + * <code>145</code>. |
|
283 | + * |
|
284 | + * @return Request_Param |
|
285 | + */ |
|
286 | 286 | public function setIDList() |
287 | 287 | { |
288 | 288 | $this->valueType = self::VALUE_TYPE_ID_LIST; |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | return $this; |
292 | 292 | } |
293 | 293 | |
294 | - /** |
|
295 | - * Sets the variable to be an alias, as defined by the |
|
296 | - * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
297 | - * |
|
298 | - * @return Request_Param |
|
299 | - * @see RegexHelper::REGEX_ALIAS |
|
300 | - */ |
|
294 | + /** |
|
295 | + * Sets the variable to be an alias, as defined by the |
|
296 | + * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
297 | + * |
|
298 | + * @return Request_Param |
|
299 | + * @see RegexHelper::REGEX_ALIAS |
|
300 | + */ |
|
301 | 301 | public function setAlias() |
302 | 302 | { |
303 | 303 | return $this->setRegex(RegexHelper::REGEX_ALIAS); |
@@ -338,12 +338,12 @@ discard block |
||
338 | 338 | return $this->setValidation(self::VALIDATION_TYPE_ALPHA); |
339 | 339 | } |
340 | 340 | |
341 | - /** |
|
342 | - * Sets the parameter value as a string containing lowercase |
|
343 | - * and/or uppercase letters, as well as numbers. |
|
344 | - * |
|
345 | - * @return Request_Param |
|
346 | - */ |
|
341 | + /** |
|
342 | + * Sets the parameter value as a string containing lowercase |
|
343 | + * and/or uppercase letters, as well as numbers. |
|
344 | + * |
|
345 | + * @return Request_Param |
|
346 | + */ |
|
347 | 347 | public function setAlnum() |
348 | 348 | { |
349 | 349 | return $this->setValidation(self::VALIDATION_TYPE_ALNUM); |
@@ -376,17 +376,17 @@ discard block |
||
376 | 376 | ); |
377 | 377 | } |
378 | 378 | |
379 | - /** |
|
380 | - * Only available for array values: the parameter must be |
|
381 | - * an array value, and the array may only contain values |
|
382 | - * specified in the values array. |
|
383 | - * |
|
384 | - * Submitted values that are not in the allowed list of |
|
385 | - * values are stripped from the value. |
|
386 | - * |
|
387 | - * @param array $values List of allowed values |
|
388 | - * @return \AppUtils\Request_Param |
|
389 | - */ |
|
379 | + /** |
|
380 | + * Only available for array values: the parameter must be |
|
381 | + * an array value, and the array may only contain values |
|
382 | + * specified in the values array. |
|
383 | + * |
|
384 | + * Submitted values that are not in the allowed list of |
|
385 | + * values are stripped from the value. |
|
386 | + * |
|
387 | + * @param array $values List of allowed values |
|
388 | + * @return \AppUtils\Request_Param |
|
389 | + */ |
|
390 | 390 | public function setValuesList(array $values) |
391 | 391 | { |
392 | 392 | $this->setArray(); |
@@ -404,53 +404,53 @@ discard block |
||
404 | 404 | return $this->setValidation(self::VALIDATION_TYPE_ARRAY); |
405 | 405 | } |
406 | 406 | |
407 | - /** |
|
408 | - * Specifies that a JSON-encoded string is expected. |
|
409 | - * |
|
410 | - * NOTE: Numbers or quoted strings are technically valid |
|
411 | - * JSON, but are not accepted, because it is assumed |
|
412 | - * at least an array or object are expected. |
|
413 | - * |
|
414 | - * @return \AppUtils\Request_Param |
|
415 | - */ |
|
407 | + /** |
|
408 | + * Specifies that a JSON-encoded string is expected. |
|
409 | + * |
|
410 | + * NOTE: Numbers or quoted strings are technically valid |
|
411 | + * JSON, but are not accepted, because it is assumed |
|
412 | + * at least an array or object are expected. |
|
413 | + * |
|
414 | + * @return \AppUtils\Request_Param |
|
415 | + */ |
|
416 | 416 | public function setJSON() : Request_Param |
417 | 417 | { |
418 | 418 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => true)); |
419 | 419 | } |
420 | 420 | |
421 | - /** |
|
422 | - * Like {@link Request_Param::setJSON()}, but accepts |
|
423 | - * only JSON objects. Arrays will not be accepted. |
|
424 | - * |
|
425 | - * @return \AppUtils\Request_Param |
|
426 | - */ |
|
421 | + /** |
|
422 | + * Like {@link Request_Param::setJSON()}, but accepts |
|
423 | + * only JSON objects. Arrays will not be accepted. |
|
424 | + * |
|
425 | + * @return \AppUtils\Request_Param |
|
426 | + */ |
|
427 | 427 | public function setJSONObject() : Request_Param |
428 | 428 | { |
429 | 429 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => false)); |
430 | 430 | } |
431 | 431 | |
432 | - /** |
|
433 | - * The parameter is a string boolean representation. This means |
|
434 | - * it can be any of the following: "yes", "true", "no", "false". |
|
435 | - * The value is automatically converted to a boolean when retrieving |
|
436 | - * the parameter. |
|
437 | - * |
|
438 | - * @return Request_Param |
|
439 | - */ |
|
432 | + /** |
|
433 | + * The parameter is a string boolean representation. This means |
|
434 | + * it can be any of the following: "yes", "true", "no", "false". |
|
435 | + * The value is automatically converted to a boolean when retrieving |
|
436 | + * the parameter. |
|
437 | + * |
|
438 | + * @return Request_Param |
|
439 | + */ |
|
440 | 440 | public function setBoolean() : Request_Param |
441 | 441 | { |
442 | 442 | return $this->addClassFilter('Boolean'); |
443 | 443 | } |
444 | 444 | |
445 | - /** |
|
446 | - * Validates the request parameter as an MD5 string, |
|
447 | - * so that only values resembling md5 values are accepted. |
|
448 | - * |
|
449 | - * NOTE: This can only guarantee the format, not whether |
|
450 | - * it is an actual valid hash of something. |
|
451 | - * |
|
452 | - * @return \AppUtils\Request_Param |
|
453 | - */ |
|
445 | + /** |
|
446 | + * Validates the request parameter as an MD5 string, |
|
447 | + * so that only values resembling md5 values are accepted. |
|
448 | + * |
|
449 | + * NOTE: This can only guarantee the format, not whether |
|
450 | + * it is an actual valid hash of something. |
|
451 | + * |
|
452 | + * @return \AppUtils\Request_Param |
|
453 | + */ |
|
454 | 454 | public function setMD5() : Request_Param |
455 | 455 | { |
456 | 456 | return $this->setRegex(RegexHelper::REGEX_MD5); |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | return $this; |
493 | 493 | } |
494 | 494 | |
495 | - /** |
|
496 | - * Retrieves the value of the request parameter, |
|
497 | - * applying all filters (if any) and validation |
|
498 | - * (if any). |
|
499 | - * |
|
500 | - * @param mixed $default |
|
501 | - * @return mixed |
|
502 | - */ |
|
495 | + /** |
|
496 | + * Retrieves the value of the request parameter, |
|
497 | + * applying all filters (if any) and validation |
|
498 | + * (if any). |
|
499 | + * |
|
500 | + * @param mixed $default |
|
501 | + * @return mixed |
|
502 | + */ |
|
503 | 503 | public function get($default=null) |
504 | 504 | { |
505 | 505 | $value = $this->request->getParam($this->paramName); |
@@ -587,12 +587,12 @@ discard block |
||
587 | 587 | return $this; |
588 | 588 | } |
589 | 589 | |
590 | - /** |
|
591 | - * Adds a filter that trims whitespace from the request |
|
592 | - * parameter using the PHP <code>trim</code> function. |
|
593 | - * |
|
594 | - * @return \AppUtils\Request_Param |
|
595 | - */ |
|
590 | + /** |
|
591 | + * Adds a filter that trims whitespace from the request |
|
592 | + * parameter using the PHP <code>trim</code> function. |
|
593 | + * |
|
594 | + * @return \AppUtils\Request_Param |
|
595 | + */ |
|
596 | 596 | public function addFilterTrim() : Request_Param |
597 | 597 | { |
598 | 598 | // to guarantee we only work with strings |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | return $this->addCallbackFilter('trim'); |
602 | 602 | } |
603 | 603 | |
604 | - /** |
|
605 | - * Converts the value to a string, even if it is not |
|
606 | - * a string value. Complex types like arrays and objects |
|
607 | - * are converted to an empty string. |
|
608 | - * |
|
609 | - * @return \AppUtils\Request_Param |
|
610 | - */ |
|
604 | + /** |
|
605 | + * Converts the value to a string, even if it is not |
|
606 | + * a string value. Complex types like arrays and objects |
|
607 | + * are converted to an empty string. |
|
608 | + * |
|
609 | + * @return \AppUtils\Request_Param |
|
610 | + */ |
|
611 | 611 | public function addStringFilter() : Request_Param |
612 | 612 | { |
613 | 613 | return $this->addClassFilter('String'); |
@@ -657,12 +657,12 @@ discard block |
||
657 | 657 | return $this->addCallbackFilter('strip_tags', array($allowedTags)); |
658 | 658 | } |
659 | 659 | |
660 | - /** |
|
661 | - * Adds a filter that strips all whitespace from the |
|
662 | - * request parameter, from spaces to tabs and newlines. |
|
663 | - * |
|
664 | - * @return \AppUtils\Request_Param |
|
665 | - */ |
|
660 | + /** |
|
661 | + * Adds a filter that strips all whitespace from the |
|
662 | + * request parameter, from spaces to tabs and newlines. |
|
663 | + * |
|
664 | + * @return \AppUtils\Request_Param |
|
665 | + */ |
|
666 | 666 | public function addStripWhitespaceFilter() : Request_Param |
667 | 667 | { |
668 | 668 | // to ensure we only work with strings. |
@@ -671,14 +671,14 @@ discard block |
||
671 | 671 | return $this->addClassFilter('StripWhitespace'); |
672 | 672 | } |
673 | 673 | |
674 | - /** |
|
675 | - * Adds a filter that transforms comma separated values |
|
676 | - * into an array of values. |
|
677 | - * |
|
678 | - * @param bool $trimEntries Trim whitespace from each entry? |
|
679 | - * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
680 | - * @return \AppUtils\Request_Param |
|
681 | - */ |
|
674 | + /** |
|
675 | + * Adds a filter that transforms comma separated values |
|
676 | + * into an array of values. |
|
677 | + * |
|
678 | + * @param bool $trimEntries Trim whitespace from each entry? |
|
679 | + * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
680 | + * @return \AppUtils\Request_Param |
|
681 | + */ |
|
682 | 682 | public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
683 | 683 | { |
684 | 684 | $this->setArray(); |
@@ -703,12 +703,12 @@ discard block |
||
703 | 703 | ); |
704 | 704 | } |
705 | 705 | |
706 | - /** |
|
707 | - * Adds a filter that encodes all HTML special characters |
|
708 | - * using the PHP <code>htmlspecialchars</code> function. |
|
709 | - * |
|
710 | - * @return \AppUtils\Request_Param |
|
711 | - */ |
|
706 | + /** |
|
707 | + * Adds a filter that encodes all HTML special characters |
|
708 | + * using the PHP <code>htmlspecialchars</code> function. |
|
709 | + * |
|
710 | + * @return \AppUtils\Request_Param |
|
711 | + */ |
|
712 | 712 | public function addHTMLSpecialcharsFilter() : Request_Param |
713 | 713 | { |
714 | 714 | return $this->addCallbackFilter('htmlspecialchars', array(ENT_QUOTES, 'UTF-8')); |
@@ -721,14 +721,14 @@ discard block |
||
721 | 721 | |
722 | 722 | protected $required = false; |
723 | 723 | |
724 | - /** |
|
725 | - * Marks this request parameter as required. To use this feature, |
|
726 | - * you have to call the request's {@link Request::validate()} |
|
727 | - * method. |
|
728 | - * |
|
729 | - * @return Request_Param |
|
730 | - * @see Request::validate() |
|
731 | - */ |
|
724 | + /** |
|
725 | + * Marks this request parameter as required. To use this feature, |
|
726 | + * you have to call the request's {@link Request::validate()} |
|
727 | + * method. |
|
728 | + * |
|
729 | + * @return Request_Param |
|
730 | + * @see Request::validate() |
|
731 | + */ |
|
732 | 732 | public function makeRequired() : Request_Param |
733 | 733 | { |
734 | 734 | $this->required = true; |
@@ -6,9 +6,9 @@ |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer_String extends VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | 14 | protected function init() |
@@ -6,19 +6,19 @@ discard block |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | - /** |
|
15 | - * @var VariableInfo |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @var VariableInfo |
|
16 | + */ |
|
17 | 17 | protected $info; |
18 | 18 | |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | 22 | protected $type; |
23 | 23 | |
24 | 24 | public function __construct(VariableInfo $info) |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | |
32 | 32 | abstract protected function init(); |
33 | 33 | |
34 | - /** |
|
35 | - * Renders the value to the target format. |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
34 | + /** |
|
35 | + * Renders the value to the target format. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | 39 | public function render() |
40 | 40 | { |
41 | 41 | return $this->_render(); |
@@ -19,25 +19,25 @@ discard block |
||
19 | 19 | const TYPE_UNKNOWN = 'unknown type'; |
20 | 20 | const TYPE_CALLABLE = 'callable'; |
21 | 21 | |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | protected $string; |
26 | 26 | |
27 | - /** |
|
28 | - * @var mixed |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var mixed |
|
29 | + */ |
|
30 | 30 | protected $value; |
31 | 31 | |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | 35 | protected $type; |
36 | 36 | |
37 | - /** |
|
38 | - * @param mixed $value |
|
39 | - * @param array|null $serialized |
|
40 | - */ |
|
37 | + /** |
|
38 | + * @param mixed $value |
|
39 | + * @param array|null $serialized |
|
40 | + */ |
|
41 | 41 | public function __construct($value, $serialized=null) |
42 | 42 | { |
43 | 43 | if(is_array($serialized)) |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - /** |
|
54 | - * Creates a new variable info instance from a PHP variable |
|
55 | - * of any type. |
|
56 | - * |
|
57 | - * @param mixed $variable |
|
58 | - * @return VariableInfo |
|
59 | - */ |
|
53 | + /** |
|
54 | + * Creates a new variable info instance from a PHP variable |
|
55 | + * of any type. |
|
56 | + * |
|
57 | + * @param mixed $variable |
|
58 | + * @return VariableInfo |
|
59 | + */ |
|
60 | 60 | public static function fromVariable($variable) : VariableInfo |
61 | 61 | { |
62 | 62 | return new VariableInfo($variable); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * Restores a variable info instance using a previously serialized |
|
67 | - * array using the serialize() method. |
|
68 | - * |
|
69 | - * @param array $serialized |
|
70 | - * @return VariableInfo |
|
71 | - * @see VariableInfo::serialize() |
|
72 | - */ |
|
65 | + /** |
|
66 | + * Restores a variable info instance using a previously serialized |
|
67 | + * array using the serialize() method. |
|
68 | + * |
|
69 | + * @param array $serialized |
|
70 | + * @return VariableInfo |
|
71 | + * @see VariableInfo::serialize() |
|
72 | + */ |
|
73 | 73 | public static function fromSerialized(array $serialized) : VariableInfo |
74 | 74 | { |
75 | 75 | return new VariableInfo(null, $serialized); |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | return $this->value; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * The variable type - this is the same string that |
|
105 | - * is returned by the PHP function `gettype`. |
|
106 | - * |
|
107 | - * @return string |
|
108 | - */ |
|
103 | + /** |
|
104 | + * The variable type - this is the same string that |
|
105 | + * is returned by the PHP function `gettype`. |
|
106 | + * |
|
107 | + * @return string |
|
108 | + */ |
|
109 | 109 | public function getType() : string |
110 | 110 | { |
111 | 111 | return $this->type; |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
122 | - /** |
|
123 | - * Whether to prepend the variable type before the value, |
|
124 | - * like the var_dump function. Example: <code>string "Some text"</code>. |
|
125 | - * |
|
126 | - * @param bool $enable |
|
127 | - * @return VariableInfo |
|
128 | - */ |
|
122 | + /** |
|
123 | + * Whether to prepend the variable type before the value, |
|
124 | + * like the var_dump function. Example: <code>string "Some text"</code>. |
|
125 | + * |
|
126 | + * @param bool $enable |
|
127 | + * @return VariableInfo |
|
128 | + */ |
|
129 | 129 | public function enableType(bool $enable=true) : VariableInfo |
130 | 130 | { |
131 | 131 | return $this->setOption('prepend-type', $enable); |