@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | use Traits_Optionable; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var URLInfo |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var URLInfo |
|
| 27 | + */ |
|
| 28 | 28 | private $url; |
| 29 | 29 | |
| 30 | 30 | public function __construct(URLInfo $url) |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | ); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Whether to verify the host's SSL certificate, in |
|
| 46 | - * case of an https connection. |
|
| 47 | - * |
|
| 48 | - * @param bool $verifySSL |
|
| 49 | - * @return URLInfo_ConnectionTester |
|
| 50 | - */ |
|
| 44 | + /** |
|
| 45 | + * Whether to verify the host's SSL certificate, in |
|
| 46 | + * case of an https connection. |
|
| 47 | + * |
|
| 48 | + * @param bool $verifySSL |
|
| 49 | + * @return URLInfo_ConnectionTester |
|
| 50 | + */ |
|
| 51 | 51 | public function setVerifySSL(bool $verifySSL=true) : URLInfo_ConnectionTester |
| 52 | 52 | { |
| 53 | 53 | $this->setOption('verify-ssl', $verifySSL); |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | return $this->getIntOption('timeout'); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Initializes the CURL instance. |
|
| 86 | - * |
|
| 87 | - * @throws BaseException |
|
| 88 | - * @return resource |
|
| 89 | - */ |
|
| 84 | + /** |
|
| 85 | + * Initializes the CURL instance. |
|
| 86 | + * |
|
| 87 | + * @throws BaseException |
|
| 88 | + * @return resource |
|
| 89 | + */ |
|
| 90 | 90 | private function initCURL() |
| 91 | 91 | { |
| 92 | 92 | $ch = curl_init(); |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | return $ch; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * @param resource $ch |
|
| 108 | - */ |
|
| 106 | + /** |
|
| 107 | + * @param resource $ch |
|
| 108 | + */ |
|
| 109 | 109 | private function configureOptions($ch) : void |
| 110 | 110 | { |
| 111 | 111 | if($this->isVerboseModeEnabled()) |
@@ -110,38 +110,38 @@ discard block |
||
| 110 | 110 | return $this; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
| 115 | - * |
|
| 116 | - * @param bool $enabled |
|
| 117 | - * @return $this |
|
| 118 | - */ |
|
| 113 | + /** |
|
| 114 | + * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
| 115 | + * |
|
| 116 | + * @param bool $enabled |
|
| 117 | + * @return $this |
|
| 118 | + */ |
|
| 119 | 119 | public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
| 120 | 120 | { |
| 121 | 121 | $this->setOption('sorting', $enabled); |
| 122 | 122 | return $this; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Whether to include email addresses in the search. |
|
| 127 | - * This is only relevant when using the getURLs() |
|
| 128 | - * method. |
|
| 129 | - * |
|
| 130 | - * @param bool $include |
|
| 131 | - * @return ConvertHelper_URLFinder |
|
| 132 | - */ |
|
| 125 | + /** |
|
| 126 | + * Whether to include email addresses in the search. |
|
| 127 | + * This is only relevant when using the getURLs() |
|
| 128 | + * method. |
|
| 129 | + * |
|
| 130 | + * @param bool $include |
|
| 131 | + * @return ConvertHelper_URLFinder |
|
| 132 | + */ |
|
| 133 | 133 | public function includeEmails(bool $include=true) : ConvertHelper_URLFinder |
| 134 | 134 | { |
| 135 | 135 | $this->setOption('include-emails', $include); |
| 136 | 136 | return $this; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Whether to omit the mailto: that is automatically added to all email addresses. |
|
| 141 | - * |
|
| 142 | - * @param bool $omit |
|
| 143 | - * @return ConvertHelper_URLFinder |
|
| 144 | - */ |
|
| 139 | + /** |
|
| 140 | + * Whether to omit the mailto: that is automatically added to all email addresses. |
|
| 141 | + * |
|
| 142 | + * @param bool $omit |
|
| 143 | + * @return ConvertHelper_URLFinder |
|
| 144 | + */ |
|
| 145 | 145 | public function omitMailto(bool $omit=true) : ConvertHelper_URLFinder |
| 146 | 146 | { |
| 147 | 147 | $this->setOption('omit-mailto', $omit); |
@@ -267,11 +267,11 @@ discard block |
||
| 267 | 267 | ); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Fetches all URLs that can be found in the subject string. |
|
| 272 | - * |
|
| 273 | - * @return string[] |
|
| 274 | - */ |
|
| 270 | + /** |
|
| 271 | + * Fetches all URLs that can be found in the subject string. |
|
| 272 | + * |
|
| 273 | + * @return string[] |
|
| 274 | + */ |
|
| 275 | 275 | public function getURLs() : array |
| 276 | 276 | { |
| 277 | 277 | $this->parse(); |
@@ -474,13 +474,13 @@ discard block |
||
| 474 | 474 | return array_pop($parts); |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - /** |
|
| 478 | - * Retrieves all email addresses from the subject string. |
|
| 479 | - * |
|
| 480 | - * @return string[] |
|
| 481 | - * |
|
| 482 | - * @see omitMailto() |
|
| 483 | - */ |
|
| 477 | + /** |
|
| 478 | + * Retrieves all email addresses from the subject string. |
|
| 479 | + * |
|
| 480 | + * @return string[] |
|
| 481 | + * |
|
| 482 | + * @see omitMailto() |
|
| 483 | + */ |
|
| 484 | 484 | public function getEmails() : array |
| 485 | 485 | { |
| 486 | 486 | $this->parse(); |
@@ -506,11 +506,11 @@ discard block |
||
| 506 | 506 | return $result; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - /** |
|
| 510 | - * Retrieves all URLs as URLInfo instances. |
|
| 511 | - * |
|
| 512 | - * @return URLInfo[] |
|
| 513 | - */ |
|
| 509 | + /** |
|
| 510 | + * Retrieves all URLs as URLInfo instances. |
|
| 511 | + * |
|
| 512 | + * @return URLInfo[] |
|
| 513 | + */ |
|
| 514 | 514 | public function getInfos() : array |
| 515 | 515 | { |
| 516 | 516 | $this->parse(); |
@@ -23,24 +23,24 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class URLInfo_Parser |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | 29 | protected $url; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var bool |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var bool |
|
| 33 | + */ |
|
| 34 | 34 | protected $isValid = false; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | 39 | protected $info; |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var array|NULL |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var array|NULL |
|
| 43 | + */ |
|
| 44 | 44 | protected $error; |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -57,25 +57,25 @@ discard block |
||
| 57 | 57 | 'git' |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Stores a list of all unicode characters in the URL |
|
| 62 | - * that have been filtered out before parsing it with |
|
| 63 | - * parse_url. |
|
| 64 | - * |
|
| 65 | - * @var string[]string |
|
| 66 | - */ |
|
| 60 | + /** |
|
| 61 | + * Stores a list of all unicode characters in the URL |
|
| 62 | + * that have been filtered out before parsing it with |
|
| 63 | + * parse_url. |
|
| 64 | + * |
|
| 65 | + * @var string[]string |
|
| 66 | + */ |
|
| 67 | 67 | protected $unicodeChars = array(); |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @var bool |
|
| 71 | - */ |
|
| 69 | + /** |
|
| 70 | + * @var bool |
|
| 71 | + */ |
|
| 72 | 72 | protected $encodeUTF = false; |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * |
|
| 76 | - * @param string $url The target URL. |
|
| 77 | - * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 78 | - */ |
|
| 74 | + /** |
|
| 75 | + * |
|
| 76 | + * @param string $url The target URL. |
|
| 77 | + * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 78 | + */ |
|
| 79 | 79 | public function __construct(string $url, bool $encodeUTF) |
| 80 | 80 | { |
| 81 | 81 | $this->url = $url; |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Retrieves the array as parsed by PHP's parse_url, |
|
| 93 | - * filtered and adjusted as necessary. |
|
| 94 | - * |
|
| 95 | - * @return array |
|
| 96 | - */ |
|
| 91 | + /** |
|
| 92 | + * Retrieves the array as parsed by PHP's parse_url, |
|
| 93 | + * filtered and adjusted as necessary. |
|
| 94 | + * |
|
| 95 | + * @return array |
|
| 96 | + */ |
|
| 97 | 97 | public function getInfo() : array |
| 98 | 98 | { |
| 99 | 99 | return $this->info; |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Finds any non-url encoded unicode characters in |
|
| 120 | - * the URL, and encodes them before the URL is |
|
| 121 | - * passed to parse_url. |
|
| 122 | - */ |
|
| 118 | + /** |
|
| 119 | + * Finds any non-url encoded unicode characters in |
|
| 120 | + * the URL, and encodes them before the URL is |
|
| 121 | + * passed to parse_url. |
|
| 122 | + */ |
|
| 123 | 123 | protected function filterUnicodeChars() : void |
| 124 | 124 | { |
| 125 | 125 | $chars = ConvertHelper::string2array($this->url); |
@@ -238,11 +238,11 @@ discard block |
||
| 238 | 238 | return false; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Goes through all information in the parse_url result |
|
| 243 | - * array, and attempts to fix any user errors in formatting |
|
| 244 | - * that can be recovered from, mostly regarding stray spaces. |
|
| 245 | - */ |
|
| 241 | + /** |
|
| 242 | + * Goes through all information in the parse_url result |
|
| 243 | + * array, and attempts to fix any user errors in formatting |
|
| 244 | + * that can be recovered from, mostly regarding stray spaces. |
|
| 245 | + */ |
|
| 246 | 246 | protected function filterParsed() : void |
| 247 | 247 | { |
| 248 | 248 | $this->info['params'] = array(); |
@@ -284,13 +284,13 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - /** |
|
| 288 | - * Recursively goes through the array, and converts all previously |
|
| 289 | - * URL encoded characters with their unicode character counterparts. |
|
| 290 | - * |
|
| 291 | - * @param array $subject |
|
| 292 | - * @return array |
|
| 293 | - */ |
|
| 287 | + /** |
|
| 288 | + * Recursively goes through the array, and converts all previously |
|
| 289 | + * URL encoded characters with their unicode character counterparts. |
|
| 290 | + * |
|
| 291 | + * @param array $subject |
|
| 292 | + * @return array |
|
| 293 | + */ |
|
| 294 | 294 | protected function restoreUnicodeChars(array $subject) : array |
| 295 | 295 | { |
| 296 | 296 | $result = array(); |
@@ -314,13 +314,13 @@ discard block |
||
| 314 | 314 | return $result; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * Replaces all URL encoded unicode characters |
|
| 319 | - * in the string with the unicode character. |
|
| 320 | - * |
|
| 321 | - * @param string $string |
|
| 322 | - * @return string |
|
| 323 | - */ |
|
| 317 | + /** |
|
| 318 | + * Replaces all URL encoded unicode characters |
|
| 319 | + * in the string with the unicode character. |
|
| 320 | + * |
|
| 321 | + * @param string $string |
|
| 322 | + * @return string |
|
| 323 | + */ |
|
| 324 | 324 | protected function restoreUnicodeChar(string $string) : string |
| 325 | 325 | { |
| 326 | 326 | if(strstr($string, '%')) |
@@ -404,21 +404,21 @@ discard block |
||
| 404 | 404 | ); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | - /** |
|
| 408 | - * Checks whether the URL that was parsed is valid. |
|
| 409 | - * @return bool |
|
| 410 | - */ |
|
| 407 | + /** |
|
| 408 | + * Checks whether the URL that was parsed is valid. |
|
| 409 | + * @return bool |
|
| 410 | + */ |
|
| 411 | 411 | public function isValid() : bool |
| 412 | 412 | { |
| 413 | 413 | return $this->isValid; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - /** |
|
| 417 | - * If the validation failed, retrieves the validation |
|
| 418 | - * error message. |
|
| 419 | - * |
|
| 420 | - * @return string |
|
| 421 | - */ |
|
| 416 | + /** |
|
| 417 | + * If the validation failed, retrieves the validation |
|
| 418 | + * error message. |
|
| 419 | + * |
|
| 420 | + * @return string |
|
| 421 | + */ |
|
| 422 | 422 | public function getErrorMessage() : string |
| 423 | 423 | { |
| 424 | 424 | if(isset($this->error)) { |
@@ -428,12 +428,12 @@ discard block |
||
| 428 | 428 | return ''; |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - /** |
|
| 432 | - * If the validation failed, retrieves the validation |
|
| 433 | - * error code. |
|
| 434 | - * |
|
| 435 | - * @return int |
|
| 436 | - */ |
|
| 431 | + /** |
|
| 432 | + * If the validation failed, retrieves the validation |
|
| 433 | + * error code. |
|
| 434 | + * |
|
| 435 | + * @return int |
|
| 436 | + */ |
|
| 437 | 437 | public function getErrorCode() : int |
| 438 | 438 | { |
| 439 | 439 | if(isset($this->error)) { |
@@ -25,10 +25,10 @@ |
||
| 25 | 25 | * |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - function render() : string; |
|
| 28 | + function render() : string; |
|
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Renders the string and echos it. |
| 32 | 32 | */ |
| 33 | - function display() : void; |
|
| 33 | + function display() : void; |
|
| 34 | 34 | } |
@@ -20,43 +20,43 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class ConvertHelper_TabsNormalizer |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var integer |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var integer |
|
| 25 | + */ |
|
| 26 | 26 | protected $max = 0; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var integer |
|
| 30 | - */ |
|
| 28 | + /** |
|
| 29 | + * @var integer |
|
| 30 | + */ |
|
| 31 | 31 | protected $min = PHP_INT_MAX; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var bool |
|
| 35 | - */ |
|
| 33 | + /** |
|
| 34 | + * @var bool |
|
| 35 | + */ |
|
| 36 | 36 | protected $tabs2spaces = false; |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var string[] |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @var string[] |
|
| 40 | + */ |
|
| 41 | 41 | protected $lines = array(); |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var string |
|
| 45 | - */ |
|
| 43 | + /** |
|
| 44 | + * @var string |
|
| 45 | + */ |
|
| 46 | 46 | protected $eol = ''; |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @var integer |
|
| 50 | - */ |
|
| 48 | + /** |
|
| 49 | + * @var integer |
|
| 50 | + */ |
|
| 51 | 51 | protected $tabSize = 4; |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Whether to enable or disable the conversion |
|
| 55 | - * of tabs to spaces. |
|
| 56 | - * |
|
| 57 | - * @param bool $enable |
|
| 58 | - * @return ConvertHelper_TabsNormalizer |
|
| 59 | - */ |
|
| 53 | + /** |
|
| 54 | + * Whether to enable or disable the conversion |
|
| 55 | + * of tabs to spaces. |
|
| 56 | + * |
|
| 57 | + * @param bool $enable |
|
| 58 | + * @return ConvertHelper_TabsNormalizer |
|
| 59 | + */ |
|
| 60 | 60 | public function convertTabsToSpaces(bool $enable=true) : ConvertHelper_TabsNormalizer |
| 61 | 61 | { |
| 62 | 62 | $this->tabs2spaces = $enable; |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | return $this; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Sets the size of a tab, in spaces. Used to convert tabs |
|
| 69 | - * from spaces and the other way around. Defaults to 4. |
|
| 70 | - * |
|
| 71 | - * @param int $amountSpaces |
|
| 72 | - * @return ConvertHelper_TabsNormalizer |
|
| 73 | - */ |
|
| 67 | + /** |
|
| 68 | + * Sets the size of a tab, in spaces. Used to convert tabs |
|
| 69 | + * from spaces and the other way around. Defaults to 4. |
|
| 70 | + * |
|
| 71 | + * @param int $amountSpaces |
|
| 72 | + * @return ConvertHelper_TabsNormalizer |
|
| 73 | + */ |
|
| 74 | 74 | public function setTabSize(int $amountSpaces) : ConvertHelper_TabsNormalizer |
| 75 | 75 | { |
| 76 | 76 | $this->tabSize = $amountSpaces; |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | return $this; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Normalizes tabs in the specified string by indenting everything |
|
| 83 | - * back to the minimum tab distance. With the second parameter, |
|
| 84 | - * tabs can optionally be converted to spaces as well (recommended |
|
| 85 | - * for HTML output). |
|
| 86 | - * |
|
| 87 | - * @param string $string |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 81 | + /** |
|
| 82 | + * Normalizes tabs in the specified string by indenting everything |
|
| 83 | + * back to the minimum tab distance. With the second parameter, |
|
| 84 | + * tabs can optionally be converted to spaces as well (recommended |
|
| 85 | + * for HTML output). |
|
| 86 | + * |
|
| 87 | + * @param string $string |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | 90 | public function normalize(string $string) : string |
| 91 | 91 | { |
| 92 | 92 | $this->splitLines($string); |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | return implode($this->eol, $converted); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - /** |
|
| 147 | - * Finds out the minimum and maximum amount of |
|
| 148 | - * tabs in the string. |
|
| 149 | - */ |
|
| 146 | + /** |
|
| 147 | + * Finds out the minimum and maximum amount of |
|
| 148 | + * tabs in the string. |
|
| 149 | + */ |
|
| 150 | 150 | protected function countOccurrences() : void |
| 151 | 151 | { |
| 152 | 152 | foreach($this->lines as $line) |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | ) |
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @var string[] |
|
| 76 | - */ |
|
| 74 | + /** |
|
| 75 | + * @var string[] |
|
| 76 | + */ |
|
| 77 | 77 | protected $selected = array(); |
| 78 | 78 | |
| 79 | 79 | public function convert(string $string) : string |
@@ -83,16 +83,16 @@ discard block |
||
| 83 | 83 | return str_replace(array_keys($chars), array_values($chars), $string); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Selects a character set to replace. Can be called |
|
| 88 | - * several times to add additional sets to the collection. |
|
| 89 | - * |
|
| 90 | - * @param string $type See the <code>CHAR_XXX</code> constants. |
|
| 91 | - * @return ConvertHelper_HiddenConverter |
|
| 92 | - * |
|
| 93 | - * @see ConvertHelper_HiddenConverter::CHARS_CONTROL |
|
| 94 | - * @see ConvertHelper_HiddenConverter::CHARS_WHITESPACE |
|
| 95 | - */ |
|
| 86 | + /** |
|
| 87 | + * Selects a character set to replace. Can be called |
|
| 88 | + * several times to add additional sets to the collection. |
|
| 89 | + * |
|
| 90 | + * @param string $type See the <code>CHAR_XXX</code> constants. |
|
| 91 | + * @return ConvertHelper_HiddenConverter |
|
| 92 | + * |
|
| 93 | + * @see ConvertHelper_HiddenConverter::CHARS_CONTROL |
|
| 94 | + * @see ConvertHelper_HiddenConverter::CHARS_WHITESPACE |
|
| 95 | + */ |
|
| 96 | 96 | public function selectCharacters(string $type) : ConvertHelper_HiddenConverter |
| 97 | 97 | { |
| 98 | 98 | if(!in_array($type, $this->selected)) { |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | return $this; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Resolves the list of characters to make visible. |
|
| 107 | - * |
|
| 108 | - * @return string[] |
|
| 109 | - */ |
|
| 105 | + /** |
|
| 106 | + * Resolves the list of characters to make visible. |
|
| 107 | + * |
|
| 108 | + * @return string[] |
|
| 109 | + */ |
|
| 110 | 110 | protected function resolveSelection() : array |
| 111 | 111 | { |
| 112 | 112 | $selected = $this->selected; |
@@ -27,16 +27,16 @@ |
||
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * We parse the query string ourselves, because the PHP implementation |
|
| 32 | - * of parse_str has limitations that do not apply to query strings. This |
|
| 33 | - * is due to the fact that parse_str has to create PHP-compatible variable |
|
| 34 | - * names from the parameters. URL parameters simply allow way more things |
|
| 35 | - * than PHP variable names. |
|
| 36 | - * |
|
| 37 | - * @param string $queryString |
|
| 38 | - * @return array<string,string> |
|
| 39 | - */ |
|
| 30 | + /** |
|
| 31 | + * We parse the query string ourselves, because the PHP implementation |
|
| 32 | + * of parse_str has limitations that do not apply to query strings. This |
|
| 33 | + * is due to the fact that parse_str has to create PHP-compatible variable |
|
| 34 | + * names from the parameters. URL parameters simply allow way more things |
|
| 35 | + * than PHP variable names. |
|
| 36 | + * |
|
| 37 | + * @param string $queryString |
|
| 38 | + * @return array<string,string> |
|
| 39 | + */ |
|
| 40 | 40 | public function parse(string $queryString) : array |
| 41 | 41 | { |
| 42 | 42 | // allow HTML entities notation |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class RequestHelper_Exception extends BaseException |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @var RequestHelper_Response|NULL |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var RequestHelper_Response|NULL |
|
| 27 | + */ |
|
| 28 | 28 | protected $response = null; |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | return $this; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Retrieves the related response instance, if available. |
|
| 42 | - * |
|
| 43 | - * @return RequestHelper_Response|NULL |
|
| 44 | - */ |
|
| 40 | + /** |
|
| 41 | + * Retrieves the related response instance, if available. |
|
| 42 | + * |
|
| 43 | + * @return RequestHelper_Response|NULL |
|
| 44 | + */ |
|
| 45 | 45 | public function getResponse() : ?RequestHelper_Response |
| 46 | 46 | { |
| 47 | 47 | return $this->response; |
@@ -41,71 +41,71 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | class Highlighter |
| 43 | 43 | { |
| 44 | - /** |
|
| 45 | - * Creates a new GeSHi instance from a source code string. |
|
| 46 | - * |
|
| 47 | - * @param string $sourceCode |
|
| 48 | - * @param string $format |
|
| 49 | - * @return GeSHi |
|
| 50 | - */ |
|
| 44 | + /** |
|
| 45 | + * Creates a new GeSHi instance from a source code string. |
|
| 46 | + * |
|
| 47 | + * @param string $sourceCode |
|
| 48 | + * @param string $format |
|
| 49 | + * @return GeSHi |
|
| 50 | + */ |
|
| 51 | 51 | public static function fromString(string $sourceCode, string $format) : GeSHi |
| 52 | 52 | { |
| 53 | 53 | return new GeSHi($sourceCode, $format); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Creates a new GeSHi instance from the contents of a file. |
|
| 58 | - * |
|
| 59 | - * @param string $path |
|
| 60 | - * @param string $format |
|
| 61 | - * @return GeSHi |
|
| 62 | - */ |
|
| 56 | + /** |
|
| 57 | + * Creates a new GeSHi instance from the contents of a file. |
|
| 58 | + * |
|
| 59 | + * @param string $path |
|
| 60 | + * @param string $format |
|
| 61 | + * @return GeSHi |
|
| 62 | + */ |
|
| 63 | 63 | public static function fromFile(string $path, string $format) : GeSHi |
| 64 | 64 | { |
| 65 | 65 | return self::fromString(FileHelper::readContents($path), $format); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Parses and highlights the target string. |
|
| 70 | - * |
|
| 71 | - * @param string $sourceCode |
|
| 72 | - * @param string $format |
|
| 73 | - * @return string |
|
| 74 | - */ |
|
| 68 | + /** |
|
| 69 | + * Parses and highlights the target string. |
|
| 70 | + * |
|
| 71 | + * @param string $sourceCode |
|
| 72 | + * @param string $format |
|
| 73 | + * @return string |
|
| 74 | + */ |
|
| 75 | 75 | public static function parseString(string $sourceCode, string $format) : string |
| 76 | 76 | { |
| 77 | 77 | return self::fromString($sourceCode, $format)->parse_code(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Parses and highlights the contents of the target file. |
|
| 82 | - * |
|
| 83 | - * @param string $path |
|
| 84 | - * @param string $format |
|
| 85 | - * @return string |
|
| 86 | - */ |
|
| 80 | + /** |
|
| 81 | + * Parses and highlights the contents of the target file. |
|
| 82 | + * |
|
| 83 | + * @param string $path |
|
| 84 | + * @param string $format |
|
| 85 | + * @return string |
|
| 86 | + */ |
|
| 87 | 87 | public static function parseFile(string $path, string $format) : string |
| 88 | 88 | { |
| 89 | 89 | return self::fromFile($path, $format)->parse_code(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Adds HTML syntax highlighting to the specified SQL string. |
|
| 94 | - * |
|
| 95 | - * @param string $sql |
|
| 96 | - * @return string |
|
| 97 | - */ |
|
| 92 | + /** |
|
| 93 | + * Adds HTML syntax highlighting to the specified SQL string. |
|
| 94 | + * |
|
| 95 | + * @param string $sql |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 98 | 98 | public static function sql(string $sql) : string |
| 99 | 99 | { |
| 100 | 100 | return self::parseString($sql, 'sql'); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Adds HTML syntax highlighting to a JSON string, or a data array/object. |
|
| 105 | - * |
|
| 106 | - * @param array<int|string,mixed>|object|string $subject A JSON string, or data array/object to convert to JSON to highlight. |
|
| 107 | - * @return string |
|
| 108 | - */ |
|
| 103 | + /** |
|
| 104 | + * Adds HTML syntax highlighting to a JSON string, or a data array/object. |
|
| 105 | + * |
|
| 106 | + * @param array<int|string,mixed>|object|string $subject A JSON string, or data array/object to convert to JSON to highlight. |
|
| 107 | + * @return string |
|
| 108 | + */ |
|
| 109 | 109 | public static function json($subject) : string |
| 110 | 110 | { |
| 111 | 111 | if(!is_string($subject)) |
@@ -118,13 +118,13 @@ discard block |
||
| 118 | 118 | return self::parseString($subject, 'javascript'); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Adds HTML syntax highlighting to the specified XML code. |
|
| 123 | - * |
|
| 124 | - * @param string $xml The XML to highlight. |
|
| 125 | - * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
| 126 | - * @return string |
|
| 127 | - */ |
|
| 121 | + /** |
|
| 122 | + * Adds HTML syntax highlighting to the specified XML code. |
|
| 123 | + * |
|
| 124 | + * @param string $xml The XML to highlight. |
|
| 125 | + * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
| 126 | + * @return string |
|
| 127 | + */ |
|
| 128 | 128 | public static function xml(string $xml, bool $formatSource=false) : string |
| 129 | 129 | { |
| 130 | 130 | if($formatSource) |
@@ -141,13 +141,13 @@ discard block |
||
| 141 | 141 | return self::parseString($xml, 'xml'); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * Adds HTML syntax highlighting to the specified HTML code. |
|
| 146 | - * |
|
| 147 | - * @param string $html |
|
| 148 | - * @param bool $formatSource |
|
| 149 | - * @return string |
|
| 150 | - */ |
|
| 144 | + /** |
|
| 145 | + * Adds HTML syntax highlighting to the specified HTML code. |
|
| 146 | + * |
|
| 147 | + * @param string $html |
|
| 148 | + * @param bool $formatSource |
|
| 149 | + * @return string |
|
| 150 | + */ |
|
| 151 | 151 | public static function html(string $html, bool $formatSource=false) : string |
| 152 | 152 | { |
| 153 | 153 | if($formatSource) |
@@ -164,27 +164,27 @@ discard block |
||
| 164 | 164 | return self::parseString($html, 'xml'); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * Adds HTML syntax highlighting to a bit of PHP code. |
|
| 169 | - * |
|
| 170 | - * @param string $phpCode |
|
| 171 | - * @return string |
|
| 172 | - */ |
|
| 167 | + /** |
|
| 168 | + * Adds HTML syntax highlighting to a bit of PHP code. |
|
| 169 | + * |
|
| 170 | + * @param string $phpCode |
|
| 171 | + * @return string |
|
| 172 | + */ |
|
| 173 | 173 | public static function php(string $phpCode) : string |
| 174 | 174 | { |
| 175 | 175 | return self::parseString($phpCode, 'php'); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * Adds HTML syntax highlighting to an URL. |
|
| 180 | - * |
|
| 181 | - * NOTE: Includes the necessary CSS styles. When |
|
| 182 | - * highlighting several URLs in the same page, |
|
| 183 | - * prefer using the `parseURL` function instead. |
|
| 184 | - * |
|
| 185 | - * @param string $url |
|
| 186 | - * @return string |
|
| 187 | - */ |
|
| 178 | + /** |
|
| 179 | + * Adds HTML syntax highlighting to an URL. |
|
| 180 | + * |
|
| 181 | + * NOTE: Includes the necessary CSS styles. When |
|
| 182 | + * highlighting several URLs in the same page, |
|
| 183 | + * prefer using the `parseURL` function instead. |
|
| 184 | + * |
|
| 185 | + * @param string $url |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 188 | 188 | public static function url(string $url) : string |
| 189 | 189 | { |
| 190 | 190 | $info = parseURL($url); |