@@ -111,18 +111,18 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Adds a callback as a validation method. The callback gets the |
|
| 116 | - * value to validate as first parameter, and any additional |
|
| 117 | - * parameters passed here get appended to that. |
|
| 118 | - * |
|
| 119 | - * The callback must return boolean true or false depending on |
|
| 120 | - * whether the value is valid. |
|
| 121 | - * |
|
| 122 | - * @param mixed $callback |
|
| 123 | - * @param array $args |
|
| 124 | - * @return Request_Param |
|
| 125 | - */ |
|
| 114 | + /** |
|
| 115 | + * Adds a callback as a validation method. The callback gets the |
|
| 116 | + * value to validate as first parameter, and any additional |
|
| 117 | + * parameters passed here get appended to that. |
|
| 118 | + * |
|
| 119 | + * The callback must return boolean true or false depending on |
|
| 120 | + * whether the value is valid. |
|
| 121 | + * |
|
| 122 | + * @param mixed $callback |
|
| 123 | + * @param array $args |
|
| 124 | + * @return Request_Param |
|
| 125 | + */ |
|
| 126 | 126 | public function setCallback($callback, $args=array()) |
| 127 | 127 | { |
| 128 | 128 | if(!is_callable($callback)) { |
@@ -264,13 +264,13 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | protected $valueType = self::VALUE_TYPE_STRING; |
| 266 | 266 | |
| 267 | - /** |
|
| 268 | - * Sets the variable to contain a comma-separated list of integer IDs. |
|
| 269 | - * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
| 270 | - * <code>145</code>. |
|
| 271 | - * |
|
| 272 | - * @return Request_Param |
|
| 273 | - */ |
|
| 267 | + /** |
|
| 268 | + * Sets the variable to contain a comma-separated list of integer IDs. |
|
| 269 | + * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
| 270 | + * <code>145</code>. |
|
| 271 | + * |
|
| 272 | + * @return Request_Param |
|
| 273 | + */ |
|
| 274 | 274 | public function setIDList() |
| 275 | 275 | { |
| 276 | 276 | $this->valueType = self::VALUE_TYPE_ID_LIST; |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | return $this; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - /** |
|
| 283 | - * Sets the variable to be an alias, as defined by the |
|
| 284 | - * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
| 285 | - * |
|
| 286 | - * @return Request_Param |
|
| 287 | - * @see RegexHelper::REGEX_ALIAS |
|
| 288 | - */ |
|
| 282 | + /** |
|
| 283 | + * Sets the variable to be an alias, as defined by the |
|
| 284 | + * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
| 285 | + * |
|
| 286 | + * @return Request_Param |
|
| 287 | + * @see RegexHelper::REGEX_ALIAS |
|
| 288 | + */ |
|
| 289 | 289 | public function setAlias() |
| 290 | 290 | { |
| 291 | 291 | return $this->setRegex(RegexHelper::REGEX_ALIAS); |
@@ -326,12 +326,12 @@ discard block |
||
| 326 | 326 | return $this->setValidation(self::VALIDATION_TYPE_ALPHA); |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - /** |
|
| 330 | - * Sets the parameter value as a string containing lowercase |
|
| 331 | - * and/or uppercase letters, as well as numbers. |
|
| 332 | - * |
|
| 333 | - * @return Request_Param |
|
| 334 | - */ |
|
| 329 | + /** |
|
| 330 | + * Sets the parameter value as a string containing lowercase |
|
| 331 | + * and/or uppercase letters, as well as numbers. |
|
| 332 | + * |
|
| 333 | + * @return Request_Param |
|
| 334 | + */ |
|
| 335 | 335 | public function setAlnum() |
| 336 | 336 | { |
| 337 | 337 | return $this->setValidation(self::VALIDATION_TYPE_ALNUM); |
@@ -359,17 +359,17 @@ discard block |
||
| 359 | 359 | return $this->setValidation(self::VALIDATION_TYPE_ENUM, $args); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - /** |
|
| 363 | - * Only available for array values: the parameter must be |
|
| 364 | - * an array value, and the array may only contain values |
|
| 365 | - * specified in the values array. |
|
| 366 | - * |
|
| 367 | - * Submitted values that are not in the allowed list of |
|
| 368 | - * values are stripped from the value. |
|
| 369 | - * |
|
| 370 | - * @param array $values List of allowed values |
|
| 371 | - * @return \AppUtils\Request_Param |
|
| 372 | - */ |
|
| 362 | + /** |
|
| 363 | + * Only available for array values: the parameter must be |
|
| 364 | + * an array value, and the array may only contain values |
|
| 365 | + * specified in the values array. |
|
| 366 | + * |
|
| 367 | + * Submitted values that are not in the allowed list of |
|
| 368 | + * values are stripped from the value. |
|
| 369 | + * |
|
| 370 | + * @param array $values List of allowed values |
|
| 371 | + * @return \AppUtils\Request_Param |
|
| 372 | + */ |
|
| 373 | 373 | public function setValuesList(array $values) |
| 374 | 374 | { |
| 375 | 375 | $this->setArray(); |
@@ -382,39 +382,39 @@ discard block |
||
| 382 | 382 | return $this->setValidation(self::VALIDATION_TYPE_ARRAY); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - /** |
|
| 386 | - * Specifies that a JSON-encoded string is expected. |
|
| 387 | - * |
|
| 388 | - * NOTE: Numbers or quoted strings are technically valid |
|
| 389 | - * JSON, but are not accepted, because it is assumed |
|
| 390 | - * at least an array or object are expected. |
|
| 391 | - * |
|
| 392 | - * @return \AppUtils\Request_Param |
|
| 393 | - */ |
|
| 385 | + /** |
|
| 386 | + * Specifies that a JSON-encoded string is expected. |
|
| 387 | + * |
|
| 388 | + * NOTE: Numbers or quoted strings are technically valid |
|
| 389 | + * JSON, but are not accepted, because it is assumed |
|
| 390 | + * at least an array or object are expected. |
|
| 391 | + * |
|
| 392 | + * @return \AppUtils\Request_Param |
|
| 393 | + */ |
|
| 394 | 394 | public function setJSON() : Request_Param |
| 395 | 395 | { |
| 396 | 396 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => true)); |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * Like {@link Request_Param::setJSON()}, but accepts |
|
| 401 | - * only JSON objects. Arrays will not be accepted. |
|
| 402 | - * |
|
| 403 | - * @return \AppUtils\Request_Param |
|
| 404 | - */ |
|
| 399 | + /** |
|
| 400 | + * Like {@link Request_Param::setJSON()}, but accepts |
|
| 401 | + * only JSON objects. Arrays will not be accepted. |
|
| 402 | + * |
|
| 403 | + * @return \AppUtils\Request_Param |
|
| 404 | + */ |
|
| 405 | 405 | public function setJSONObject() : Request_Param |
| 406 | 406 | { |
| 407 | 407 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => false)); |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - /** |
|
| 411 | - * The parameter is a string boolean representation. This means |
|
| 412 | - * it can be any of the following: "yes", "true", "no", "false". |
|
| 413 | - * The value is automatically converted to a boolean when retrieving |
|
| 414 | - * the parameter. |
|
| 415 | - * |
|
| 416 | - * @return Request_Param |
|
| 417 | - */ |
|
| 410 | + /** |
|
| 411 | + * The parameter is a string boolean representation. This means |
|
| 412 | + * it can be any of the following: "yes", "true", "no", "false". |
|
| 413 | + * The value is automatically converted to a boolean when retrieving |
|
| 414 | + * the parameter. |
|
| 415 | + * |
|
| 416 | + * @return Request_Param |
|
| 417 | + */ |
|
| 418 | 418 | public function setBoolean() : Request_Param |
| 419 | 419 | { |
| 420 | 420 | $this->addCallbackFilter(array($this, 'applyFilter_boolean')); |
@@ -478,15 +478,15 @@ discard block |
||
| 478 | 478 | return $keep; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - /** |
|
| 482 | - * Validates the request parameter as an MD5 string, |
|
| 483 | - * so that only values resembling md5 values are accepted. |
|
| 484 | - * |
|
| 485 | - * NOTE: This can only guarantee the format, not whether |
|
| 486 | - * it is an actual valid hash of something. |
|
| 487 | - * |
|
| 488 | - * @return \AppUtils\Request_Param |
|
| 489 | - */ |
|
| 481 | + /** |
|
| 482 | + * Validates the request parameter as an MD5 string, |
|
| 483 | + * so that only values resembling md5 values are accepted. |
|
| 484 | + * |
|
| 485 | + * NOTE: This can only guarantee the format, not whether |
|
| 486 | + * it is an actual valid hash of something. |
|
| 487 | + * |
|
| 488 | + * @return \AppUtils\Request_Param |
|
| 489 | + */ |
|
| 490 | 490 | public function setMD5() : Request_Param |
| 491 | 491 | { |
| 492 | 492 | return $this->setRegex(RegexHelper::REGEX_MD5); |
@@ -528,14 +528,14 @@ discard block |
||
| 528 | 528 | return $this; |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - /** |
|
| 532 | - * Retrieves the value of the request parameter, |
|
| 533 | - * applying all filters (if any) and validation |
|
| 534 | - * (if any). |
|
| 535 | - * |
|
| 536 | - * @param mixed $default |
|
| 537 | - * @return mixed |
|
| 538 | - */ |
|
| 531 | + /** |
|
| 532 | + * Retrieves the value of the request parameter, |
|
| 533 | + * applying all filters (if any) and validation |
|
| 534 | + * (if any). |
|
| 535 | + * |
|
| 536 | + * @param mixed $default |
|
| 537 | + * @return mixed |
|
| 538 | + */ |
|
| 539 | 539 | public function get($default=null) |
| 540 | 540 | { |
| 541 | 541 | $value = $this->request->getParam($this->paramName); |
@@ -565,12 +565,12 @@ discard block |
||
| 565 | 565 | return null; |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - /** |
|
| 569 | - * Validates the syntax of an URL, but not its actual validity. |
|
| 570 | - * |
|
| 571 | - * @param mixed $value |
|
| 572 | - * @return string |
|
| 573 | - */ |
|
| 568 | + /** |
|
| 569 | + * Validates the syntax of an URL, but not its actual validity. |
|
| 570 | + * |
|
| 571 | + * @param mixed $value |
|
| 572 | + * @return string |
|
| 573 | + */ |
|
| 574 | 574 | protected function validate_url($value) : string |
| 575 | 575 | { |
| 576 | 576 | if(!is_string($value)) { |
@@ -710,10 +710,10 @@ discard block |
||
| 710 | 710 | return null; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - /** |
|
| 714 | - * Makes sure that the value is a JSON-encoded string. |
|
| 715 | - * @param string $value |
|
| 716 | - */ |
|
| 713 | + /** |
|
| 714 | + * Makes sure that the value is a JSON-encoded string. |
|
| 715 | + * @param string $value |
|
| 716 | + */ |
|
| 717 | 717 | protected function validate_json($value) |
| 718 | 718 | { |
| 719 | 719 | if(!is_string($value)) { |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | if($this->validationParams['arrays'] === false) |
| 731 | 731 | { |
| 732 | 732 | if(is_object(json_decode($value))) { |
| 733 | - return $value; |
|
| 733 | + return $value; |
|
| 734 | 734 | } |
| 735 | 735 | } |
| 736 | 736 | else |
@@ -811,12 +811,12 @@ discard block |
||
| 811 | 811 | return $this; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - /** |
|
| 815 | - * Adds a filter that trims whitespace from the request |
|
| 816 | - * parameter using the PHP <code>trim</code> function. |
|
| 817 | - * |
|
| 818 | - * @return \AppUtils\Request_Param |
|
| 819 | - */ |
|
| 814 | + /** |
|
| 815 | + * Adds a filter that trims whitespace from the request |
|
| 816 | + * parameter using the PHP <code>trim</code> function. |
|
| 817 | + * |
|
| 818 | + * @return \AppUtils\Request_Param |
|
| 819 | + */ |
|
| 820 | 820 | public function addFilterTrim() : Request_Param |
| 821 | 821 | { |
| 822 | 822 | // to guarantee we only work with strings |
@@ -825,13 +825,13 @@ discard block |
||
| 825 | 825 | return $this->addCallbackFilter('trim'); |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | - /** |
|
| 829 | - * Converts the value to a string, even if it is not |
|
| 830 | - * a string value. Complex types like arrays and objects |
|
| 831 | - * are converted to an empty string. |
|
| 832 | - * |
|
| 833 | - * @return \AppUtils\Request_Param |
|
| 834 | - */ |
|
| 828 | + /** |
|
| 829 | + * Converts the value to a string, even if it is not |
|
| 830 | + * a string value. Complex types like arrays and objects |
|
| 831 | + * are converted to an empty string. |
|
| 832 | + * |
|
| 833 | + * @return \AppUtils\Request_Param |
|
| 834 | + */ |
|
| 835 | 835 | public function addStringFilter() : Request_Param |
| 836 | 836 | { |
| 837 | 837 | return $this->addCallbackFilter(array($this, 'applyFilter_string')); |
@@ -881,12 +881,12 @@ discard block |
||
| 881 | 881 | return $this->addCallbackFilter('strip_tags', array($allowedTags)); |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | - /** |
|
| 885 | - * Adds a filter that strips all whitespace from the |
|
| 886 | - * request parameter, from spaces to tabs and newlines. |
|
| 887 | - * |
|
| 888 | - * @return \AppUtils\Request_Param |
|
| 889 | - */ |
|
| 884 | + /** |
|
| 885 | + * Adds a filter that strips all whitespace from the |
|
| 886 | + * request parameter, from spaces to tabs and newlines. |
|
| 887 | + * |
|
| 888 | + * @return \AppUtils\Request_Param |
|
| 889 | + */ |
|
| 890 | 890 | public function addStripWhitespaceFilter() : Request_Param |
| 891 | 891 | { |
| 892 | 892 | // to ensure we only work with strings. |
@@ -895,14 +895,14 @@ discard block |
||
| 895 | 895 | return $this->addCallbackFilter(array($this, 'applyFilter_stripWhitespace')); |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - /** |
|
| 899 | - * Adds a filter that transforms comma separated values |
|
| 900 | - * into an array of values. |
|
| 901 | - * |
|
| 902 | - * @param bool $trimEntries Trim whitespace from each entry? |
|
| 903 | - * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
| 904 | - * @return \AppUtils\Request_Param |
|
| 905 | - */ |
|
| 898 | + /** |
|
| 899 | + * Adds a filter that transforms comma separated values |
|
| 900 | + * into an array of values. |
|
| 901 | + * |
|
| 902 | + * @param bool $trimEntries Trim whitespace from each entry? |
|
| 903 | + * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
| 904 | + * @return \AppUtils\Request_Param |
|
| 905 | + */ |
|
| 906 | 906 | public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
| 907 | 907 | { |
| 908 | 908 | $this->setArray(); |
@@ -916,12 +916,12 @@ discard block |
||
| 916 | 916 | ); |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - /** |
|
| 920 | - * Adds a filter that encodes all HTML special characters |
|
| 921 | - * using the PHP <code>htmlspecialchars</code> function. |
|
| 922 | - * |
|
| 923 | - * @return \AppUtils\Request_Param |
|
| 924 | - */ |
|
| 919 | + /** |
|
| 920 | + * Adds a filter that encodes all HTML special characters |
|
| 921 | + * using the PHP <code>htmlspecialchars</code> function. |
|
| 922 | + * |
|
| 923 | + * @return \AppUtils\Request_Param |
|
| 924 | + */ |
|
| 925 | 925 | public function addHTMLSpecialcharsFilter() : Request_Param |
| 926 | 926 | { |
| 927 | 927 | return $this->addCallbackFilter('htmlspecialchars', array(ENT_QUOTES, 'UTF-8')); |
@@ -934,14 +934,14 @@ discard block |
||
| 934 | 934 | |
| 935 | 935 | protected $required = false; |
| 936 | 936 | |
| 937 | - /** |
|
| 938 | - * Marks this request parameter as required. To use this feature, |
|
| 939 | - * you have to call the request's {@link Request::validate()} |
|
| 940 | - * method. |
|
| 941 | - * |
|
| 942 | - * @return Request_Param |
|
| 943 | - * @see Request::validate() |
|
| 944 | - */ |
|
| 937 | + /** |
|
| 938 | + * Marks this request parameter as required. To use this feature, |
|
| 939 | + * you have to call the request's {@link Request::validate()} |
|
| 940 | + * method. |
|
| 941 | + * |
|
| 942 | + * @return Request_Param |
|
| 943 | + * @see Request::validate() |
|
| 944 | + */ |
|
| 945 | 945 | public function makeRequired() : Request_Param |
| 946 | 946 | { |
| 947 | 947 | $this->required = true; |
@@ -50,20 +50,20 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Creates and returns a new instance of the CSV builder which |
|
| 55 | - * can be used to build CSV from scratch. |
|
| 56 | - * |
|
| 57 | - * @return CSVHelper_Builder |
|
| 58 | - */ |
|
| 53 | + /** |
|
| 54 | + * Creates and returns a new instance of the CSV builder which |
|
| 55 | + * can be used to build CSV from scratch. |
|
| 56 | + * |
|
| 57 | + * @return CSVHelper_Builder |
|
| 58 | + */ |
|
| 59 | 59 | public static function createBuilder() |
| 60 | 60 | { |
| 61 | 61 | return new CSVHelper_Builder(); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * @var string |
|
| 66 | - */ |
|
| 64 | + /** |
|
| 65 | + * @var string |
|
| 66 | + */ |
|
| 67 | 67 | protected $csv = ''; |
| 68 | 68 | |
| 69 | 69 | protected $data = array(); |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | protected $headersPosition = self::HEADERS_NONE; |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Loads CSV data from a string. |
|
| 77 | - * |
|
| 78 | - * Note: Use the {@link hasErrors()} method to |
|
| 79 | - * check if the string could be parsed correctly |
|
| 80 | - * afterwards. |
|
| 81 | - * |
|
| 82 | - * @param string $string |
|
| 83 | - * @return CSVHelper |
|
| 84 | - */ |
|
| 75 | + /** |
|
| 76 | + * Loads CSV data from a string. |
|
| 77 | + * |
|
| 78 | + * Note: Use the {@link hasErrors()} method to |
|
| 79 | + * check if the string could be parsed correctly |
|
| 80 | + * afterwards. |
|
| 81 | + * |
|
| 82 | + * @param string $string |
|
| 83 | + * @return CSVHelper |
|
| 84 | + */ |
|
| 85 | 85 | public function loadString($string) |
| 86 | 86 | { |
| 87 | 87 | // remove any UTF byte order marks that may still be present in the string |
@@ -95,20 +95,20 @@ discard block |
||
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Loads CSV data from a file. |
|
| 100 | - * |
|
| 101 | - * Note: Use the {@link hasErrors()} method to |
|
| 102 | - * check if the string could be parsed correctly |
|
| 103 | - * afterwards. |
|
| 104 | - * |
|
| 105 | - * @param string $file |
|
| 106 | - * @throws FileHelper_Exception |
|
| 107 | - * @return CSVHelper |
|
| 108 | - * |
|
| 109 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
| 110 | - * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
| 111 | - */ |
|
| 98 | + /** |
|
| 99 | + * Loads CSV data from a file. |
|
| 100 | + * |
|
| 101 | + * Note: Use the {@link hasErrors()} method to |
|
| 102 | + * check if the string could be parsed correctly |
|
| 103 | + * afterwards. |
|
| 104 | + * |
|
| 105 | + * @param string $file |
|
| 106 | + * @throws FileHelper_Exception |
|
| 107 | + * @return CSVHelper |
|
| 108 | + * |
|
| 109 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
| 110 | + * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
| 111 | + */ |
|
| 112 | 112 | public function loadFile(string $file) : CSVHelper |
| 113 | 113 | { |
| 114 | 114 | $csv = FileHelper::readContents($file); |
@@ -122,28 +122,28 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | protected $rowCount = 0; |
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Specifies that headers are positioned on top, horizontally. |
|
| 127 | - * @return CSVHelper |
|
| 128 | - */ |
|
| 125 | + /** |
|
| 126 | + * Specifies that headers are positioned on top, horizontally. |
|
| 127 | + * @return CSVHelper |
|
| 128 | + */ |
|
| 129 | 129 | public function setHeadersTop() |
| 130 | 130 | { |
| 131 | 131 | return $this->setHeadersPosition(self::HEADERS_TOP); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Specifies that headers are positioned on the left, vertically. |
|
| 136 | - * @return CSVHelper |
|
| 137 | - */ |
|
| 134 | + /** |
|
| 135 | + * Specifies that headers are positioned on the left, vertically. |
|
| 136 | + * @return CSVHelper |
|
| 137 | + */ |
|
| 138 | 138 | public function setHeadersLeft() |
| 139 | 139 | { |
| 140 | 140 | return $this->setHeadersPosition(self::HEADERS_LEFT); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Specifies that there are no headers in the file (default). |
|
| 145 | - * @return CSVHelper |
|
| 146 | - */ |
|
| 143 | + /** |
|
| 144 | + * Specifies that there are no headers in the file (default). |
|
| 145 | + * @return CSVHelper |
|
| 146 | + */ |
|
| 147 | 147 | public function setHeadersNone() |
| 148 | 148 | { |
| 149 | 149 | return $this->setHeadersPosition(self::HEADERS_NONE); |
@@ -173,18 +173,18 @@ discard block |
||
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * Specifies where the headers are positioned in the |
|
| 178 | - * CSV, or turns them off entirely. Use the class constants |
|
| 179 | - * to ensure the value is correct. |
|
| 180 | - * |
|
| 181 | - * @param string $position |
|
| 182 | - * @throws CSVHelper_Exception |
|
| 183 | - * @return CSVHelper |
|
| 184 | - * @see CSVHelper::HEADERS_LEFT |
|
| 185 | - * @see CSVHelper::HEADERS_TOP |
|
| 186 | - * @see CSVHelper::HEADERS_NONE |
|
| 187 | - */ |
|
| 176 | + /** |
|
| 177 | + * Specifies where the headers are positioned in the |
|
| 178 | + * CSV, or turns them off entirely. Use the class constants |
|
| 179 | + * to ensure the value is correct. |
|
| 180 | + * |
|
| 181 | + * @param string $position |
|
| 182 | + * @throws CSVHelper_Exception |
|
| 183 | + * @return CSVHelper |
|
| 184 | + * @see CSVHelper::HEADERS_LEFT |
|
| 185 | + * @see CSVHelper::HEADERS_TOP |
|
| 186 | + * @see CSVHelper::HEADERS_NONE |
|
| 187 | + */ |
|
| 188 | 188 | public function setHeadersPosition($position) |
| 189 | 189 | { |
| 190 | 190 | $validPositions = array( |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | return $this; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Resets all internal data, allowing to start entirely anew |
|
| 216 | - * with a new file, or to start building a new CSV file from |
|
| 217 | - * scratch. |
|
| 218 | - * |
|
| 219 | - * @return CSVHelper |
|
| 220 | - */ |
|
| 214 | + /** |
|
| 215 | + * Resets all internal data, allowing to start entirely anew |
|
| 216 | + * with a new file, or to start building a new CSV file from |
|
| 217 | + * scratch. |
|
| 218 | + * |
|
| 219 | + * @return CSVHelper |
|
| 220 | + */ |
|
| 221 | 221 | public function reset() |
| 222 | 222 | { |
| 223 | 223 | $this->data = array(); |
@@ -234,19 +234,19 @@ discard block |
||
| 234 | 234 | return $this->data; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Retrieves the row at the specified index. |
|
| 239 | - * If there is no data at the index, this will |
|
| 240 | - * return an array populated with empty strings |
|
| 241 | - * for all available columns. |
|
| 242 | - * |
|
| 243 | - * Tip: Use the {@link rowExists()} method to check |
|
| 244 | - * whether the specified row exists. |
|
| 245 | - * |
|
| 246 | - * @param integer $index |
|
| 247 | - * @return array() |
|
| 248 | - * @see rowExists() |
|
| 249 | - */ |
|
| 237 | + /** |
|
| 238 | + * Retrieves the row at the specified index. |
|
| 239 | + * If there is no data at the index, this will |
|
| 240 | + * return an array populated with empty strings |
|
| 241 | + * for all available columns. |
|
| 242 | + * |
|
| 243 | + * Tip: Use the {@link rowExists()} method to check |
|
| 244 | + * whether the specified row exists. |
|
| 245 | + * |
|
| 246 | + * @param integer $index |
|
| 247 | + * @return array() |
|
| 248 | + * @see rowExists() |
|
| 249 | + */ |
|
| 250 | 250 | public function getRow($index) |
| 251 | 251 | { |
| 252 | 252 | if(isset($this->data[$index])) { |
@@ -256,63 +256,63 @@ discard block |
||
| 256 | 256 | return array_fill(0, $this->rowCount, ''); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Checks whether the specified row exists in the data set. |
|
| 261 | - * @param integer $index |
|
| 262 | - * @return boolean |
|
| 263 | - */ |
|
| 259 | + /** |
|
| 260 | + * Checks whether the specified row exists in the data set. |
|
| 261 | + * @param integer $index |
|
| 262 | + * @return boolean |
|
| 263 | + */ |
|
| 264 | 264 | public function rowExists($index) |
| 265 | 265 | { |
| 266 | 266 | return isset($this->data[$index]); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - /** |
|
| 270 | - * Counts the amount of rows in the parsed CSV, |
|
| 271 | - * excluding the headers if any, depending on |
|
| 272 | - * their position. |
|
| 273 | - * |
|
| 274 | - * @return integer |
|
| 275 | - */ |
|
| 269 | + /** |
|
| 270 | + * Counts the amount of rows in the parsed CSV, |
|
| 271 | + * excluding the headers if any, depending on |
|
| 272 | + * their position. |
|
| 273 | + * |
|
| 274 | + * @return integer |
|
| 275 | + */ |
|
| 276 | 276 | public function countRows() |
| 277 | 277 | { |
| 278 | 278 | return $this->rowCount; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - /** |
|
| 282 | - * Counts the amount of rows in the parsed CSV, |
|
| 283 | - * excluding the headers if any, depending on |
|
| 284 | - * their position. |
|
| 285 | - * |
|
| 286 | - * @return integer |
|
| 287 | - */ |
|
| 281 | + /** |
|
| 282 | + * Counts the amount of rows in the parsed CSV, |
|
| 283 | + * excluding the headers if any, depending on |
|
| 284 | + * their position. |
|
| 285 | + * |
|
| 286 | + * @return integer |
|
| 287 | + */ |
|
| 288 | 288 | public function countColumns() |
| 289 | 289 | { |
| 290 | 290 | return $this->columnCount; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - /** |
|
| 294 | - * Retrieves the headers, if any. Specify the position of the |
|
| 295 | - * headers first to ensure this works correctly. |
|
| 296 | - * |
|
| 297 | - * @return array Indexed array with header names. |
|
| 298 | - */ |
|
| 293 | + /** |
|
| 294 | + * Retrieves the headers, if any. Specify the position of the |
|
| 295 | + * headers first to ensure this works correctly. |
|
| 296 | + * |
|
| 297 | + * @return array Indexed array with header names. |
|
| 298 | + */ |
|
| 299 | 299 | public function getHeaders() |
| 300 | 300 | { |
| 301 | 301 | return $this->headers; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - /** |
|
| 305 | - * Retrieves the column at the specified index. If there |
|
| 306 | - * is no column at the index, this returns an array |
|
| 307 | - * populated with empty strings. |
|
| 308 | - * |
|
| 309 | - * Tip: Use the {@link columnExists()} method to check |
|
| 310 | - * whether a column exists. |
|
| 311 | - * |
|
| 312 | - * @param integer $index |
|
| 313 | - * @return string[] |
|
| 314 | - * @see columnExists() |
|
| 315 | - */ |
|
| 304 | + /** |
|
| 305 | + * Retrieves the column at the specified index. If there |
|
| 306 | + * is no column at the index, this returns an array |
|
| 307 | + * populated with empty strings. |
|
| 308 | + * |
|
| 309 | + * Tip: Use the {@link columnExists()} method to check |
|
| 310 | + * whether a column exists. |
|
| 311 | + * |
|
| 312 | + * @param integer $index |
|
| 313 | + * @return string[] |
|
| 314 | + * @see columnExists() |
|
| 315 | + */ |
|
| 316 | 316 | public function getColumn($index) |
| 317 | 317 | { |
| 318 | 318 | $data = array(); |
@@ -328,11 +328,11 @@ discard block |
||
| 328 | 328 | return $data; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * Checks whether the specified column exists in the data set. |
|
| 333 | - * @param integer $index |
|
| 334 | - * @return boolean |
|
| 335 | - */ |
|
| 331 | + /** |
|
| 332 | + * Checks whether the specified column exists in the data set. |
|
| 333 | + * @param integer $index |
|
| 334 | + * @return boolean |
|
| 335 | + */ |
|
| 336 | 336 | public function columnExists($index) |
| 337 | 337 | { |
| 338 | 338 | if($index < $this->columnCount) { |
@@ -396,22 +396,22 @@ discard block |
||
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * Checks whether any errors have been encountered |
|
| 401 | - * while parsing the CSV. |
|
| 402 | - * |
|
| 403 | - * @return boolean |
|
| 404 | - * @see getErrorMessages() |
|
| 405 | - */ |
|
| 399 | + /** |
|
| 400 | + * Checks whether any errors have been encountered |
|
| 401 | + * while parsing the CSV. |
|
| 402 | + * |
|
| 403 | + * @return boolean |
|
| 404 | + * @see getErrorMessages() |
|
| 405 | + */ |
|
| 406 | 406 | public function hasErrors() |
| 407 | 407 | { |
| 408 | 408 | return !empty($this->errors); |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | - /** |
|
| 412 | - * Retrieves all error messages. |
|
| 413 | - * @return array |
|
| 414 | - */ |
|
| 411 | + /** |
|
| 412 | + * Retrieves all error messages. |
|
| 413 | + * @return array |
|
| 414 | + */ |
|
| 415 | 415 | public function getErrorMessages() |
| 416 | 416 | { |
| 417 | 417 | return $this->errors; |
@@ -435,16 +435,16 @@ discard block |
||
| 435 | 435 | return $bytes . ' ' . t('B'); |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - /** |
|
| 439 | - * Cuts a text to the specified length if it is longer than the |
|
| 440 | - * target length. Appends a text to signify it has been cut at |
|
| 441 | - * the end of the string. |
|
| 442 | - * |
|
| 443 | - * @param string $text |
|
| 444 | - * @param int $targetLength |
|
| 445 | - * @param string $append |
|
| 446 | - * @return string |
|
| 447 | - */ |
|
| 438 | + /** |
|
| 439 | + * Cuts a text to the specified length if it is longer than the |
|
| 440 | + * target length. Appends a text to signify it has been cut at |
|
| 441 | + * the end of the string. |
|
| 442 | + * |
|
| 443 | + * @param string $text |
|
| 444 | + * @param int $targetLength |
|
| 445 | + * @param string $append |
|
| 446 | + * @return string |
|
| 447 | + */ |
|
| 448 | 448 | public static function text_cut(string $text, int $targetLength, string $append = '...') : string |
| 449 | 449 | { |
| 450 | 450 | $length = mb_strlen($text); |
@@ -514,27 +514,27 @@ discard block |
||
| 514 | 514 | return self::$booleanStrings[$string]; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - /** |
|
| 518 | - * Whether the specified string is a boolean string or boolean value. |
|
| 519 | - * Alias for {@link ConvertHelper::isBoolean()}. |
|
| 520 | - * |
|
| 521 | - * @param mixed $string |
|
| 522 | - * @return bool |
|
| 523 | - * @deprecated |
|
| 524 | - * @see ConvertHelper::isBoolean() |
|
| 525 | - */ |
|
| 517 | + /** |
|
| 518 | + * Whether the specified string is a boolean string or boolean value. |
|
| 519 | + * Alias for {@link ConvertHelper::isBoolean()}. |
|
| 520 | + * |
|
| 521 | + * @param mixed $string |
|
| 522 | + * @return bool |
|
| 523 | + * @deprecated |
|
| 524 | + * @see ConvertHelper::isBoolean() |
|
| 525 | + */ |
|
| 526 | 526 | public static function isBooleanString($string) : bool |
| 527 | 527 | { |
| 528 | 528 | return self::isBoolean($string); |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - /** |
|
| 532 | - * Alias for the {@\AppUtils\XMLHelper::string2xml()} method. |
|
| 533 | - * |
|
| 534 | - * @param string $text |
|
| 535 | - * @return string |
|
| 536 | - * @deprecated |
|
| 537 | - */ |
|
| 531 | + /** |
|
| 532 | + * Alias for the {@\AppUtils\XMLHelper::string2xml()} method. |
|
| 533 | + * |
|
| 534 | + * @param string $text |
|
| 535 | + * @return string |
|
| 536 | + * @deprecated |
|
| 537 | + */ |
|
| 538 | 538 | public static function text_makeXMLCompliant($text) |
| 539 | 539 | { |
| 540 | 540 | return XMLHelper::string2xml($text); |
@@ -636,13 +636,13 @@ discard block |
||
| 636 | 636 | return $translit->convert($string); |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - /** |
|
| 640 | - * Retrieves the HEX character codes for all control |
|
| 641 | - * characters that the {@link stripControlCharacters()} |
|
| 642 | - * method will remove. |
|
| 643 | - * |
|
| 644 | - * @return string[] |
|
| 645 | - */ |
|
| 639 | + /** |
|
| 640 | + * Retrieves the HEX character codes for all control |
|
| 641 | + * characters that the {@link stripControlCharacters()} |
|
| 642 | + * method will remove. |
|
| 643 | + * |
|
| 644 | + * @return string[] |
|
| 645 | + */ |
|
| 646 | 646 | public static function getControlCharactersAsHex() |
| 647 | 647 | { |
| 648 | 648 | $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
@@ -678,13 +678,13 @@ discard block |
||
| 678 | 678 | return $stack; |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - /** |
|
| 682 | - * Retrieves an array of all control characters that |
|
| 683 | - * the {@link stripControlCharacters()} method will |
|
| 684 | - * remove, as the actual UTF-8 characters. |
|
| 685 | - * |
|
| 686 | - * @return string[] |
|
| 687 | - */ |
|
| 681 | + /** |
|
| 682 | + * Retrieves an array of all control characters that |
|
| 683 | + * the {@link stripControlCharacters()} method will |
|
| 684 | + * remove, as the actual UTF-8 characters. |
|
| 685 | + * |
|
| 686 | + * @return string[] |
|
| 687 | + */ |
|
| 688 | 688 | public static function getControlCharactersAsUTF8() |
| 689 | 689 | { |
| 690 | 690 | $chars = self::getControlCharactersAsHex(); |
@@ -697,12 +697,12 @@ discard block |
||
| 697 | 697 | return $result; |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | - /** |
|
| 701 | - * Retrieves all control characters as JSON encoded |
|
| 702 | - * characters, e.g. "\u200b". |
|
| 703 | - * |
|
| 704 | - * @return string[] |
|
| 705 | - */ |
|
| 700 | + /** |
|
| 701 | + * Retrieves all control characters as JSON encoded |
|
| 702 | + * characters, e.g. "\u200b". |
|
| 703 | + * |
|
| 704 | + * @return string[] |
|
| 705 | + */ |
|
| 706 | 706 | public static function getControlCharactersAsJSON() |
| 707 | 707 | { |
| 708 | 708 | $chars = self::getControlCharactersAsHex(); |
@@ -759,20 +759,20 @@ discard block |
||
| 759 | 759 | return preg_replace(self::$controlCharsRegex, '', $string); |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - /** |
|
| 763 | - * Converts a unicode character to the PHPO notation. |
|
| 764 | - * |
|
| 765 | - * Example: |
|
| 766 | - * |
|
| 767 | - * <pre>unicodeChar2php('"\u0000"')</pre> |
|
| 768 | - * |
|
| 769 | - * Returns |
|
| 770 | - * |
|
| 771 | - * <pre>\x0</pre> |
|
| 772 | - * |
|
| 773 | - * @param string $unicodeChar |
|
| 774 | - * @return string |
|
| 775 | - */ |
|
| 762 | + /** |
|
| 763 | + * Converts a unicode character to the PHPO notation. |
|
| 764 | + * |
|
| 765 | + * Example: |
|
| 766 | + * |
|
| 767 | + * <pre>unicodeChar2php('"\u0000"')</pre> |
|
| 768 | + * |
|
| 769 | + * Returns |
|
| 770 | + * |
|
| 771 | + * <pre>\x0</pre> |
|
| 772 | + * |
|
| 773 | + * @param string $unicodeChar |
|
| 774 | + * @return string |
|
| 775 | + */ |
|
| 776 | 776 | public static function unicodeChar2php($unicodeChar) |
| 777 | 777 | { |
| 778 | 778 | $unicodeChar = json_decode($unicodeChar); |
@@ -895,25 +895,25 @@ discard block |
||
| 895 | 895 | return 'false'; |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - /** |
|
| 899 | - * Converts an associative array with attribute name > value pairs |
|
| 900 | - * to an attribute string that can be used in an HTML tag. Empty |
|
| 901 | - * attribute values are ignored. |
|
| 902 | - * |
|
| 903 | - * Example: |
|
| 904 | - * |
|
| 905 | - * array2attributeString(array( |
|
| 906 | - * 'id' => 45, |
|
| 907 | - * 'href' => 'http://www.mistralys.com' |
|
| 908 | - * )); |
|
| 909 | - * |
|
| 910 | - * Result: |
|
| 911 | - * |
|
| 912 | - * id="45" href="http://www.mistralys.com" |
|
| 913 | - * |
|
| 914 | - * @param array $array |
|
| 915 | - * @return string |
|
| 916 | - */ |
|
| 898 | + /** |
|
| 899 | + * Converts an associative array with attribute name > value pairs |
|
| 900 | + * to an attribute string that can be used in an HTML tag. Empty |
|
| 901 | + * attribute values are ignored. |
|
| 902 | + * |
|
| 903 | + * Example: |
|
| 904 | + * |
|
| 905 | + * array2attributeString(array( |
|
| 906 | + * 'id' => 45, |
|
| 907 | + * 'href' => 'http://www.mistralys.com' |
|
| 908 | + * )); |
|
| 909 | + * |
|
| 910 | + * Result: |
|
| 911 | + * |
|
| 912 | + * id="45" href="http://www.mistralys.com" |
|
| 913 | + * |
|
| 914 | + * @param array $array |
|
| 915 | + * @return string |
|
| 916 | + */ |
|
| 917 | 917 | public static function array2attributeString($array) |
| 918 | 918 | { |
| 919 | 919 | $tokens = array(); |
@@ -932,14 +932,14 @@ discard block |
||
| 932 | 932 | return ' '.implode(' ', $tokens); |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - /** |
|
| 936 | - * Converts a string so it can safely be used in a javascript |
|
| 937 | - * statement in an HTML tag: uses single quotes around the string |
|
| 938 | - * and encodes all special characters as needed. |
|
| 939 | - * |
|
| 940 | - * @param string $string |
|
| 941 | - * @return string |
|
| 942 | - */ |
|
| 935 | + /** |
|
| 936 | + * Converts a string so it can safely be used in a javascript |
|
| 937 | + * statement in an HTML tag: uses single quotes around the string |
|
| 938 | + * and encodes all special characters as needed. |
|
| 939 | + * |
|
| 940 | + * @param string $string |
|
| 941 | + * @return string |
|
| 942 | + */ |
|
| 943 | 943 | public static function string2attributeJS($string, $quoted=true) |
| 944 | 944 | { |
| 945 | 945 | $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8')); |
@@ -950,15 +950,15 @@ discard block |
||
| 950 | 950 | return $converted; |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - /** |
|
| 954 | - * Checks if the specified string is a boolean value, which |
|
| 955 | - * includes string representations of boolean values, like |
|
| 956 | - * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
| 957 | - * or <code>false</code>. |
|
| 958 | - * |
|
| 959 | - * @param mixed $value |
|
| 960 | - * @return boolean |
|
| 961 | - */ |
|
| 953 | + /** |
|
| 954 | + * Checks if the specified string is a boolean value, which |
|
| 955 | + * includes string representations of boolean values, like |
|
| 956 | + * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
| 957 | + * or <code>false</code>. |
|
| 958 | + * |
|
| 959 | + * @param mixed $value |
|
| 960 | + * @return boolean |
|
| 961 | + */ |
|
| 962 | 962 | public static function isBoolean($value) : bool |
| 963 | 963 | { |
| 964 | 964 | if(is_bool($value)) { |
@@ -972,12 +972,12 @@ discard block |
||
| 972 | 972 | return array_key_exists($value, self::$booleanStrings); |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | - /** |
|
| 976 | - * Converts an associative array to an HTML style attribute value string. |
|
| 977 | - * |
|
| 978 | - * @param array $subject |
|
| 979 | - * @return string |
|
| 980 | - */ |
|
| 975 | + /** |
|
| 976 | + * Converts an associative array to an HTML style attribute value string. |
|
| 977 | + * |
|
| 978 | + * @param array $subject |
|
| 979 | + * @return string |
|
| 980 | + */ |
|
| 981 | 981 | public static function array2styleString(array $subject) : string |
| 982 | 982 | { |
| 983 | 983 | $tokens = array(); |
@@ -988,23 +988,23 @@ discard block |
||
| 988 | 988 | return implode(';', $tokens); |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - /** |
|
| 992 | - * Converts a DateTime object to a timestamp, which |
|
| 993 | - * is PHP 5.2 compatible. |
|
| 994 | - * |
|
| 995 | - * @param \DateTime $date |
|
| 996 | - * @return integer |
|
| 997 | - */ |
|
| 991 | + /** |
|
| 992 | + * Converts a DateTime object to a timestamp, which |
|
| 993 | + * is PHP 5.2 compatible. |
|
| 994 | + * |
|
| 995 | + * @param \DateTime $date |
|
| 996 | + * @return integer |
|
| 997 | + */ |
|
| 998 | 998 | public static function date2timestamp(\DateTime $date) : int |
| 999 | 999 | { |
| 1000 | 1000 | return (int)$date->format('U'); |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - /** |
|
| 1004 | - * Converts a timestamp into a DateTime instance. |
|
| 1005 | - * @param int $timestamp |
|
| 1006 | - * @return \DateTime |
|
| 1007 | - */ |
|
| 1003 | + /** |
|
| 1004 | + * Converts a timestamp into a DateTime instance. |
|
| 1005 | + * @param int $timestamp |
|
| 1006 | + * @return \DateTime |
|
| 1007 | + */ |
|
| 1008 | 1008 | public static function timestamp2date(int $timestamp) : \DateTime |
| 1009 | 1009 | { |
| 1010 | 1010 | $date = new \DateTime(); |
@@ -1012,13 +1012,13 @@ discard block |
||
| 1012 | 1012 | return $date; |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | - /** |
|
| 1016 | - * Strips an absolute path to a file within the application |
|
| 1017 | - * to make the path relative to the application root path. |
|
| 1018 | - * |
|
| 1019 | - * @param string $path |
|
| 1020 | - * @return string |
|
| 1021 | - */ |
|
| 1015 | + /** |
|
| 1016 | + * Strips an absolute path to a file within the application |
|
| 1017 | + * to make the path relative to the application root path. |
|
| 1018 | + * |
|
| 1019 | + * @param string $path |
|
| 1020 | + * @return string |
|
| 1021 | + */ |
|
| 1022 | 1022 | public static function fileRelativize($path) |
| 1023 | 1023 | { |
| 1024 | 1024 | $path = str_replace('\\', '/', $path); |
@@ -1030,22 +1030,22 @@ discard block |
||
| 1030 | 1030 | |
| 1031 | 1031 | const JS_REGEX_JSON = 'json'; |
| 1032 | 1032 | |
| 1033 | - /** |
|
| 1034 | - * Takes a regular expression and attempts to convert it to |
|
| 1035 | - * its javascript equivalent. Returns an array containing the |
|
| 1036 | - * format string itself (without start and end characters), |
|
| 1037 | - * and the modifiers. |
|
| 1038 | - * |
|
| 1039 | - * This is intended to be used with the RegExp object, for ex: |
|
| 1040 | - * |
|
| 1041 | - * <script> |
|
| 1042 | - * var expression = <?php echo json_encode(ConvertHelper::regex2js('/ab+c/i')) ?>; |
|
| 1043 | - * var reg = new RegExp(expression.format, expression.modifiers); |
|
| 1044 | - * </script> |
|
| 1045 | - * |
|
| 1046 | - * @param string $regex |
|
| 1047 | - * @return array |
|
| 1048 | - */ |
|
| 1033 | + /** |
|
| 1034 | + * Takes a regular expression and attempts to convert it to |
|
| 1035 | + * its javascript equivalent. Returns an array containing the |
|
| 1036 | + * format string itself (without start and end characters), |
|
| 1037 | + * and the modifiers. |
|
| 1038 | + * |
|
| 1039 | + * This is intended to be used with the RegExp object, for ex: |
|
| 1040 | + * |
|
| 1041 | + * <script> |
|
| 1042 | + * var expression = <?php echo json_encode(ConvertHelper::regex2js('/ab+c/i')) ?>; |
|
| 1043 | + * var reg = new RegExp(expression.format, expression.modifiers); |
|
| 1044 | + * </script> |
|
| 1045 | + * |
|
| 1046 | + * @param string $regex |
|
| 1047 | + * @return array |
|
| 1048 | + */ |
|
| 1049 | 1049 | public static function regex2js($regex, $return=self::JS_REGEX_OBJECT) |
| 1050 | 1050 | { |
| 1051 | 1051 | $regex = trim($regex); |
@@ -1091,12 +1091,12 @@ discard block |
||
| 1091 | 1091 | ); |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - /** |
|
| 1095 | - * Strips all known UTF byte order marks from the specified string. |
|
| 1096 | - * |
|
| 1097 | - * @param string $string |
|
| 1098 | - * @return string |
|
| 1099 | - */ |
|
| 1094 | + /** |
|
| 1095 | + * Strips all known UTF byte order marks from the specified string. |
|
| 1096 | + * |
|
| 1097 | + * @param string $string |
|
| 1098 | + * @return string |
|
| 1099 | + */ |
|
| 1100 | 1100 | public static function stripUTFBom($string) |
| 1101 | 1101 | { |
| 1102 | 1102 | $boms = FileHelper::getUTFBOMs(); |
@@ -1111,13 +1111,13 @@ discard block |
||
| 1111 | 1111 | return $string; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | - /** |
|
| 1115 | - * Converts a string to valid utf8, regardless |
|
| 1116 | - * of the string's encoding(s). |
|
| 1117 | - * |
|
| 1118 | - * @param string $string |
|
| 1119 | - * @return string |
|
| 1120 | - */ |
|
| 1114 | + /** |
|
| 1115 | + * Converts a string to valid utf8, regardless |
|
| 1116 | + * of the string's encoding(s). |
|
| 1117 | + * |
|
| 1118 | + * @param string $string |
|
| 1119 | + * @return string |
|
| 1120 | + */ |
|
| 1121 | 1121 | public static function string2utf8($string) |
| 1122 | 1122 | { |
| 1123 | 1123 | if(!self::isStringASCII($string)) { |
@@ -1127,15 +1127,15 @@ discard block |
||
| 1127 | 1127 | return $string; |
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | - /** |
|
| 1131 | - * Checks whether the specified string is an ASCII |
|
| 1132 | - * string, without any special or UTF8 characters. |
|
| 1133 | - * Note: empty strings and NULL are considered ASCII. |
|
| 1134 | - * Any variable types other than strings are not. |
|
| 1135 | - * |
|
| 1136 | - * @param string $string |
|
| 1137 | - * @return boolean |
|
| 1138 | - */ |
|
| 1130 | + /** |
|
| 1131 | + * Checks whether the specified string is an ASCII |
|
| 1132 | + * string, without any special or UTF8 characters. |
|
| 1133 | + * Note: empty strings and NULL are considered ASCII. |
|
| 1134 | + * Any variable types other than strings are not. |
|
| 1135 | + * |
|
| 1136 | + * @param string $string |
|
| 1137 | + * @return boolean |
|
| 1138 | + */ |
|
| 1139 | 1139 | public static function isStringASCII($string) |
| 1140 | 1140 | { |
| 1141 | 1141 | if($string === '' || $string === NULL) { |
@@ -1160,22 +1160,22 @@ discard block |
||
| 1160 | 1160 | return $url; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | - /** |
|
| 1164 | - * Calculates a percentage match of the source string with the target string. |
|
| 1165 | - * |
|
| 1166 | - * Options are: |
|
| 1167 | - * |
|
| 1168 | - * - maxLevenshtein, default: 10 |
|
| 1169 | - * Any levenshtein results above this value are ignored. |
|
| 1170 | - * |
|
| 1171 | - * - precision, default: 1 |
|
| 1172 | - * The precision of the percentage float value |
|
| 1173 | - * |
|
| 1174 | - * @param string $source |
|
| 1175 | - * @param string $target |
|
| 1176 | - * @param array $options |
|
| 1177 | - * @return float |
|
| 1178 | - */ |
|
| 1163 | + /** |
|
| 1164 | + * Calculates a percentage match of the source string with the target string. |
|
| 1165 | + * |
|
| 1166 | + * Options are: |
|
| 1167 | + * |
|
| 1168 | + * - maxLevenshtein, default: 10 |
|
| 1169 | + * Any levenshtein results above this value are ignored. |
|
| 1170 | + * |
|
| 1171 | + * - precision, default: 1 |
|
| 1172 | + * The precision of the percentage float value |
|
| 1173 | + * |
|
| 1174 | + * @param string $source |
|
| 1175 | + * @param string $target |
|
| 1176 | + * @param array $options |
|
| 1177 | + * @return float |
|
| 1178 | + */ |
|
| 1179 | 1179 | public static function matchString($source, $target, $options=array()) |
| 1180 | 1180 | { |
| 1181 | 1181 | $defaults = array( |
@@ -1259,14 +1259,14 @@ discard block |
||
| 1259 | 1259 | |
| 1260 | 1260 | const INTERVAL_SECONDS = 'seconds'; |
| 1261 | 1261 | |
| 1262 | - /** |
|
| 1263 | - * Calculates the total amount of days / hours / minutes or seconds |
|
| 1264 | - * of a date interval object and returns the value. |
|
| 1265 | - * |
|
| 1266 | - * @param \DateInterval $interval |
|
| 1267 | - * @param string $unit |
|
| 1268 | - * @return integer |
|
| 1269 | - */ |
|
| 1262 | + /** |
|
| 1263 | + * Calculates the total amount of days / hours / minutes or seconds |
|
| 1264 | + * of a date interval object and returns the value. |
|
| 1265 | + * |
|
| 1266 | + * @param \DateInterval $interval |
|
| 1267 | + * @param string $unit |
|
| 1268 | + * @return integer |
|
| 1269 | + */ |
|
| 1270 | 1270 | public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) |
| 1271 | 1271 | { |
| 1272 | 1272 | $total = $interval->format('%a'); |
@@ -1304,13 +1304,13 @@ discard block |
||
| 1304 | 1304 | 'Sunday' |
| 1305 | 1305 | ); |
| 1306 | 1306 | |
| 1307 | - /** |
|
| 1308 | - * Converts a date to the corresponding day name. |
|
| 1309 | - * |
|
| 1310 | - * @param \DateTime $date |
|
| 1311 | - * @param string $short |
|
| 1312 | - * @return string|NULL |
|
| 1313 | - */ |
|
| 1307 | + /** |
|
| 1308 | + * Converts a date to the corresponding day name. |
|
| 1309 | + * |
|
| 1310 | + * @param \DateTime $date |
|
| 1311 | + * @param string $short |
|
| 1312 | + * @return string|NULL |
|
| 1313 | + */ |
|
| 1314 | 1314 | public static function date2dayName(\DateTime $date, $short=false) |
| 1315 | 1315 | { |
| 1316 | 1316 | $day = $date->format('l'); |
@@ -1325,21 +1325,21 @@ discard block |
||
| 1325 | 1325 | return null; |
| 1326 | 1326 | } |
| 1327 | 1327 | |
| 1328 | - /** |
|
| 1329 | - * Retrieves a list of english day names. |
|
| 1330 | - * @return string[] |
|
| 1331 | - */ |
|
| 1328 | + /** |
|
| 1329 | + * Retrieves a list of english day names. |
|
| 1330 | + * @return string[] |
|
| 1331 | + */ |
|
| 1332 | 1332 | public static function getDayNamesInvariant() |
| 1333 | 1333 | { |
| 1334 | 1334 | return self::$daysInvariant; |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | - /** |
|
| 1338 | - * Retrieves the day names list for the current locale. |
|
| 1339 | - * |
|
| 1340 | - * @param string $short |
|
| 1341 | - * @return string[] |
|
| 1342 | - */ |
|
| 1337 | + /** |
|
| 1338 | + * Retrieves the day names list for the current locale. |
|
| 1339 | + * |
|
| 1340 | + * @param string $short |
|
| 1341 | + * @return string[] |
|
| 1342 | + */ |
|
| 1343 | 1343 | public static function getDayNames($short=false) |
| 1344 | 1344 | { |
| 1345 | 1345 | if($short) { |
@@ -1399,16 +1399,16 @@ discard block |
||
| 1399 | 1399 | return $last; |
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | - /** |
|
| 1403 | - * Splits a string into an array of all characters it is composed of. |
|
| 1404 | - * Unicode character safe. |
|
| 1405 | - * |
|
| 1406 | - * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
| 1407 | - * characters. |
|
| 1408 | - * |
|
| 1409 | - * @param string $string |
|
| 1410 | - * @return array |
|
| 1411 | - */ |
|
| 1402 | + /** |
|
| 1403 | + * Splits a string into an array of all characters it is composed of. |
|
| 1404 | + * Unicode character safe. |
|
| 1405 | + * |
|
| 1406 | + * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
| 1407 | + * characters. |
|
| 1408 | + * |
|
| 1409 | + * @param string $string |
|
| 1410 | + * @return array |
|
| 1411 | + */ |
|
| 1412 | 1412 | public static function string2array(string $string) : array |
| 1413 | 1413 | { |
| 1414 | 1414 | $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); |
@@ -1419,12 +1419,12 @@ discard block |
||
| 1419 | 1419 | return array(); |
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | - /** |
|
| 1423 | - * Checks whether the specified string contains HTML code. |
|
| 1424 | - * |
|
| 1425 | - * @param string $string |
|
| 1426 | - * @return boolean |
|
| 1427 | - */ |
|
| 1422 | + /** |
|
| 1423 | + * Checks whether the specified string contains HTML code. |
|
| 1424 | + * |
|
| 1425 | + * @param string $string |
|
| 1426 | + * @return boolean |
|
| 1427 | + */ |
|
| 1428 | 1428 | public static function isStringHTML(string $string) : bool |
| 1429 | 1429 | { |
| 1430 | 1430 | if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
@@ -1439,18 +1439,18 @@ discard block |
||
| 1439 | 1439 | return false; |
| 1440 | 1440 | } |
| 1441 | 1441 | |
| 1442 | - /** |
|
| 1443 | - * UTF8-safe wordwrap method: works like the regular wordwrap |
|
| 1444 | - * PHP function but compatible with UTF8. Otherwise the lengths |
|
| 1445 | - * are no calculated correctly. |
|
| 1446 | - * |
|
| 1447 | - * @param string $str |
|
| 1448 | - * @param int $width |
|
| 1449 | - * @param string $break |
|
| 1450 | - * @param bool $cut |
|
| 1451 | - * @return string |
|
| 1452 | - * @see https://stackoverflow.com/a/4988494/2298192 |
|
| 1453 | - */ |
|
| 1442 | + /** |
|
| 1443 | + * UTF8-safe wordwrap method: works like the regular wordwrap |
|
| 1444 | + * PHP function but compatible with UTF8. Otherwise the lengths |
|
| 1445 | + * are no calculated correctly. |
|
| 1446 | + * |
|
| 1447 | + * @param string $str |
|
| 1448 | + * @param int $width |
|
| 1449 | + * @param string $break |
|
| 1450 | + * @param bool $cut |
|
| 1451 | + * @return string |
|
| 1452 | + * @see https://stackoverflow.com/a/4988494/2298192 |
|
| 1453 | + */ |
|
| 1454 | 1454 | public static function wordwrap($str, $width = 75, $break = "\n", $cut = false) |
| 1455 | 1455 | { |
| 1456 | 1456 | $lines = explode($break, $str); |
@@ -1496,27 +1496,27 @@ discard block |
||
| 1496 | 1496 | return implode($break, $lines); |
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | - /** |
|
| 1500 | - * Calculates the byte length of a string, taking into |
|
| 1501 | - * account any unicode characters. |
|
| 1502 | - * |
|
| 1503 | - * @param string $string |
|
| 1504 | - * @return int |
|
| 1505 | - * @see https://stackoverflow.com/a/9718273/2298192 |
|
| 1506 | - */ |
|
| 1499 | + /** |
|
| 1500 | + * Calculates the byte length of a string, taking into |
|
| 1501 | + * account any unicode characters. |
|
| 1502 | + * |
|
| 1503 | + * @param string $string |
|
| 1504 | + * @return int |
|
| 1505 | + * @see https://stackoverflow.com/a/9718273/2298192 |
|
| 1506 | + */ |
|
| 1507 | 1507 | public static function string2bytes($string) |
| 1508 | 1508 | { |
| 1509 | 1509 | return mb_strlen($string, '8bit'); |
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | - /** |
|
| 1513 | - * Creates a short, 8-character long hash for the specified string. |
|
| 1514 | - * |
|
| 1515 | - * WARNING: Not cryptographically safe. |
|
| 1516 | - * |
|
| 1517 | - * @param string $string |
|
| 1518 | - * @return string |
|
| 1519 | - */ |
|
| 1512 | + /** |
|
| 1513 | + * Creates a short, 8-character long hash for the specified string. |
|
| 1514 | + * |
|
| 1515 | + * WARNING: Not cryptographically safe. |
|
| 1516 | + * |
|
| 1517 | + * @param string $string |
|
| 1518 | + * @return string |
|
| 1519 | + */ |
|
| 1520 | 1520 | public static function string2shortHash($string) |
| 1521 | 1521 | { |
| 1522 | 1522 | return hash('crc32', $string, false); |
@@ -1542,23 +1542,23 @@ discard block |
||
| 1542 | 1542 | return ConvertHelper_ThrowableInfo::fromThrowable($e); |
| 1543 | 1543 | } |
| 1544 | 1544 | |
| 1545 | - /** |
|
| 1546 | - * Parses the specified query string like the native |
|
| 1547 | - * function <code>parse_str</code>, without the key |
|
| 1548 | - * naming limitations. |
|
| 1549 | - * |
|
| 1550 | - * Using parse_str, dots or spaces in key names are |
|
| 1551 | - * replaced by underscores. This method keeps all names |
|
| 1552 | - * intact. |
|
| 1553 | - * |
|
| 1554 | - * It still uses the parse_str implementation as it |
|
| 1555 | - * is tested and tried, but fixes the parameter names |
|
| 1556 | - * after parsing, as needed. |
|
| 1557 | - * |
|
| 1558 | - * @param string $queryString |
|
| 1559 | - * @return array |
|
| 1560 | - * @see https://www.php.net/manual/en/function.parse-str.php |
|
| 1561 | - */ |
|
| 1545 | + /** |
|
| 1546 | + * Parses the specified query string like the native |
|
| 1547 | + * function <code>parse_str</code>, without the key |
|
| 1548 | + * naming limitations. |
|
| 1549 | + * |
|
| 1550 | + * Using parse_str, dots or spaces in key names are |
|
| 1551 | + * replaced by underscores. This method keeps all names |
|
| 1552 | + * intact. |
|
| 1553 | + * |
|
| 1554 | + * It still uses the parse_str implementation as it |
|
| 1555 | + * is tested and tried, but fixes the parameter names |
|
| 1556 | + * after parsing, as needed. |
|
| 1557 | + * |
|
| 1558 | + * @param string $queryString |
|
| 1559 | + * @return array |
|
| 1560 | + * @see https://www.php.net/manual/en/function.parse-str.php |
|
| 1561 | + */ |
|
| 1562 | 1562 | public static function parseQueryString(string $queryString) : array |
| 1563 | 1563 | { |
| 1564 | 1564 | // allow HTML entities notation |
@@ -1598,16 +1598,16 @@ discard block |
||
| 1598 | 1598 | $placeholders = array(); |
| 1599 | 1599 | foreach($paramNames as $paramName) |
| 1600 | 1600 | { |
| 1601 | - // create a unique placeholder name |
|
| 1602 | - $placeholder = '__PLACEHOLDER'.$counter.'__'; |
|
| 1601 | + // create a unique placeholder name |
|
| 1602 | + $placeholder = '__PLACEHOLDER'.$counter.'__'; |
|
| 1603 | 1603 | |
| 1604 | - // store the placeholder name to replace later |
|
| 1605 | - $table[$placeholder] = $paramName; |
|
| 1604 | + // store the placeholder name to replace later |
|
| 1605 | + $table[$placeholder] = $paramName; |
|
| 1606 | 1606 | |
| 1607 | - // add the placeholder to replace in the query string before parsing |
|
| 1608 | - $placeholders[$paramName.'='] = $placeholder.'='; |
|
| 1607 | + // add the placeholder to replace in the query string before parsing |
|
| 1608 | + $placeholders[$paramName.'='] = $placeholder.'='; |
|
| 1609 | 1609 | |
| 1610 | - $counter++; |
|
| 1610 | + $counter++; |
|
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | // next challenge: replacing the parameter names by placeholders |
@@ -1634,23 +1634,23 @@ discard block |
||
| 1634 | 1634 | |
| 1635 | 1635 | foreach($parsed as $name => $value) |
| 1636 | 1636 | { |
| 1637 | - $keep[$table[$name]] = $value; |
|
| 1637 | + $keep[$table[$name]] = $value; |
|
| 1638 | 1638 | } |
| 1639 | 1639 | |
| 1640 | 1640 | return $keep; |
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | - /** |
|
| 1644 | - * Searches for needle in the specified string, and returns a list |
|
| 1645 | - * of all occurrences, including the matched string. The matched |
|
| 1646 | - * string is useful when doing a case insensitive search, as it |
|
| 1647 | - * shows the exact matched case of needle. |
|
| 1648 | - * |
|
| 1649 | - * @param string $needle |
|
| 1650 | - * @param string $haystack |
|
| 1651 | - * @param bool $caseInsensitive |
|
| 1652 | - * @return ConvertHelper_StringMatch[] |
|
| 1653 | - */ |
|
| 1643 | + /** |
|
| 1644 | + * Searches for needle in the specified string, and returns a list |
|
| 1645 | + * of all occurrences, including the matched string. The matched |
|
| 1646 | + * string is useful when doing a case insensitive search, as it |
|
| 1647 | + * shows the exact matched case of needle. |
|
| 1648 | + * |
|
| 1649 | + * @param string $needle |
|
| 1650 | + * @param string $haystack |
|
| 1651 | + * @param bool $caseInsensitive |
|
| 1652 | + * @return ConvertHelper_StringMatch[] |
|
| 1653 | + */ |
|
| 1654 | 1654 | public static function findString(string $needle, string $haystack, bool $caseInsensitive=false) |
| 1655 | 1655 | { |
| 1656 | 1656 | if($needle === '') { |
@@ -1676,14 +1676,14 @@ discard block |
||
| 1676 | 1676 | return $positions; |
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | - /** |
|
| 1680 | - * Like explode, but trims all entries, and removes |
|
| 1681 | - * empty entries from the resulting array. |
|
| 1682 | - * |
|
| 1683 | - * @param string $delimiter |
|
| 1684 | - * @param string $string |
|
| 1685 | - * @return string[] |
|
| 1686 | - */ |
|
| 1679 | + /** |
|
| 1680 | + * Like explode, but trims all entries, and removes |
|
| 1681 | + * empty entries from the resulting array. |
|
| 1682 | + * |
|
| 1683 | + * @param string $delimiter |
|
| 1684 | + * @param string $string |
|
| 1685 | + * @return string[] |
|
| 1686 | + */ |
|
| 1687 | 1687 | public static function explodeTrim(string $delimiter, string $string) : array |
| 1688 | 1688 | { |
| 1689 | 1689 | if(empty($string) || empty($delimiter)) { |
@@ -1705,12 +1705,12 @@ discard block |
||
| 1705 | 1705 | |
| 1706 | 1706 | protected static $eolChars; |
| 1707 | 1707 | |
| 1708 | - /** |
|
| 1709 | - * Detects the most used end-of-line character in the subject string. |
|
| 1710 | - * |
|
| 1711 | - * @param string $str The string to check. |
|
| 1712 | - * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
| 1713 | - */ |
|
| 1708 | + /** |
|
| 1709 | + * Detects the most used end-of-line character in the subject string. |
|
| 1710 | + * |
|
| 1711 | + * @param string $str The string to check. |
|
| 1712 | + * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
| 1713 | + */ |
|
| 1714 | 1714 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
| 1715 | 1715 | { |
| 1716 | 1716 | if(empty($subjectString)) { |
@@ -1722,27 +1722,27 @@ discard block |
||
| 1722 | 1722 | $cr = chr((int)hexdec('0d')); |
| 1723 | 1723 | $lf = chr((int)hexdec('0a')); |
| 1724 | 1724 | |
| 1725 | - self::$eolChars = array( |
|
| 1726 | - array( |
|
| 1727 | - 'char' => $cr.$lf, |
|
| 1728 | - 'type' => ConvertHelper_EOL::TYPE_CRLF, |
|
| 1729 | - 'description' => t('Carriage return followed by a line feed'), |
|
| 1730 | - ), |
|
| 1731 | - array( |
|
| 1732 | - 'char' => $lf.$cr, |
|
| 1733 | - 'type' => ConvertHelper_EOL::TYPE_LFCR, |
|
| 1734 | - 'description' => t('Line feed followed by a carriage return'), |
|
| 1735 | - ), |
|
| 1736 | - array( |
|
| 1737 | - 'char' => $lf, |
|
| 1738 | - 'type' => ConvertHelper_EOL::TYPE_LF, |
|
| 1739 | - 'description' => t('Line feed'), |
|
| 1740 | - ), |
|
| 1741 | - array( |
|
| 1742 | - 'char' => $cr, |
|
| 1743 | - 'type' => ConvertHelper_EOL::TYPE_CR, |
|
| 1744 | - 'description' => t('Carriage Return'), |
|
| 1745 | - ), |
|
| 1725 | + self::$eolChars = array( |
|
| 1726 | + array( |
|
| 1727 | + 'char' => $cr.$lf, |
|
| 1728 | + 'type' => ConvertHelper_EOL::TYPE_CRLF, |
|
| 1729 | + 'description' => t('Carriage return followed by a line feed'), |
|
| 1730 | + ), |
|
| 1731 | + array( |
|
| 1732 | + 'char' => $lf.$cr, |
|
| 1733 | + 'type' => ConvertHelper_EOL::TYPE_LFCR, |
|
| 1734 | + 'description' => t('Line feed followed by a carriage return'), |
|
| 1735 | + ), |
|
| 1736 | + array( |
|
| 1737 | + 'char' => $lf, |
|
| 1738 | + 'type' => ConvertHelper_EOL::TYPE_LF, |
|
| 1739 | + 'description' => t('Line feed'), |
|
| 1740 | + ), |
|
| 1741 | + array( |
|
| 1742 | + 'char' => $cr, |
|
| 1743 | + 'type' => ConvertHelper_EOL::TYPE_CR, |
|
| 1744 | + 'description' => t('Carriage Return'), |
|
| 1745 | + ), |
|
| 1746 | 1746 | ); |
| 1747 | 1747 | } |
| 1748 | 1748 | |
@@ -1770,13 +1770,13 @@ discard block |
||
| 1770 | 1770 | ); |
| 1771 | 1771 | } |
| 1772 | 1772 | |
| 1773 | - /** |
|
| 1774 | - * Removes the specified keys from the target array, |
|
| 1775 | - * if they exist. |
|
| 1776 | - * |
|
| 1777 | - * @param array $array |
|
| 1778 | - * @param array $keys |
|
| 1779 | - */ |
|
| 1773 | + /** |
|
| 1774 | + * Removes the specified keys from the target array, |
|
| 1775 | + * if they exist. |
|
| 1776 | + * |
|
| 1777 | + * @param array $array |
|
| 1778 | + * @param array $keys |
|
| 1779 | + */ |
|
| 1780 | 1780 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
| 1781 | 1781 | { |
| 1782 | 1782 | foreach($keys as $key) |
@@ -1787,11 +1787,11 @@ discard block |
||
| 1787 | 1787 | } |
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | - /** |
|
| 1791 | - * Checks if the specified variable is an integer or a string containing an integer. |
|
| 1792 | - * @param mixed $value |
|
| 1793 | - * @return bool |
|
| 1794 | - */ |
|
| 1790 | + /** |
|
| 1791 | + * Checks if the specified variable is an integer or a string containing an integer. |
|
| 1792 | + * @param mixed $value |
|
| 1793 | + * @return bool |
|
| 1794 | + */ |
|
| 1795 | 1795 | public static function isInteger($value) : bool |
| 1796 | 1796 | { |
| 1797 | 1797 | if(is_int($value)) { |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | return $this->buildURL($params, $dispatcher); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Retrieves the name of the current dispatcher script / page. |
|
| 113 | - * This is made to be extended and implemented in a subclass. |
|
| 114 | - * |
|
| 115 | - * @return string |
|
| 116 | - */ |
|
| 111 | + /** |
|
| 112 | + * Retrieves the name of the current dispatcher script / page. |
|
| 113 | + * This is made to be extended and implemented in a subclass. |
|
| 114 | + * |
|
| 115 | + * @return string |
|
| 116 | + */ |
|
| 117 | 117 | public function getDispatcher() : string |
| 118 | 118 | { |
| 119 | 119 | return ''; |
@@ -200,13 +200,13 @@ discard block |
||
| 200 | 200 | return $this->knownParams[$name]; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - /** |
|
| 204 | - * Retrieves a previously registered parameter instance. |
|
| 205 | - * |
|
| 206 | - * @param string $name |
|
| 207 | - * @throws Request_Exception |
|
| 208 | - * @return Request_Param |
|
| 209 | - */ |
|
| 203 | + /** |
|
| 204 | + * Retrieves a previously registered parameter instance. |
|
| 205 | + * |
|
| 206 | + * @param string $name |
|
| 207 | + * @throws Request_Exception |
|
| 208 | + * @return Request_Param |
|
| 209 | + */ |
|
| 210 | 210 | public function getRegisteredParam(string $name) : Request_Param |
| 211 | 211 | { |
| 212 | 212 | if(isset($this->knownParams[$name])) { |
@@ -223,13 +223,13 @@ discard block |
||
| 223 | 223 | ); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Checks whether a parameter with the specified name |
|
| 228 | - * has been registered. |
|
| 229 | - * |
|
| 230 | - * @param string $name |
|
| 231 | - * @return bool |
|
| 232 | - */ |
|
| 226 | + /** |
|
| 227 | + * Checks whether a parameter with the specified name |
|
| 228 | + * has been registered. |
|
| 229 | + * |
|
| 230 | + * @param string $name |
|
| 231 | + * @return bool |
|
| 232 | + */ |
|
| 233 | 233 | public function hasRegisteredParam(string $name) : bool |
| 234 | 234 | { |
| 235 | 235 | return isset($this->knownParams[$name]); |
@@ -358,14 +358,14 @@ discard block |
||
| 358 | 358 | return false; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * Removes a single parameter from the request. |
|
| 363 | - * If the parameter has been registered, also |
|
| 364 | - * removes the registration info. |
|
| 365 | - * |
|
| 366 | - * @param string $name |
|
| 367 | - * @return Request |
|
| 368 | - */ |
|
| 361 | + /** |
|
| 362 | + * Removes a single parameter from the request. |
|
| 363 | + * If the parameter has been registered, also |
|
| 364 | + * removes the registration info. |
|
| 365 | + * |
|
| 366 | + * @param string $name |
|
| 367 | + * @return Request |
|
| 368 | + */ |
|
| 369 | 369 | public function removeParam(string $name) : Request |
| 370 | 370 | { |
| 371 | 371 | if(isset($_REQUEST[$name])) { |
@@ -379,12 +379,12 @@ discard block |
||
| 379 | 379 | return $this; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - /** |
|
| 383 | - * Removes several parameters from the request. |
|
| 384 | - * |
|
| 385 | - * @param string[] $names |
|
| 386 | - * @return Request |
|
| 387 | - */ |
|
| 382 | + /** |
|
| 383 | + * Removes several parameters from the request. |
|
| 384 | + * |
|
| 385 | + * @param string[] $names |
|
| 386 | + * @return Request |
|
| 387 | + */ |
|
| 388 | 388 | public function removeParams(array $names) : Request |
| 389 | 389 | { |
| 390 | 390 | foreach($names as $name) { |
@@ -449,18 +449,18 @@ discard block |
||
| 449 | 449 | return $val; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - /** |
|
| 453 | - * Treats the request parameter as a JSON string, and |
|
| 454 | - * if it exists and contains valid JSON, returns the |
|
| 455 | - * decoded JSON value as an array (default). |
|
| 456 | - * |
|
| 457 | - * @param string $name |
|
| 458 | - * @param bool $assoc |
|
| 459 | - * @return array|object |
|
| 460 | - * |
|
| 461 | - * @see Request::getJSONAssoc() |
|
| 462 | - * @see Request::getJSONObject() |
|
| 463 | - */ |
|
| 452 | + /** |
|
| 453 | + * Treats the request parameter as a JSON string, and |
|
| 454 | + * if it exists and contains valid JSON, returns the |
|
| 455 | + * decoded JSON value as an array (default). |
|
| 456 | + * |
|
| 457 | + * @param string $name |
|
| 458 | + * @param bool $assoc |
|
| 459 | + * @return array|object |
|
| 460 | + * |
|
| 461 | + * @see Request::getJSONAssoc() |
|
| 462 | + * @see Request::getJSONObject() |
|
| 463 | + */ |
|
| 464 | 464 | public function getJSON(string $name, bool $assoc=true) |
| 465 | 465 | { |
| 466 | 466 | $value = $this->getParam($name); |
@@ -485,13 +485,13 @@ discard block |
||
| 485 | 485 | return new \stdClass(); |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - /** |
|
| 489 | - * Like {@link Request::getJSON()}, but omitting the second |
|
| 490 | - * parameter. Use this for more readable code. |
|
| 491 | - * |
|
| 492 | - * @param string $name |
|
| 493 | - * @return array |
|
| 494 | - */ |
|
| 488 | + /** |
|
| 489 | + * Like {@link Request::getJSON()}, but omitting the second |
|
| 490 | + * parameter. Use this for more readable code. |
|
| 491 | + * |
|
| 492 | + * @param string $name |
|
| 493 | + * @return array |
|
| 494 | + */ |
|
| 495 | 495 | public function getJSONAssoc(string $name) : array |
| 496 | 496 | { |
| 497 | 497 | $result = $this->getJSON($name); |
@@ -502,13 +502,13 @@ discard block |
||
| 502 | 502 | return array(); |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | - /** |
|
| 506 | - * Like {@link Request::getJSON()}, but omitting the second |
|
| 507 | - * parameter. Use this for more readable code. |
|
| 508 | - * |
|
| 509 | - * @param string $name |
|
| 510 | - * @return object |
|
| 511 | - */ |
|
| 505 | + /** |
|
| 506 | + * Like {@link Request::getJSON()}, but omitting the second |
|
| 507 | + * parameter. Use this for more readable code. |
|
| 508 | + * |
|
| 509 | + * @param string $name |
|
| 510 | + * @return object |
|
| 511 | + */ |
|
| 512 | 512 | public function getJSONObject(string $name) : object |
| 513 | 513 | { |
| 514 | 514 | $result = $this->getJSON($name, false); |
@@ -519,12 +519,12 @@ discard block |
||
| 519 | 519 | return new \stdClass(); |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - /** |
|
| 523 | - * Sends a JSON response with the correct headers. |
|
| 524 | - * |
|
| 525 | - * @param array|string $data |
|
| 526 | - * @param bool $exit Whether to exit the script afterwards. |
|
| 527 | - */ |
|
| 522 | + /** |
|
| 523 | + * Sends a JSON response with the correct headers. |
|
| 524 | + * |
|
| 525 | + * @param array|string $data |
|
| 526 | + * @param bool $exit Whether to exit the script afterwards. |
|
| 527 | + */ |
|
| 528 | 528 | public static function sendJSON($data, bool $exit=true) |
| 529 | 529 | { |
| 530 | 530 | $payload = $data; |
@@ -544,12 +544,12 @@ discard block |
||
| 544 | 544 | } |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - /** |
|
| 548 | - * Sends HTML to the browser with the correct headers. |
|
| 549 | - * |
|
| 550 | - * @param string $html |
|
| 551 | - * @param bool $exit Whether to exit the script afterwards. |
|
| 552 | - */ |
|
| 547 | + /** |
|
| 548 | + * Sends HTML to the browser with the correct headers. |
|
| 549 | + * |
|
| 550 | + * @param string $html |
|
| 551 | + * @param bool $exit Whether to exit the script afterwards. |
|
| 552 | + */ |
|
| 553 | 553 | public static function sendHTML(string $html, bool $exit=true) |
| 554 | 554 | { |
| 555 | 555 | header('Cache-Control: no-cache, must-revalidate'); |
@@ -564,16 +564,16 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - /** |
|
| 568 | - * Creates a new instance of the URL comparer, which can check |
|
| 569 | - * whether the specified URLs match, regardless of the order in |
|
| 570 | - * which the query parameters are, if any. |
|
| 571 | - * |
|
| 572 | - * @param string $sourceURL |
|
| 573 | - * @param string $targetURL |
|
| 574 | - * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
| 575 | - * @return Request_URLComparer |
|
| 576 | - */ |
|
| 567 | + /** |
|
| 568 | + * Creates a new instance of the URL comparer, which can check |
|
| 569 | + * whether the specified URLs match, regardless of the order in |
|
| 570 | + * which the query parameters are, if any. |
|
| 571 | + * |
|
| 572 | + * @param string $sourceURL |
|
| 573 | + * @param string $targetURL |
|
| 574 | + * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
| 575 | + * @return Request_URLComparer |
|
| 576 | + */ |
|
| 577 | 577 | public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
| 578 | 578 | { |
| 579 | 579 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
@@ -582,10 +582,10 @@ discard block |
||
| 582 | 582 | return $comparer; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - /** |
|
| 586 | - * Retrieves the full URL that was used to access the current page. |
|
| 587 | - * @return string |
|
| 588 | - */ |
|
| 585 | + /** |
|
| 586 | + * Retrieves the full URL that was used to access the current page. |
|
| 587 | + * @return string |
|
| 588 | + */ |
|
| 589 | 589 | public function getCurrentURL() : string |
| 590 | 590 | { |
| 591 | 591 | return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
@@ -14,49 +14,49 @@ discard block |
||
| 14 | 14 | const CONTEXT_COMMAND_LINE = 'cli'; |
| 15 | 15 | const CONTEXT_WEB = 'web'; |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * @var \Throwable |
|
| 19 | - */ |
|
| 17 | + /** |
|
| 18 | + * @var \Throwable |
|
| 19 | + */ |
|
| 20 | 20 | protected $exception; |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var ConvertHelper_ThrowableInfo_Call[] |
|
| 24 | - */ |
|
| 22 | + /** |
|
| 23 | + * @var ConvertHelper_ThrowableInfo_Call[] |
|
| 24 | + */ |
|
| 25 | 25 | protected $calls = array(); |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var integer |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var integer |
|
| 29 | + */ |
|
| 30 | 30 | protected $code; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | 35 | protected $message; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var integer |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var integer |
|
| 39 | + */ |
|
| 40 | 40 | protected $callsCount = 0; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var ConvertHelper_ThrowableInfo |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var ConvertHelper_ThrowableInfo |
|
| 44 | + */ |
|
| 45 | 45 | protected $previous; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var string |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var string |
|
| 49 | + */ |
|
| 50 | 50 | protected $referer = ''; |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @var \DateTime |
|
| 54 | - */ |
|
| 52 | + /** |
|
| 53 | + * @var \DateTime |
|
| 54 | + */ |
|
| 55 | 55 | protected $date; |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @var string |
|
| 59 | - */ |
|
| 57 | + /** |
|
| 58 | + * @var string |
|
| 59 | + */ |
|
| 60 | 60 | protected $context = self::CONTEXT_WEB; |
| 61 | 61 | |
| 62 | 62 | protected function __construct($subject) |
@@ -103,16 +103,16 @@ discard block |
||
| 103 | 103 | return isset($this->previous); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Retrieves the information on the previous exception. |
|
| 108 | - * |
|
| 109 | - * NOTE: Throws an exception if there is no previous |
|
| 110 | - * exception. Use hasPrevious() first to avoid this. |
|
| 111 | - * |
|
| 112 | - * @throws ConvertHelper_Exception |
|
| 113 | - * @return ConvertHelper_ThrowableInfo |
|
| 114 | - * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION |
|
| 115 | - */ |
|
| 106 | + /** |
|
| 107 | + * Retrieves the information on the previous exception. |
|
| 108 | + * |
|
| 109 | + * NOTE: Throws an exception if there is no previous |
|
| 110 | + * exception. Use hasPrevious() first to avoid this. |
|
| 111 | + * |
|
| 112 | + * @throws ConvertHelper_Exception |
|
| 113 | + * @return ConvertHelper_ThrowableInfo |
|
| 114 | + * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION |
|
| 115 | + */ |
|
| 116 | 116 | public function getPrevious() : ConvertHelper_ThrowableInfo |
| 117 | 117 | { |
| 118 | 118 | if(isset($this->previous)) { |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | return !empty($this->code); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Improved textonly exception trace. |
|
| 136 | - */ |
|
| 134 | + /** |
|
| 135 | + * Improved textonly exception trace. |
|
| 136 | + */ |
|
| 137 | 137 | public function toString() : string |
| 138 | 138 | { |
| 139 | 139 | $calls = $this->getCalls(); |
@@ -161,73 +161,73 @@ discard block |
||
| 161 | 161 | return $string; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * Retrieves the URL of the page in which the exception |
|
| 166 | - * was thrown, if applicable: in CLI context, this will |
|
| 167 | - * return an empty string. |
|
| 168 | - * |
|
| 169 | - * @return string |
|
| 170 | - */ |
|
| 164 | + /** |
|
| 165 | + * Retrieves the URL of the page in which the exception |
|
| 166 | + * was thrown, if applicable: in CLI context, this will |
|
| 167 | + * return an empty string. |
|
| 168 | + * |
|
| 169 | + * @return string |
|
| 170 | + */ |
|
| 171 | 171 | public function getReferer() : string |
| 172 | 172 | { |
| 173 | 173 | return $this->referer; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - /** |
|
| 177 | - * Whether the exception occurred in a command line context. |
|
| 178 | - * @return bool |
|
| 179 | - */ |
|
| 176 | + /** |
|
| 177 | + * Whether the exception occurred in a command line context. |
|
| 178 | + * @return bool |
|
| 179 | + */ |
|
| 180 | 180 | public function isCommandLine() : bool |
| 181 | 181 | { |
| 182 | 182 | return $this->getContext() === self::CONTEXT_COMMAND_LINE; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Whether the exception occurred during an http request. |
|
| 187 | - * @return bool |
|
| 188 | - */ |
|
| 185 | + /** |
|
| 186 | + * Whether the exception occurred during an http request. |
|
| 187 | + * @return bool |
|
| 188 | + */ |
|
| 189 | 189 | public function isWebRequest() : bool |
| 190 | 190 | { |
| 191 | 191 | return $this->getContext() === self::CONTEXT_WEB; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Retrieves the context identifier, i.e. if the exception |
|
| 196 | - * occurred in a command line context or regular web request. |
|
| 197 | - * |
|
| 198 | - * @return string |
|
| 199 | - * |
|
| 200 | - * @see ConvertHelper_ThrowableInfo::isCommandLine() |
|
| 201 | - * @see ConvertHelper_ThrowableInfo::isWebRequest() |
|
| 202 | - * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE |
|
| 203 | - * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB |
|
| 204 | - */ |
|
| 194 | + /** |
|
| 195 | + * Retrieves the context identifier, i.e. if the exception |
|
| 196 | + * occurred in a command line context or regular web request. |
|
| 197 | + * |
|
| 198 | + * @return string |
|
| 199 | + * |
|
| 200 | + * @see ConvertHelper_ThrowableInfo::isCommandLine() |
|
| 201 | + * @see ConvertHelper_ThrowableInfo::isWebRequest() |
|
| 202 | + * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE |
|
| 203 | + * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB |
|
| 204 | + */ |
|
| 205 | 205 | public function getContext() : string |
| 206 | 206 | { |
| 207 | 207 | return $this->context; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Retrieves the date of the exception, and approximate time: |
|
| 212 | - * since exceptions do not store time, this is captured the |
|
| 213 | - * moment the ThrowableInfo is created. |
|
| 214 | - * |
|
| 215 | - * @return \DateTime |
|
| 216 | - */ |
|
| 210 | + /** |
|
| 211 | + * Retrieves the date of the exception, and approximate time: |
|
| 212 | + * since exceptions do not store time, this is captured the |
|
| 213 | + * moment the ThrowableInfo is created. |
|
| 214 | + * |
|
| 215 | + * @return \DateTime |
|
| 216 | + */ |
|
| 217 | 217 | public function getDate() : \DateTime |
| 218 | 218 | { |
| 219 | 219 | return $this->date; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Serializes all information on the exception to an |
|
| 224 | - * associative array. This can be saved (file, database, |
|
| 225 | - * session...), and later be restored into a throwable |
|
| 226 | - * info instance using the fromSerialized() method. |
|
| 227 | - * |
|
| 228 | - * @return array |
|
| 229 | - * @see ConvertHelper_ThrowableInfo::fromSerialized() |
|
| 230 | - */ |
|
| 222 | + /** |
|
| 223 | + * Serializes all information on the exception to an |
|
| 224 | + * associative array. This can be saved (file, database, |
|
| 225 | + * session...), and later be restored into a throwable |
|
| 226 | + * info instance using the fromSerialized() method. |
|
| 227 | + * |
|
| 228 | + * @return array |
|
| 229 | + * @see ConvertHelper_ThrowableInfo::fromSerialized() |
|
| 230 | + */ |
|
| 231 | 231 | public function serialize() : array |
| 232 | 232 | { |
| 233 | 233 | $result = array( |
@@ -254,24 +254,24 @@ discard block |
||
| 254 | 254 | return $result; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - /** |
|
| 258 | - * Sets the maximum folder depth to show in the |
|
| 259 | - * file paths, to avoid them being too long. |
|
| 260 | - * |
|
| 261 | - * @param int $depth |
|
| 262 | - * @return ConvertHelper_ThrowableInfo |
|
| 263 | - */ |
|
| 257 | + /** |
|
| 258 | + * Sets the maximum folder depth to show in the |
|
| 259 | + * file paths, to avoid them being too long. |
|
| 260 | + * |
|
| 261 | + * @param int $depth |
|
| 262 | + * @return ConvertHelper_ThrowableInfo |
|
| 263 | + */ |
|
| 264 | 264 | public function setFolderDepth(int $depth) : ConvertHelper_ThrowableInfo |
| 265 | 265 | { |
| 266 | 266 | return $this->setOption('folder-depth', $depth); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - /** |
|
| 270 | - * Retrieves the current folder depth option value. |
|
| 271 | - * |
|
| 272 | - * @return int |
|
| 273 | - * @see ConvertHelper_ThrowableInfo::setFolderDepth() |
|
| 274 | - */ |
|
| 269 | + /** |
|
| 270 | + * Retrieves the current folder depth option value. |
|
| 271 | + * |
|
| 272 | + * @return int |
|
| 273 | + * @see ConvertHelper_ThrowableInfo::setFolderDepth() |
|
| 274 | + */ |
|
| 275 | 275 | public function getFolderDepth() : int |
| 276 | 276 | { |
| 277 | 277 | $depth = $this->getOption('folder-depth'); |
@@ -282,19 +282,19 @@ discard block |
||
| 282 | 282 | return 2; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - /** |
|
| 286 | - * Retrieves all function calls that led to the error. |
|
| 287 | - * @return ConvertHelper_ThrowableInfo_Call[] |
|
| 288 | - */ |
|
| 285 | + /** |
|
| 286 | + * Retrieves all function calls that led to the error. |
|
| 287 | + * @return ConvertHelper_ThrowableInfo_Call[] |
|
| 288 | + */ |
|
| 289 | 289 | public function getCalls() |
| 290 | 290 | { |
| 291 | 291 | return $this->calls; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - /** |
|
| 295 | - * Returns the amount of function and method calls in the stack trace. |
|
| 296 | - * @return int |
|
| 297 | - */ |
|
| 294 | + /** |
|
| 295 | + * Returns the amount of function and method calls in the stack trace. |
|
| 296 | + * @return int |
|
| 297 | + */ |
|
| 298 | 298 | public function countCalls() : int |
| 299 | 299 | { |
| 300 | 300 | return $this->callsCount; |
@@ -29,19 +29,19 @@ discard block |
||
| 29 | 29 | const TYPE_LF = 'LF'; |
| 30 | 30 | const TYPE_CR = 'CR'; |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | 35 | protected $char; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | 40 | protected $type; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | 45 | protected $description; |
| 46 | 46 | |
| 47 | 47 | public function __construct(string $char, string $type, string $description) |
@@ -51,33 +51,33 @@ discard block |
||
| 51 | 51 | $this->description = $description; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * The actual EOL character. |
|
| 56 | - * @return string |
|
| 57 | - */ |
|
| 54 | + /** |
|
| 55 | + * The actual EOL character. |
|
| 56 | + * @return string |
|
| 57 | + */ |
|
| 58 | 58 | public function getCharacter() : string |
| 59 | 59 | { |
| 60 | 60 | return $this->char; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * A more detailed, human readable description of the character. |
|
| 65 | - * @return string |
|
| 66 | - */ |
|
| 63 | + /** |
|
| 64 | + * A more detailed, human readable description of the character. |
|
| 65 | + * @return string |
|
| 66 | + */ |
|
| 67 | 67 | public function getDescription() : string |
| 68 | 68 | { |
| 69 | 69 | return $this->description; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * The EOL character type, e.g. "CR+LF", "CR"... |
|
| 74 | - * @return string |
|
| 75 | - * |
|
| 76 | - * @see ConvertHelper_EOL::TYPE_CR |
|
| 77 | - * @see ConvertHelper_EOL::TYPE_CRLF |
|
| 78 | - * @see ConvertHelper_EOL::TYPE_LF |
|
| 79 | - * @see ConvertHelper_EOL::TYPE_LFCR |
|
| 80 | - */ |
|
| 72 | + /** |
|
| 73 | + * The EOL character type, e.g. "CR+LF", "CR"... |
|
| 74 | + * @return string |
|
| 75 | + * |
|
| 76 | + * @see ConvertHelper_EOL::TYPE_CR |
|
| 77 | + * @see ConvertHelper_EOL::TYPE_CRLF |
|
| 78 | + * @see ConvertHelper_EOL::TYPE_LF |
|
| 79 | + * @see ConvertHelper_EOL::TYPE_LFCR |
|
| 80 | + */ |
|
| 81 | 81 | public function getType() : string |
| 82 | 82 | { |
| 83 | 83 | return $this->type; |
@@ -32,25 +32,25 @@ discard block |
||
| 32 | 32 | self::TYPE_CALLABLE => 'cf5e20' |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | 38 | protected $string; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var mixed |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var mixed |
|
| 42 | + */ |
|
| 43 | 43 | protected $value; |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var string |
|
| 47 | + */ |
|
| 48 | 48 | protected $type; |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param mixed $value |
|
| 52 | - * @param array|null $serialized |
|
| 53 | - */ |
|
| 50 | + /** |
|
| 51 | + * @param mixed $value |
|
| 52 | + * @param array|null $serialized |
|
| 53 | + */ |
|
| 54 | 54 | public function __construct($value, $serialized=null) |
| 55 | 55 | { |
| 56 | 56 | if(is_array($serialized)) |
@@ -63,26 +63,26 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Creates a new variable info instance from a PHP variable |
|
| 68 | - * of any type. |
|
| 69 | - * |
|
| 70 | - * @param mixed $variable |
|
| 71 | - * @return VariableInfo |
|
| 72 | - */ |
|
| 66 | + /** |
|
| 67 | + * Creates a new variable info instance from a PHP variable |
|
| 68 | + * of any type. |
|
| 69 | + * |
|
| 70 | + * @param mixed $variable |
|
| 71 | + * @return VariableInfo |
|
| 72 | + */ |
|
| 73 | 73 | public static function fromVariable($variable) : VariableInfo |
| 74 | 74 | { |
| 75 | 75 | return new VariableInfo($variable); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Restores a variable info instance using a previously serialized |
|
| 80 | - * array using the serialize() method. |
|
| 81 | - * |
|
| 82 | - * @param array $serialized |
|
| 83 | - * @return VariableInfo |
|
| 84 | - * @see VariableInfo::serialize() |
|
| 85 | - */ |
|
| 78 | + /** |
|
| 79 | + * Restores a variable info instance using a previously serialized |
|
| 80 | + * array using the serialize() method. |
|
| 81 | + * |
|
| 82 | + * @param array $serialized |
|
| 83 | + * @return VariableInfo |
|
| 84 | + * @see VariableInfo::serialize() |
|
| 85 | + */ |
|
| 86 | 86 | public static function fromSerialized(array $serialized) : VariableInfo |
| 87 | 87 | { |
| 88 | 88 | return new VariableInfo(null, $serialized); |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | $this->string = $this->_toString(); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * The variable type - this is the same string that |
|
| 113 | - * is returned by the PHP function `gettype`. |
|
| 114 | - * |
|
| 115 | - * @return string |
|
| 116 | - */ |
|
| 111 | + /** |
|
| 112 | + * The variable type - this is the same string that |
|
| 113 | + * is returned by the PHP function `gettype`. |
|
| 114 | + * |
|
| 115 | + * @return string |
|
| 116 | + */ |
|
| 117 | 117 | public function getType() : string |
| 118 | 118 | { |
| 119 | 119 | return $this->type; |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | ); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Whether to prepend the variable type before the value, |
|
| 132 | - * like the var_dump function. Example: <code>string "Some text"</code>. |
|
| 133 | - * |
|
| 134 | - * @param bool $enable |
|
| 135 | - * @return VariableInfo |
|
| 136 | - */ |
|
| 130 | + /** |
|
| 131 | + * Whether to prepend the variable type before the value, |
|
| 132 | + * like the var_dump function. Example: <code>string "Some text"</code>. |
|
| 133 | + * |
|
| 134 | + * @param bool $enable |
|
| 135 | + * @return VariableInfo |
|
| 136 | + */ |
|
| 137 | 137 | public function enableType(bool $enable=true) : VariableInfo |
| 138 | 138 | { |
| 139 | 139 | return $this->setOption('prepend-type', $enable); |
@@ -31,9 +31,9 @@ |
||
| 31 | 31 | |
| 32 | 32 | const PATH_MODE_STRIP = 'strip'; |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var string |
|
| 36 | - */ |
|
| 34 | + /** |
|
| 35 | + * @var string |
|
| 36 | + */ |
|
| 37 | 37 | protected $path; |
| 38 | 38 | |
| 39 | 39 | public function __construct(string $path) |
@@ -20,17 +20,17 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class BaseException extends \Exception |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | 26 | protected $details; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param string $message |
|
| 30 | - * @param string $details |
|
| 31 | - * @param int $code |
|
| 32 | - * @param \Exception $previous |
|
| 33 | - */ |
|
| 28 | + /** |
|
| 29 | + * @param string $message |
|
| 30 | + * @param string $details |
|
| 31 | + * @param int $code |
|
| 32 | + * @param \Exception $previous |
|
| 33 | + */ |
|
| 34 | 34 | public function __construct(string $message, $details=null, $code=null, $previous=null) |
| 35 | 35 | { |
| 36 | 36 | parent::__construct($message, $code, $previous); |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | $this->details = $details; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Retrieves the detailed error description, if any. |
|
| 43 | - * @return string |
|
| 44 | - */ |
|
| 41 | + /** |
|
| 42 | + * Retrieves the detailed error description, if any. |
|
| 43 | + * @return string |
|
| 44 | + */ |
|
| 45 | 45 | public function getDetails() : string |
| 46 | 46 | { |
| 47 | 47 | if($this->details !== null) { |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | return ''; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Displays pertinent information on the exception in |
|
| 56 | - * the browser, and exits the script. |
|
| 57 | - */ |
|
| 54 | + /** |
|
| 55 | + * Displays pertinent information on the exception in |
|
| 56 | + * the browser, and exits the script. |
|
| 57 | + */ |
|
| 58 | 58 | public function display() |
| 59 | 59 | { |
| 60 | 60 | if(!headers_sent()) { |
@@ -65,20 +65,20 @@ discard block |
||
| 65 | 65 | exit; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Retrieves information on the exception that can be |
|
| 70 | - * easily accessed. |
|
| 71 | - * |
|
| 72 | - * @return ConvertHelper_ThrowableInfo |
|
| 73 | - */ |
|
| 68 | + /** |
|
| 69 | + * Retrieves information on the exception that can be |
|
| 70 | + * easily accessed. |
|
| 71 | + * |
|
| 72 | + * @return ConvertHelper_ThrowableInfo |
|
| 73 | + */ |
|
| 74 | 74 | public function getInfo() : ConvertHelper_ThrowableInfo |
| 75 | 75 | { |
| 76 | 76 | return ConvertHelper::throwable2info($this); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Dumps a current PHP function trace, as a textonly string. |
|
| 81 | - */ |
|
| 79 | + /** |
|
| 80 | + * Dumps a current PHP function trace, as a textonly string. |
|
| 81 | + */ |
|
| 82 | 82 | public static function dumpTraceAsString() |
| 83 | 83 | { |
| 84 | 84 | try |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * Dumps a current PHP function trace, with HTML styling. |
|
| 96 | - */ |
|
| 94 | + /** |
|
| 95 | + * Dumps a current PHP function trace, with HTML styling. |
|
| 96 | + */ |
|
| 97 | 97 | public static function dumpTraceAsHTML() |
| 98 | 98 | { |
| 99 | 99 | try |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * Creates an exception info instance from a throwable instance. |
|
| 113 | - * |
|
| 114 | - * @param \Throwable $e |
|
| 115 | - * @return ConvertHelper_ThrowableInfo |
|
| 116 | - * @see ConvertHelper::throwable2info() |
|
| 117 | - */ |
|
| 111 | + /** |
|
| 112 | + * Creates an exception info instance from a throwable instance. |
|
| 113 | + * |
|
| 114 | + * @param \Throwable $e |
|
| 115 | + * @return ConvertHelper_ThrowableInfo |
|
| 116 | + * @see ConvertHelper::throwable2info() |
|
| 117 | + */ |
|
| 118 | 118 | public static function createInfo(\Throwable $e) : ConvertHelper_ThrowableInfo |
| 119 | 119 | { |
| 120 | 120 | return ConvertHelper::throwable2info($e); |