@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | $this->init(); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Can be extended in a subclass, to avoid |
|
| 61 | - * redefining the constructor. |
|
| 62 | - * |
|
| 63 | - * @return void |
|
| 64 | - */ |
|
| 59 | + /** |
|
| 60 | + * Can be extended in a subclass, to avoid |
|
| 61 | + * redefining the constructor. |
|
| 62 | + * |
|
| 63 | + * @return void |
|
| 64 | + */ |
|
| 65 | 65 | protected function init() : void |
| 66 | 66 | { |
| 67 | 67 | |
@@ -126,30 +126,30 @@ discard block |
||
| 126 | 126 | return $this->buildURL($params, $dispatcher); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Retrieves the name of the current dispatcher script / page. |
|
| 131 | - * This is made to be extended and implemented in a subclass. |
|
| 132 | - * |
|
| 133 | - * @return string |
|
| 134 | - */ |
|
| 129 | + /** |
|
| 130 | + * Retrieves the name of the current dispatcher script / page. |
|
| 131 | + * This is made to be extended and implemented in a subclass. |
|
| 132 | + * |
|
| 133 | + * @return string |
|
| 134 | + */ |
|
| 135 | 135 | public function getDispatcher() : string |
| 136 | 136 | { |
| 137 | 137 | return ''; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Filters and retrieves the current request variables |
|
| 142 | - * to be used to build a URL to refresh the current page. |
|
| 143 | - * |
|
| 144 | - * For further customization options, use the |
|
| 145 | - * {@see Request::createRefreshParams()} method. |
|
| 146 | - * |
|
| 147 | - * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result. |
|
| 148 | - * @param string[] $exclude Names of parameters to exclude from the result. |
|
| 149 | - * @return array<string,mixed> |
|
| 150 | - * |
|
| 151 | - * @see Request::createRefreshParams() |
|
| 152 | - */ |
|
| 140 | + /** |
|
| 141 | + * Filters and retrieves the current request variables |
|
| 142 | + * to be used to build a URL to refresh the current page. |
|
| 143 | + * |
|
| 144 | + * For further customization options, use the |
|
| 145 | + * {@see Request::createRefreshParams()} method. |
|
| 146 | + * |
|
| 147 | + * @param array<string,mixed> $params Key => value pairs of parameters to always include in the result. |
|
| 148 | + * @param string[] $exclude Names of parameters to exclude from the result. |
|
| 149 | + * @return array<string,mixed> |
|
| 150 | + * |
|
| 151 | + * @see Request::createRefreshParams() |
|
| 152 | + */ |
|
| 153 | 153 | public function getRefreshParams(array $params = array(), array $exclude = array()) : array |
| 154 | 154 | { |
| 155 | 155 | return $this->createRefreshParams() |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | ->getParams(); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Creates an instance of the helper that can be used to |
|
| 163 | - * retrieve the request's parameters collection, with the |
|
| 164 | - * possibility to exclude and override some by rules. |
|
| 165 | - * |
|
| 166 | - * @return Request_RefreshParams |
|
| 167 | - */ |
|
| 161 | + /** |
|
| 162 | + * Creates an instance of the helper that can be used to |
|
| 163 | + * retrieve the request's parameters collection, with the |
|
| 164 | + * possibility to exclude and override some by rules. |
|
| 165 | + * |
|
| 166 | + * @return Request_RefreshParams |
|
| 167 | + */ |
|
| 168 | 168 | public function createRefreshParams() : Request_RefreshParams |
| 169 | 169 | { |
| 170 | 170 | return new Request_RefreshParams(); |
@@ -200,10 +200,10 @@ discard block |
||
| 200 | 200 | return $url; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - /** |
|
| 204 | - * Retrieves the base URL of the application. |
|
| 205 | - * @return string |
|
| 206 | - */ |
|
| 203 | + /** |
|
| 204 | + * Retrieves the base URL of the application. |
|
| 205 | + * @return string |
|
| 206 | + */ |
|
| 207 | 207 | public function getBaseURL() : string |
| 208 | 208 | { |
| 209 | 209 | return $this->baseURL; |
@@ -233,13 +233,13 @@ discard block |
||
| 233 | 233 | return $this->knownParams[$name]; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Retrieves a previously registered parameter instance. |
|
| 238 | - * |
|
| 239 | - * @param string $name |
|
| 240 | - * @return RequestParam |
|
| 241 | - *@throws Request_Exception |
|
| 242 | - */ |
|
| 236 | + /** |
|
| 237 | + * Retrieves a previously registered parameter instance. |
|
| 238 | + * |
|
| 239 | + * @param string $name |
|
| 240 | + * @return RequestParam |
|
| 241 | + *@throws Request_Exception |
|
| 242 | + */ |
|
| 243 | 243 | public function getRegisteredParam(string $name) : RequestParam |
| 244 | 244 | { |
| 245 | 245 | if(isset($this->knownParams[$name])) { |
@@ -256,48 +256,48 @@ discard block |
||
| 256 | 256 | ); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Checks whether a parameter with the specified name |
|
| 261 | - * has been registered. |
|
| 262 | - * |
|
| 263 | - * @param string $name |
|
| 264 | - * @return bool |
|
| 265 | - */ |
|
| 259 | + /** |
|
| 260 | + * Checks whether a parameter with the specified name |
|
| 261 | + * has been registered. |
|
| 262 | + * |
|
| 263 | + * @param string $name |
|
| 264 | + * @return bool |
|
| 265 | + */ |
|
| 266 | 266 | public function hasRegisteredParam(string $name) : bool |
| 267 | 267 | { |
| 268 | 268 | return isset($this->knownParams[$name]); |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - /** |
|
| 272 | - * Retrieves an indexed array with accept mime types |
|
| 273 | - * that the client sent, in the order of preference |
|
| 274 | - * the client specified. |
|
| 275 | - * |
|
| 276 | - * Example: |
|
| 277 | - * |
|
| 278 | - * array( |
|
| 279 | - * 'text/html', |
|
| 280 | - * 'application/xhtml+xml', |
|
| 281 | - * 'image/webp' |
|
| 282 | - * ... |
|
| 283 | - * ) |
|
| 284 | - * |
|
| 285 | - * @return string[] |
|
| 286 | - * @see Request::parseAcceptHeaders() |
|
| 287 | - */ |
|
| 271 | + /** |
|
| 272 | + * Retrieves an indexed array with accept mime types |
|
| 273 | + * that the client sent, in the order of preference |
|
| 274 | + * the client specified. |
|
| 275 | + * |
|
| 276 | + * Example: |
|
| 277 | + * |
|
| 278 | + * array( |
|
| 279 | + * 'text/html', |
|
| 280 | + * 'application/xhtml+xml', |
|
| 281 | + * 'image/webp' |
|
| 282 | + * ... |
|
| 283 | + * ) |
|
| 284 | + * |
|
| 285 | + * @return string[] |
|
| 286 | + * @see Request::parseAcceptHeaders() |
|
| 287 | + */ |
|
| 288 | 288 | public static function getAcceptHeaders() : array |
| 289 | 289 | { |
| 290 | 290 | return self::parseAcceptHeaders()->getMimeStrings(); |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - /** |
|
| 294 | - * Returns an instance of the "accept" headers parser, |
|
| 295 | - * to access information on the browser's accepted |
|
| 296 | - * mime types. |
|
| 297 | - * |
|
| 298 | - * @return Request_AcceptHeaders |
|
| 299 | - * @see Request::getAcceptHeaders() |
|
| 300 | - */ |
|
| 293 | + /** |
|
| 294 | + * Returns an instance of the "accept" headers parser, |
|
| 295 | + * to access information on the browser's accepted |
|
| 296 | + * mime types. |
|
| 297 | + * |
|
| 298 | + * @return Request_AcceptHeaders |
|
| 299 | + * @see Request::getAcceptHeaders() |
|
| 300 | + */ |
|
| 301 | 301 | public static function parseAcceptHeaders() : Request_AcceptHeaders |
| 302 | 302 | { |
| 303 | 303 | static $accept; |
@@ -341,14 +341,14 @@ discard block |
||
| 341 | 341 | return $this->getParam($name) !== null; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - /** |
|
| 345 | - * Removes a single parameter from the request. |
|
| 346 | - * If the parameter has been registered, also |
|
| 347 | - * removes the registration info. |
|
| 348 | - * |
|
| 349 | - * @param string $name |
|
| 350 | - * @return Request |
|
| 351 | - */ |
|
| 344 | + /** |
|
| 345 | + * Removes a single parameter from the request. |
|
| 346 | + * If the parameter has been registered, also |
|
| 347 | + * removes the registration info. |
|
| 348 | + * |
|
| 349 | + * @param string $name |
|
| 350 | + * @return Request |
|
| 351 | + */ |
|
| 352 | 352 | public function removeParam(string $name) : Request |
| 353 | 353 | { |
| 354 | 354 | if(isset($_REQUEST[$name])) { |
@@ -362,12 +362,12 @@ discard block |
||
| 362 | 362 | return $this; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - /** |
|
| 366 | - * Removes several parameters from the request. |
|
| 367 | - * |
|
| 368 | - * @param string[] $names |
|
| 369 | - * @return Request |
|
| 370 | - */ |
|
| 365 | + /** |
|
| 366 | + * Removes several parameters from the request. |
|
| 367 | + * |
|
| 368 | + * @param string[] $names |
|
| 369 | + * @return Request |
|
| 370 | + */ |
|
| 371 | 371 | public function removeParams(array $names) : Request |
| 372 | 372 | { |
| 373 | 373 | foreach($names as $name) { |
@@ -563,11 +563,11 @@ discard block |
||
| 563 | 563 | exit; |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | - /** |
|
| 567 | - * Sends HTML to the browser with the correct headers. |
|
| 568 | - * |
|
| 569 | - * @param string $html |
|
| 570 | - */ |
|
| 566 | + /** |
|
| 567 | + * Sends HTML to the browser with the correct headers. |
|
| 568 | + * |
|
| 569 | + * @param string $html |
|
| 570 | + */ |
|
| 571 | 571 | public static function sendHTML(string $html) : void |
| 572 | 572 | { |
| 573 | 573 | header('Cache-Control: no-cache, must-revalidate'); |
@@ -588,16 +588,16 @@ discard block |
||
| 588 | 588 | exit; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - /** |
|
| 592 | - * Creates a new instance of the URL comparer, which can check |
|
| 593 | - * whether the specified URLs match, regardless of the order in |
|
| 594 | - * which the query parameters are, if any. |
|
| 595 | - * |
|
| 596 | - * @param string $sourceURL |
|
| 597 | - * @param string $targetURL |
|
| 598 | - * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
| 599 | - * @return Request_URLComparer |
|
| 600 | - */ |
|
| 591 | + /** |
|
| 592 | + * Creates a new instance of the URL comparer, which can check |
|
| 593 | + * whether the specified URLs match, regardless of the order in |
|
| 594 | + * which the query parameters are, if any. |
|
| 595 | + * |
|
| 596 | + * @param string $sourceURL |
|
| 597 | + * @param string $targetURL |
|
| 598 | + * @param string[] $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
| 599 | + * @return Request_URLComparer |
|
| 600 | + */ |
|
| 601 | 601 | public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
| 602 | 602 | { |
| 603 | 603 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
@@ -606,10 +606,10 @@ discard block |
||
| 606 | 606 | return $comparer; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | - /** |
|
| 610 | - * Retrieves the full URL that was used to access the current page. |
|
| 611 | - * @return string |
|
| 612 | - */ |
|
| 609 | + /** |
|
| 610 | + * Retrieves the full URL that was used to access the current page. |
|
| 611 | + * @return string |
|
| 612 | + */ |
|
| 613 | 613 | public function getCurrentURL() : string |
| 614 | 614 | { |
| 615 | 615 | return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
@@ -44,20 +44,20 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | protected FolderInfo $path; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var string[] |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var string[] |
|
| 49 | + */ |
|
| 50 | 50 | protected array $found = array(); |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * The path must exist when the class is instantiated: its |
|
| 54 | - * real path will be determined to work with. |
|
| 55 | - * |
|
| 56 | - * @param string|PathInfoInterface|SplFileInfo $path The absolute path to the target folder. |
|
| 57 | - * |
|
| 58 | - * @throws FileHelper_Exception |
|
| 59 | - * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
| 60 | - */ |
|
| 52 | + /** |
|
| 53 | + * The path must exist when the class is instantiated: its |
|
| 54 | + * real path will be determined to work with. |
|
| 55 | + * |
|
| 56 | + * @param string|PathInfoInterface|SplFileInfo $path The absolute path to the target folder. |
|
| 57 | + * |
|
| 58 | + * @throws FileHelper_Exception |
|
| 59 | + * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
| 60 | + */ |
|
| 61 | 61 | public function __construct($path) |
| 62 | 62 | { |
| 63 | 63 | $this->path = AbstractPathInfo::resolveType($path)->requireExists()->requireIsFolder(); |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Enables extension stripping, to return file names without extension. |
|
| 80 | - * |
|
| 81 | - * @return FileFinder |
|
| 82 | - */ |
|
| 78 | + /** |
|
| 79 | + * Enables extension stripping, to return file names without extension. |
|
| 80 | + * |
|
| 81 | + * @return FileFinder |
|
| 82 | + */ |
|
| 83 | 83 | public function stripExtensions() : FileFinder |
| 84 | 84 | { |
| 85 | 85 | return $this->setOption('strip-extensions', true); |
@@ -96,46 +96,46 @@ discard block |
||
| 96 | 96 | return $this->setOption('recursive', $enabled); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Retrieves all extensions that were added to |
|
| 101 | - * the list of included extensions. |
|
| 102 | - * |
|
| 103 | - * @return string[] |
|
| 104 | - */ |
|
| 99 | + /** |
|
| 100 | + * Retrieves all extensions that were added to |
|
| 101 | + * the list of included extensions. |
|
| 102 | + * |
|
| 103 | + * @return string[] |
|
| 104 | + */ |
|
| 105 | 105 | public function getIncludeExtensions() : array |
| 106 | 106 | { |
| 107 | 107 | return $this->getArrayOption(self::OPTION_INCLUDE_EXTENSIONS); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Includes a single extension in the file search: only |
|
| 112 | - * files with this extension will be used in the results. |
|
| 113 | - * |
|
| 114 | - * NOTE: Included extensions take precedence before excluded |
|
| 115 | - * extensions. If any excluded extensions are specified, they |
|
| 116 | - * will be ignored. |
|
| 117 | - * |
|
| 118 | - * @param string $extension Extension name, without dot (`php` for example). |
|
| 119 | - * @return FileFinder |
|
| 120 | - * @see FileFinder::includeExtensions() |
|
| 121 | - */ |
|
| 110 | + /** |
|
| 111 | + * Includes a single extension in the file search: only |
|
| 112 | + * files with this extension will be used in the results. |
|
| 113 | + * |
|
| 114 | + * NOTE: Included extensions take precedence before excluded |
|
| 115 | + * extensions. If any excluded extensions are specified, they |
|
| 116 | + * will be ignored. |
|
| 117 | + * |
|
| 118 | + * @param string $extension Extension name, without dot (`php` for example). |
|
| 119 | + * @return FileFinder |
|
| 120 | + * @see FileFinder::includeExtensions() |
|
| 121 | + */ |
|
| 122 | 122 | public function includeExtension(string $extension) : FileFinder |
| 123 | 123 | { |
| 124 | 124 | return $this->includeExtensions(array($extension)); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Includes several extensions in the file search: only |
|
| 129 | - * files with these extensions wil be used in the results. |
|
| 130 | - * |
|
| 131 | - * NOTE: Included extensions take precedence before excluded |
|
| 132 | - * extensions. If any excluded extensions are specified, they |
|
| 133 | - * will be ignored. |
|
| 134 | - * |
|
| 135 | - * @param string[] $extensions Extension names, without dot (`php` for example). |
|
| 136 | - * @return FileFinder |
|
| 137 | - * @see FileFinder::includeExtension() |
|
| 138 | - */ |
|
| 127 | + /** |
|
| 128 | + * Includes several extensions in the file search: only |
|
| 129 | + * files with these extensions wil be used in the results. |
|
| 130 | + * |
|
| 131 | + * NOTE: Included extensions take precedence before excluded |
|
| 132 | + * extensions. If any excluded extensions are specified, they |
|
| 133 | + * will be ignored. |
|
| 134 | + * |
|
| 135 | + * @param string[] $extensions Extension names, without dot (`php` for example). |
|
| 136 | + * @return FileFinder |
|
| 137 | + * @see FileFinder::includeExtension() |
|
| 138 | + */ |
|
| 139 | 139 | public function includeExtensions(array $extensions) : FileFinder |
| 140 | 140 | { |
| 141 | 141 | $items = $this->getIncludeExtensions(); |
@@ -146,37 +146,37 @@ discard block |
||
| 146 | 146 | return $this; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - /** |
|
| 150 | - * Retrieves a list of all extensions currently set as |
|
| 151 | - * excluded from the search. |
|
| 152 | - * |
|
| 153 | - * @return string[] |
|
| 154 | - */ |
|
| 149 | + /** |
|
| 150 | + * Retrieves a list of all extensions currently set as |
|
| 151 | + * excluded from the search. |
|
| 152 | + * |
|
| 153 | + * @return string[] |
|
| 154 | + */ |
|
| 155 | 155 | public function getExcludeExtensions() : array |
| 156 | 156 | { |
| 157 | 157 | return $this->getArrayOption(self::OPTION_EXCLUDE_EXTENSIONS); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * Excludes a single extension from the search. |
|
| 162 | - * |
|
| 163 | - * @param string $extension Extension name, without dot (`php` for example). |
|
| 164 | - * @return FileFinder |
|
| 165 | - * @see FileFinder::excludeExtensions() |
|
| 166 | - */ |
|
| 160 | + /** |
|
| 161 | + * Excludes a single extension from the search. |
|
| 162 | + * |
|
| 163 | + * @param string $extension Extension name, without dot (`php` for example). |
|
| 164 | + * @return FileFinder |
|
| 165 | + * @see FileFinder::excludeExtensions() |
|
| 166 | + */ |
|
| 167 | 167 | public function excludeExtension(string $extension) : FileFinder |
| 168 | 168 | { |
| 169 | 169 | return $this->excludeExtensions(array($extension)); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Add several extensions to the list of extensions to |
|
| 174 | - * exclude from the file search. |
|
| 175 | - * |
|
| 176 | - * @param string[] $extensions Extension names, without dot (`php` for example). |
|
| 177 | - * @return FileFinder |
|
| 178 | - * @see FileFinder::excludeExtension() |
|
| 179 | - */ |
|
| 172 | + /** |
|
| 173 | + * Add several extensions to the list of extensions to |
|
| 174 | + * exclude from the file search. |
|
| 175 | + * |
|
| 176 | + * @param string[] $extensions Extension names, without dot (`php` for example). |
|
| 177 | + * @return FileFinder |
|
| 178 | + * @see FileFinder::excludeExtension() |
|
| 179 | + */ |
|
| 180 | 180 | public function excludeExtensions(array $extensions) : FileFinder |
| 181 | 181 | { |
| 182 | 182 | $items = $this->getExcludeExtensions(); |
@@ -187,52 +187,52 @@ discard block |
||
| 187 | 187 | return $this; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * In this mode, the entire path to the file will be stripped, |
|
| 192 | - * leaving only the file name in the files list. |
|
| 193 | - * |
|
| 194 | - * @return FileFinder |
|
| 195 | - */ |
|
| 190 | + /** |
|
| 191 | + * In this mode, the entire path to the file will be stripped, |
|
| 192 | + * leaving only the file name in the files list. |
|
| 193 | + * |
|
| 194 | + * @return FileFinder |
|
| 195 | + */ |
|
| 196 | 196 | public function setPathmodeStrip() : FileFinder |
| 197 | 197 | { |
| 198 | 198 | return $this->setPathmode(self::PATH_MODE_STRIP); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * In this mode, only the path relative to the source folder |
|
| 203 | - * will be included in the files list. |
|
| 204 | - * |
|
| 205 | - * @return FileFinder |
|
| 206 | - */ |
|
| 201 | + /** |
|
| 202 | + * In this mode, only the path relative to the source folder |
|
| 203 | + * will be included in the files list. |
|
| 204 | + * |
|
| 205 | + * @return FileFinder |
|
| 206 | + */ |
|
| 207 | 207 | public function setPathmodeRelative() : FileFinder |
| 208 | 208 | { |
| 209 | 209 | return $this->setPathmode(self::PATH_MODE_RELATIVE); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * In this mode, the full, absolute paths to the files will |
|
| 214 | - * be included in the files list. |
|
| 215 | - * |
|
| 216 | - * @return FileFinder |
|
| 217 | - */ |
|
| 212 | + /** |
|
| 213 | + * In this mode, the full, absolute paths to the files will |
|
| 214 | + * be included in the files list. |
|
| 215 | + * |
|
| 216 | + * @return FileFinder |
|
| 217 | + */ |
|
| 218 | 218 | public function setPathmodeAbsolute() : FileFinder |
| 219 | 219 | { |
| 220 | 220 | return $this->setPathmode(self::PATH_MODE_ABSOLUTE); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - /** |
|
| 224 | - * This sets a character or string to replace the slashes |
|
| 225 | - * in the paths with. |
|
| 226 | - * |
|
| 227 | - * This is used for example in the `getPHPClassNames()` |
|
| 228 | - * method, to return files from subfolders as class names |
|
| 229 | - * using the "_" character: |
|
| 230 | - * |
|
| 231 | - * Subfolder/To/File.php => Subfolder_To_File.php |
|
| 232 | - * |
|
| 233 | - * @param string $character |
|
| 234 | - * @return FileFinder |
|
| 235 | - */ |
|
| 223 | + /** |
|
| 224 | + * This sets a character or string to replace the slashes |
|
| 225 | + * in the paths with. |
|
| 226 | + * |
|
| 227 | + * This is used for example in the `getPHPClassNames()` |
|
| 228 | + * method, to return files from subfolders as class names |
|
| 229 | + * using the "_" character: |
|
| 230 | + * |
|
| 231 | + * Subfolder/To/File.php => Subfolder_To_File.php |
|
| 232 | + * |
|
| 233 | + * @param string $character |
|
| 234 | + * @return FileFinder |
|
| 235 | + */ |
|
| 236 | 236 | public function setSlashReplacement(string $character) : FileFinder |
| 237 | 237 | { |
| 238 | 238 | return $this->setOption('slash-replacement', $character); |
@@ -255,12 +255,12 @@ discard block |
||
| 255 | 255 | return $this->setOption(self::OPTION_PATHMODE, $mode); |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - /** |
|
| 259 | - * Retrieves a list of all matching file names/paths, |
|
| 260 | - * depending on the selected options. |
|
| 261 | - * |
|
| 262 | - * @return string[] |
|
| 263 | - */ |
|
| 258 | + /** |
|
| 259 | + * Retrieves a list of all matching file names/paths, |
|
| 260 | + * depending on the selected options. |
|
| 261 | + * |
|
| 262 | + * @return string[] |
|
| 263 | + */ |
|
| 264 | 264 | public function getAll() : array |
| 265 | 265 | { |
| 266 | 266 | $this->find((string)$this->path, true); |
@@ -268,24 +268,24 @@ discard block |
||
| 268 | 268 | return $this->found; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - /** |
|
| 272 | - * Retrieves only PHP files. Can be combined with other |
|
| 273 | - * options like enabling recursion into sub-folders. |
|
| 274 | - * |
|
| 275 | - * @return string[] |
|
| 276 | - */ |
|
| 271 | + /** |
|
| 272 | + * Retrieves only PHP files. Can be combined with other |
|
| 273 | + * options like enabling recursion into sub-folders. |
|
| 274 | + * |
|
| 275 | + * @return string[] |
|
| 276 | + */ |
|
| 277 | 277 | public function getPHPFiles() : array |
| 278 | 278 | { |
| 279 | 279 | $this->includeExtensions(array('php')); |
| 280 | 280 | return $this->getAll(); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - /** |
|
| 284 | - * Generates PHP class names from file paths: it replaces |
|
| 285 | - * slashes with underscores, and removes file extensions. |
|
| 286 | - * |
|
| 287 | - * @return string[] An array of PHP file names without extension. |
|
| 288 | - */ |
|
| 283 | + /** |
|
| 284 | + * Generates PHP class names from file paths: it replaces |
|
| 285 | + * slashes with underscores, and removes file extensions. |
|
| 286 | + * |
|
| 287 | + * @return string[] An array of PHP file names without extension. |
|
| 288 | + */ |
|
| 289 | 289 | public function getPHPClassNames() : array |
| 290 | 290 | { |
| 291 | 291 | $this->includeExtensions(array('php')); |
@@ -356,13 +356,13 @@ discard block |
||
| 356 | 356 | return $path; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - /** |
|
| 360 | - * Checks whether the specified extension is allowed |
|
| 361 | - * with the current settings. |
|
| 362 | - * |
|
| 363 | - * @param string $extension |
|
| 364 | - * @return bool |
|
| 365 | - */ |
|
| 359 | + /** |
|
| 360 | + * Checks whether the specified extension is allowed |
|
| 361 | + * with the current settings. |
|
| 362 | + * |
|
| 363 | + * @param string $extension |
|
| 364 | + * @return bool |
|
| 365 | + */ |
|
| 366 | 366 | protected function filterExclusion(string $extension) : bool |
| 367 | 367 | { |
| 368 | 368 | $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS); |
@@ -382,12 +382,12 @@ discard block |
||
| 382 | 382 | return true; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - /** |
|
| 386 | - * Adjusts the path according to the selected path mode. |
|
| 387 | - * |
|
| 388 | - * @param string $path |
|
| 389 | - * @return string |
|
| 390 | - */ |
|
| 385 | + /** |
|
| 386 | + * Adjusts the path according to the selected path mode. |
|
| 387 | + * |
|
| 388 | + * @param string $path |
|
| 389 | + * @return string |
|
| 390 | + */ |
|
| 391 | 391 | protected function filterPath(string $path) : string |
| 392 | 392 | { |
| 393 | 393 | switch($this->getStringOption(self::OPTION_PATHMODE)) |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | protected ?string $details = null; |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param string $message |
|
| 30 | - * @param string|NULL $details |
|
| 31 | - * @param int|NULL $code |
|
| 32 | - * @param Throwable|NULL $previous |
|
| 33 | - */ |
|
| 28 | + /** |
|
| 29 | + * @param string $message |
|
| 30 | + * @param string|NULL $details |
|
| 31 | + * @param int|NULL $code |
|
| 32 | + * @param Throwable|NULL $previous |
|
| 33 | + */ |
|
| 34 | 34 | public function __construct(string $message, ?string $details=null, ?int $code=null, ?Throwable $previous=null) |
| 35 | 35 | { |
| 36 | 36 | if(defined('APP_UTILS_TESTSUITE') && APP_UTILS_TESTSUITE === 'true') |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | if($code === null) |
| 42 | 42 | { |
| 43 | - $code = 0; |
|
| 43 | + $code = 0; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | parent::__construct($message, (int)$code, $previous); |
@@ -48,18 +48,18 @@ discard block |
||
| 48 | 48 | $this->details = $details; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Retrieves the detailed error description, if any. |
|
| 53 | - * @return string |
|
| 54 | - */ |
|
| 51 | + /** |
|
| 52 | + * Retrieves the detailed error description, if any. |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | 55 | public function getDetails() : string |
| 56 | 56 | { |
| 57 | 57 | return $this->details ?? ''; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Displays pertinent information on the exception. |
|
| 62 | - */ |
|
| 60 | + /** |
|
| 61 | + * Displays pertinent information on the exception. |
|
| 62 | + */ |
|
| 63 | 63 | public function display() : void |
| 64 | 64 | { |
| 65 | 65 | if(!headers_sent()) { |
@@ -69,20 +69,20 @@ discard block |
||
| 69 | 69 | echo $this->getInfo(); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Retrieves information on the exception that can be |
|
| 74 | - * easily accessed. |
|
| 75 | - * |
|
| 76 | - * @return ConvertHelper_ThrowableInfo |
|
| 77 | - */ |
|
| 72 | + /** |
|
| 73 | + * Retrieves information on the exception that can be |
|
| 74 | + * easily accessed. |
|
| 75 | + * |
|
| 76 | + * @return ConvertHelper_ThrowableInfo |
|
| 77 | + */ |
|
| 78 | 78 | public function getInfo() : ConvertHelper_ThrowableInfo |
| 79 | 79 | { |
| 80 | 80 | return ConvertHelper::throwable2info($this); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Dumps a current PHP function trace, as a text only string. |
|
| 85 | - */ |
|
| 83 | + /** |
|
| 84 | + * Dumps a current PHP function trace, as a text only string. |
|
| 85 | + */ |
|
| 86 | 86 | public static function dumpTraceAsString() : void |
| 87 | 87 | { |
| 88 | 88 | try |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Dumps a current PHP function trace, with HTML styling. |
|
| 100 | - */ |
|
| 98 | + /** |
|
| 99 | + * Dumps a current PHP function trace, with HTML styling. |
|
| 100 | + */ |
|
| 101 | 101 | public static function dumpTraceAsHTML() : void |
| 102 | 102 | { |
| 103 | 103 | try |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Creates an exception info instance from a throwable instance. |
|
| 117 | - * |
|
| 118 | - * @param Throwable $e |
|
| 119 | - * @return ConvertHelper_ThrowableInfo |
|
| 120 | - * @see ConvertHelper::throwable2info() |
|
| 121 | - */ |
|
| 115 | + /** |
|
| 116 | + * Creates an exception info instance from a throwable instance. |
|
| 117 | + * |
|
| 118 | + * @param Throwable $e |
|
| 119 | + * @return ConvertHelper_ThrowableInfo |
|
| 120 | + * @see ConvertHelper::throwable2info() |
|
| 121 | + */ |
|
| 122 | 122 | public static function createInfo(Throwable $e) : ConvertHelper_ThrowableInfo |
| 123 | 123 | { |
| 124 | 124 | return ConvertHelper::throwable2info($e); |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | self::TYPE_TRAIT |
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param PHPFile $path The path to the PHP file to parse. |
|
| 53 | - * @throws FileHelper_Exception |
|
| 54 | - * @see FileHelper::findPHPClasses() |
|
| 55 | - */ |
|
| 51 | + /** |
|
| 52 | + * @param PHPFile $path The path to the PHP file to parse. |
|
| 53 | + * @throws FileHelper_Exception |
|
| 54 | + * @see FileHelper::findPHPClasses() |
|
| 55 | + */ |
|
| 56 | 56 | public function __construct(PHPFile $path) |
| 57 | 57 | { |
| 58 | 58 | $this->file = $path |
@@ -62,58 +62,58 @@ discard block |
||
| 62 | 62 | $this->parseFile(); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * The name of the namespace of the classes in the file, if any. |
|
| 67 | - * @return string |
|
| 68 | - */ |
|
| 65 | + /** |
|
| 66 | + * The name of the namespace of the classes in the file, if any. |
|
| 67 | + * @return string |
|
| 68 | + */ |
|
| 69 | 69 | public function getNamespace() : string |
| 70 | 70 | { |
| 71 | 71 | return $this->namespace; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Whether the file contains a namespace. |
|
| 76 | - * @return bool |
|
| 77 | - */ |
|
| 74 | + /** |
|
| 75 | + * Whether the file contains a namespace. |
|
| 76 | + * @return bool |
|
| 77 | + */ |
|
| 78 | 78 | public function hasNamespace() : bool |
| 79 | 79 | { |
| 80 | 80 | return !empty($this->namespace); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * The absolute path to the file. |
|
| 85 | - * @return string |
|
| 86 | - */ |
|
| 83 | + /** |
|
| 84 | + * The absolute path to the file. |
|
| 85 | + * @return string |
|
| 86 | + */ |
|
| 87 | 87 | public function getPath() : string |
| 88 | 88 | { |
| 89 | 89 | return $this->file->getPath(); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Whether any classes were found in the file. |
|
| 94 | - * @return bool |
|
| 95 | - */ |
|
| 92 | + /** |
|
| 93 | + * Whether any classes were found in the file. |
|
| 94 | + * @return bool |
|
| 95 | + */ |
|
| 96 | 96 | public function hasClasses() : bool |
| 97 | 97 | { |
| 98 | 98 | return !empty($this->classes); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * The names of the classes that were found in the file (with namespace if any). |
|
| 103 | - * @return string[] |
|
| 104 | - */ |
|
| 101 | + /** |
|
| 102 | + * The names of the classes that were found in the file (with namespace if any). |
|
| 103 | + * @return string[] |
|
| 104 | + */ |
|
| 105 | 105 | public function getClassNames() : array |
| 106 | 106 | { |
| 107 | 107 | return array_keys($this->classes); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Retrieves all classes that were detected in the file, |
|
| 112 | - * which can be used to retrieve more information about |
|
| 113 | - * them. |
|
| 114 | - * |
|
| 115 | - * @return FileHelper_PHPClassInfo_Class[] |
|
| 116 | - */ |
|
| 110 | + /** |
|
| 111 | + * Retrieves all classes that were detected in the file, |
|
| 112 | + * which can be used to retrieve more information about |
|
| 113 | + * them. |
|
| 114 | + * |
|
| 115 | + * @return FileHelper_PHPClassInfo_Class[] |
|
| 116 | + */ |
|
| 117 | 117 | public function getClasses() : array |
| 118 | 118 | { |
| 119 | 119 | return array_values($this->classes); |
@@ -185,13 +185,13 @@ discard block |
||
| 185 | 185 | $this->classes[$class->getNameNS()] = $class; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * Strips all whitespace from the string, replacing it with |
|
| 190 | - * regular spaces (newlines, tabs, etc.). |
|
| 191 | - * |
|
| 192 | - * @param string $string |
|
| 193 | - * @return string |
|
| 194 | - */ |
|
| 188 | + /** |
|
| 189 | + * Strips all whitespace from the string, replacing it with |
|
| 190 | + * regular spaces (newlines, tabs, etc.). |
|
| 191 | + * |
|
| 192 | + * @param string $string |
|
| 193 | + * @return string |
|
| 194 | + */ |
|
| 195 | 195 | protected function stripWhitespace(string $string) : string |
| 196 | 196 | { |
| 197 | 197 | return preg_replace('/\s/', ' ', $string); |
@@ -33,22 +33,22 @@ discard block |
||
| 33 | 33 | $this->parse(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Retrieves an indexed array with accept mime types |
|
| 38 | - * that the client sent, in the order of preference |
|
| 39 | - * the client specified. |
|
| 40 | - * |
|
| 41 | - * Example: |
|
| 42 | - * |
|
| 43 | - * array( |
|
| 44 | - * 'text/html', |
|
| 45 | - * 'application/xhtml+xml', |
|
| 46 | - * 'image/webp' |
|
| 47 | - * ... |
|
| 48 | - * ) |
|
| 49 | - * |
|
| 50 | - * @return string[] |
|
| 51 | - */ |
|
| 36 | + /** |
|
| 37 | + * Retrieves an indexed array with accept mime types |
|
| 38 | + * that the client sent, in the order of preference |
|
| 39 | + * the client specified. |
|
| 40 | + * |
|
| 41 | + * Example: |
|
| 42 | + * |
|
| 43 | + * array( |
|
| 44 | + * 'text/html', |
|
| 45 | + * 'application/xhtml+xml', |
|
| 46 | + * 'image/webp' |
|
| 47 | + * ... |
|
| 48 | + * ) |
|
| 49 | + * |
|
| 50 | + * @return string[] |
|
| 51 | + */ |
|
| 52 | 52 | public function getMimeStrings() : array |
| 53 | 53 | { |
| 54 | 54 | $result = array(); |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | return $result; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Checks that an "Accept" header string exists, and tries to parse it. |
|
| 66 | - */ |
|
| 64 | + /** |
|
| 65 | + * Checks that an "Accept" header string exists, and tries to parse it. |
|
| 66 | + */ |
|
| 67 | 67 | protected function parse() : void |
| 68 | 68 | { |
| 69 | 69 | // we may be in a CLI environment where the headers |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | $this->headers = $this->parseHeader($_SERVER['HTTP_ACCEPT']); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Splits the "Accept" header string and parses the mime types. |
|
| 80 | - * |
|
| 81 | - * @param string $acceptHeader |
|
| 82 | - * @return AcceptHeader[] |
|
| 83 | - */ |
|
| 78 | + /** |
|
| 79 | + * Splits the "Accept" header string and parses the mime types. |
|
| 80 | + * |
|
| 81 | + * @param string $acceptHeader |
|
| 82 | + * @return AcceptHeader[] |
|
| 83 | + */ |
|
| 84 | 84 | protected function parseHeader(string $acceptHeader) : array |
| 85 | 85 | { |
| 86 | 86 | $tokens = preg_split('/\s*,\s*/', $acceptHeader); |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | return $accept; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Parses a single mime type entry. |
|
| 102 | - * |
|
| 103 | - * @param int $i The position in the "Accept" string |
|
| 104 | - * @param string $mime The mime type |
|
| 105 | - * @return AcceptHeader |
|
| 106 | - */ |
|
| 100 | + /** |
|
| 101 | + * Parses a single mime type entry. |
|
| 102 | + * |
|
| 103 | + * @param int $i The position in the "Accept" string |
|
| 104 | + * @param string $mime The mime type |
|
| 105 | + * @return AcceptHeader |
|
| 106 | + */ |
|
| 107 | 107 | protected function parseEntry(int $i, string $mime) : AcceptHeader |
| 108 | 108 | { |
| 109 | 109 | $quality = 0; |
@@ -28,23 +28,23 @@ |
||
| 28 | 28 | $this->info = $info; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Enables the authentication information in the URL, |
|
| 33 | - * if a username and password are present. |
|
| 34 | - * |
|
| 35 | - * @param bool $enable Whether to turn it on or off. |
|
| 36 | - * @return URINormalizer |
|
| 37 | - */ |
|
| 31 | + /** |
|
| 32 | + * Enables the authentication information in the URL, |
|
| 33 | + * if a username and password are present. |
|
| 34 | + * |
|
| 35 | + * @param bool $enable Whether to turn it on or off. |
|
| 36 | + * @return URINormalizer |
|
| 37 | + */ |
|
| 38 | 38 | public function enableAuth(bool $enable=true) : URINormalizer |
| 39 | 39 | { |
| 40 | 40 | $this->auth = $enable; |
| 41 | 41 | return $this; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Retrieves the normalized URL. |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 44 | + /** |
|
| 45 | + * Retrieves the normalized URL. |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | 48 | public function normalize() : string |
| 49 | 49 | { |
| 50 | 50 | $method = 'normalize_'.$this->info->getType(); |
@@ -155,13 +155,13 @@ |
||
| 155 | 155 | ); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Fetches all parameters in the URL, regardless of |
|
| 160 | - * whether parameter exclusion is enabled, so they |
|
| 161 | - * can be highlighted is need be. |
|
| 162 | - * |
|
| 163 | - * @return array<string,string> |
|
| 164 | - */ |
|
| 158 | + /** |
|
| 159 | + * Fetches all parameters in the URL, regardless of |
|
| 160 | + * whether parameter exclusion is enabled, so they |
|
| 161 | + * can be highlighted is need be. |
|
| 162 | + * |
|
| 163 | + * @return array<string,string> |
|
| 164 | + */ |
|
| 165 | 165 | protected function resolveParams() : array |
| 166 | 166 | { |
| 167 | 167 | $previous = $this->info->isParamExclusionEnabled(); |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * The end of line character used in the INI source string. |
|
| 67 | - * @return string |
|
| 68 | - */ |
|
| 65 | + /** |
|
| 66 | + * The end of line character used in the INI source string. |
|
| 67 | + * @return string |
|
| 68 | + */ |
|
| 69 | 69 | public function getEOLChar() : string |
| 70 | 70 | { |
| 71 | 71 | return $this->eol; |
@@ -99,35 +99,35 @@ discard block |
||
| 99 | 99 | ); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Factory method: Creates a new ini helper instance from an ini string. |
|
| 104 | - * |
|
| 105 | - * @param string $iniContent |
|
| 106 | - * @return IniHelper |
|
| 107 | - */ |
|
| 102 | + /** |
|
| 103 | + * Factory method: Creates a new ini helper instance from an ini string. |
|
| 104 | + * |
|
| 105 | + * @param string $iniContent |
|
| 106 | + * @return IniHelper |
|
| 107 | + */ |
|
| 108 | 108 | public static function createFromString(string $iniContent) : IniHelper |
| 109 | 109 | { |
| 110 | 110 | return new IniHelper($iniContent); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Factory method: Creates a new empty ini helper. |
|
| 115 | - * |
|
| 116 | - * @return IniHelper |
|
| 117 | - */ |
|
| 113 | + /** |
|
| 114 | + * Factory method: Creates a new empty ini helper. |
|
| 115 | + * |
|
| 116 | + * @return IniHelper |
|
| 117 | + */ |
|
| 118 | 118 | public static function createNew() : IniHelper |
| 119 | 119 | { |
| 120 | 120 | return self::createFromString(''); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Adds a new data section, and returns the section instance. |
|
| 125 | - * If a section with the name already exists, returns that |
|
| 126 | - * section instead of creating a new one. |
|
| 127 | - * |
|
| 128 | - * @param string $name |
|
| 129 | - * @return IniHelper_Section |
|
| 130 | - */ |
|
| 123 | + /** |
|
| 124 | + * Adds a new data section, and returns the section instance. |
|
| 125 | + * If a section with the name already exists, returns that |
|
| 126 | + * section instead of creating a new one. |
|
| 127 | + * |
|
| 128 | + * @param string $name |
|
| 129 | + * @return IniHelper_Section |
|
| 130 | + */ |
|
| 131 | 131 | public function addSection(string $name) : IniHelper_Section |
| 132 | 132 | { |
| 133 | 133 | if(!isset($this->sections[$name])) { |
@@ -137,22 +137,22 @@ discard block |
||
| 137 | 137 | return $this->sections[$name]; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Retrieves a section by its name, if it exists. |
|
| 142 | - * |
|
| 143 | - * @param string $name |
|
| 144 | - * @return IniHelper_Section|NULL |
|
| 145 | - */ |
|
| 140 | + /** |
|
| 141 | + * Retrieves a section by its name, if it exists. |
|
| 142 | + * |
|
| 143 | + * @param string $name |
|
| 144 | + * @return IniHelper_Section|NULL |
|
| 145 | + */ |
|
| 146 | 146 | public function getSection(string $name) : ?IniHelper_Section |
| 147 | 147 | { |
| 148 | 148 | return $this->sections[$name] ?? null; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Gets the data from the INI file as an associative array. |
|
| 153 | - * |
|
| 154 | - * @return array<string,mixed> |
|
| 155 | - */ |
|
| 151 | + /** |
|
| 152 | + * Gets the data from the INI file as an associative array. |
|
| 153 | + * |
|
| 154 | + * @return array<string,mixed> |
|
| 155 | + */ |
|
| 156 | 156 | public function toArray() : array |
| 157 | 157 | { |
| 158 | 158 | $result = array(); |
@@ -172,17 +172,17 @@ discard block |
||
| 172 | 172 | return $result; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Saves the INI content to the target file. |
|
| 177 | - * |
|
| 178 | - * @param string $filePath |
|
| 179 | - * @return IniHelper |
|
| 180 | - * @throws FileHelper_Exception |
|
| 181 | - * |
|
| 182 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
| 183 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
| 184 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
| 185 | - */ |
|
| 175 | + /** |
|
| 176 | + * Saves the INI content to the target file. |
|
| 177 | + * |
|
| 178 | + * @param string $filePath |
|
| 179 | + * @return IniHelper |
|
| 180 | + * @throws FileHelper_Exception |
|
| 181 | + * |
|
| 182 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
| 183 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
| 184 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
| 185 | + */ |
|
| 186 | 186 | public function saveToFile(string $filePath) : IniHelper |
| 187 | 187 | { |
| 188 | 188 | FileHelper::saveFile($filePath, $this->saveToString()); |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | return $this; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Returns the INI content as string. |
|
| 195 | - * |
|
| 196 | - * @return string |
|
| 197 | - */ |
|
| 193 | + /** |
|
| 194 | + * Returns the INI content as string. |
|
| 195 | + * |
|
| 196 | + * @return string |
|
| 197 | + */ |
|
| 198 | 198 | public function saveToString() : string |
| 199 | 199 | { |
| 200 | 200 | $parts = array(); |
@@ -207,15 +207,15 @@ discard block |
||
| 207 | 207 | return implode($this->eol, $parts); |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Sets or adds the value of a setting in the INI content. |
|
| 212 | - * If the setting does not exist, it is added. Otherwise, |
|
| 213 | - * the existing value is overwritten. |
|
| 214 | - * |
|
| 215 | - * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>. |
|
| 216 | - * @param mixed $value |
|
| 217 | - * @return IniHelper |
|
| 218 | - */ |
|
| 210 | + /** |
|
| 211 | + * Sets or adds the value of a setting in the INI content. |
|
| 212 | + * If the setting does not exist, it is added. Otherwise, |
|
| 213 | + * the existing value is overwritten. |
|
| 214 | + * |
|
| 215 | + * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>. |
|
| 216 | + * @param mixed $value |
|
| 217 | + * @return IniHelper |
|
| 218 | + */ |
|
| 219 | 219 | public function setValue(string $path, $value) : IniHelper |
| 220 | 220 | { |
| 221 | 221 | $info = $this->parsePath($path); |
@@ -239,12 +239,12 @@ discard block |
||
| 239 | 239 | return $this; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * Checks whether a section with the specified name exists. |
|
| 244 | - * |
|
| 245 | - * @param string $name |
|
| 246 | - * @return bool |
|
| 247 | - */ |
|
| 242 | + /** |
|
| 243 | + * Checks whether a section with the specified name exists. |
|
| 244 | + * |
|
| 245 | + * @param string $name |
|
| 246 | + * @return bool |
|
| 247 | + */ |
|
| 248 | 248 | public function sectionExists(string $name) : bool |
| 249 | 249 | { |
| 250 | 250 | foreach($this->sections as $section) { |
@@ -256,23 +256,23 @@ discard block |
||
| 256 | 256 | return false; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Retrieves the default section, which is used to add |
|
| 261 | - * values in the root of the document. |
|
| 262 | - * |
|
| 263 | - * @return IniHelper_Section |
|
| 264 | - */ |
|
| 259 | + /** |
|
| 260 | + * Retrieves the default section, which is used to add |
|
| 261 | + * values in the root of the document. |
|
| 262 | + * |
|
| 263 | + * @return IniHelper_Section |
|
| 264 | + */ |
|
| 265 | 265 | public function getDefaultSection() : IniHelper_Section |
| 266 | 266 | { |
| 267 | 267 | return $this->addSection(self::SECTION_DEFAULT); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Retrieves all variable lines for the specified path. |
|
| 272 | - * |
|
| 273 | - * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>. |
|
| 274 | - * @return INILine[] |
|
| 275 | - */ |
|
| 270 | + /** |
|
| 271 | + * Retrieves all variable lines for the specified path. |
|
| 272 | + * |
|
| 273 | + * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>. |
|
| 274 | + * @return INILine[] |
|
| 275 | + */ |
|
| 276 | 276 | public function getLinesByVariable(string $path) : array |
| 277 | 277 | { |
| 278 | 278 | $info = $this->parsePath($path); |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | protected IniHelper $ini; |
| 27 | 27 | protected string $name; |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var INILine[] |
|
| 31 | - */ |
|
| 29 | + /** |
|
| 30 | + * @var INILine[] |
|
| 31 | + */ |
|
| 32 | 32 | protected array $lines = array(); |
| 33 | 33 | |
| 34 | 34 | public function __construct(IniHelper $ini, string $name) |
@@ -37,33 +37,33 @@ discard block |
||
| 37 | 37 | $this->name = $name; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * The section's name. |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 40 | + /** |
|
| 41 | + * The section's name. |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 44 | 44 | public function getName() : string |
| 45 | 45 | { |
| 46 | 46 | return $this->name; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Whether this is the default section: this |
|
| 51 | - * is used internally to store all variables that |
|
| 52 | - * are not in any specific section. |
|
| 53 | - * |
|
| 54 | - * @return bool |
|
| 55 | - */ |
|
| 49 | + /** |
|
| 50 | + * Whether this is the default section: this |
|
| 51 | + * is used internally to store all variables that |
|
| 52 | + * are not in any specific section. |
|
| 53 | + * |
|
| 54 | + * @return bool |
|
| 55 | + */ |
|
| 56 | 56 | public function isDefault() : bool |
| 57 | 57 | { |
| 58 | 58 | return $this->name === IniHelper::SECTION_DEFAULT; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * Adds a line instance to the section. |
|
| 63 | - * |
|
| 64 | - * @param INILine $line |
|
| 65 | - * @return IniHelper_Section |
|
| 66 | - */ |
|
| 61 | + /** |
|
| 62 | + * Adds a line instance to the section. |
|
| 63 | + * |
|
| 64 | + * @param INILine $line |
|
| 65 | + * @return IniHelper_Section |
|
| 66 | + */ |
|
| 67 | 67 | public function addLine(INILine $line) : IniHelper_Section |
| 68 | 68 | { |
| 69 | 69 | $this->lines[] = $line; |
@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | return $this; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Converts the values contained in the section into |
|
| 76 | - * an associative array. |
|
| 77 | - * |
|
| 78 | - * @return array<string,array<int,string>> |
|
| 79 | - */ |
|
| 74 | + /** |
|
| 75 | + * Converts the values contained in the section into |
|
| 76 | + * an associative array. |
|
| 77 | + * |
|
| 78 | + * @return array<string,array<int,string>> |
|
| 79 | + */ |
|
| 80 | 80 | public function toArray() : array |
| 81 | 81 | { |
| 82 | 82 | $result = array(); |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | return implode($this->ini->getEOLChar(), $lines); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Deletes a line from the section. |
|
| 141 | - * |
|
| 142 | - * @param INILine $toDelete |
|
| 143 | - * @return IniHelper_Section |
|
| 144 | - */ |
|
| 139 | + /** |
|
| 140 | + * Deletes a line from the section. |
|
| 141 | + * |
|
| 142 | + * @param INILine $toDelete |
|
| 143 | + * @return IniHelper_Section |
|
| 144 | + */ |
|
| 145 | 145 | public function deleteLine(INILine $toDelete) : IniHelper_Section |
| 146 | 146 | { |
| 147 | 147 | $keep = array(); |
@@ -226,15 +226,15 @@ discard block |
||
| 226 | 226 | return $this; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * Adds a variable value to the section. Unlike setValue(), this |
|
| 231 | - * will not overwrite any existing value. If the name is an existing |
|
| 232 | - * variable name, it will be converted to duplicate keys. |
|
| 233 | - * |
|
| 234 | - * @param string $name |
|
| 235 | - * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
| 236 | - * @return IniHelper_Section |
|
| 237 | - */ |
|
| 229 | + /** |
|
| 230 | + * Adds a variable value to the section. Unlike setValue(), this |
|
| 231 | + * will not overwrite any existing value. If the name is an existing |
|
| 232 | + * variable name, it will be converted to duplicate keys. |
|
| 233 | + * |
|
| 234 | + * @param string $name |
|
| 235 | + * @param mixed $value If this is an array, it will be treated as duplicate keys, and all values that are not present yet will be added. |
|
| 236 | + * @return IniHelper_Section |
|
| 237 | + */ |
|
| 238 | 238 | public function addValue(string $name, $value) : IniHelper_Section |
| 239 | 239 | { |
| 240 | 240 | // array value? Treat it as duplicate keys. |
@@ -297,12 +297,12 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | |
| 300 | - /** |
|
| 301 | - * Retrieves all lines for the specified variable name. |
|
| 302 | - * |
|
| 303 | - * @param string $name |
|
| 304 | - * @return INILine[] |
|
| 305 | - */ |
|
| 300 | + /** |
|
| 301 | + * Retrieves all lines for the specified variable name. |
|
| 302 | + * |
|
| 303 | + * @param string $name |
|
| 304 | + * @return INILine[] |
|
| 305 | + */ |
|
| 306 | 306 | public function getLinesByVariable(string $name) : array |
| 307 | 307 | { |
| 308 | 308 | $result = array(); |