@@ -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(); |
@@ -44,42 +44,42 @@ discard block |
||
44 | 44 | public const TYPE_URL = 'url'; |
45 | 45 | public const TYPE_NONE = 'none'; |
46 | 46 | |
47 | - /** |
|
48 | - * The original URL that was passed to the constructor. |
|
49 | - * @var string |
|
50 | - */ |
|
47 | + /** |
|
48 | + * The original URL that was passed to the constructor. |
|
49 | + * @var string |
|
50 | + */ |
|
51 | 51 | protected string $rawURL; |
52 | 52 | |
53 | - /** |
|
54 | - * @var array<string,mixed> |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var array<string,mixed> |
|
55 | + */ |
|
56 | 56 | protected array $info; |
57 | 57 | |
58 | - /** |
|
59 | - * @var string[] |
|
60 | - */ |
|
58 | + /** |
|
59 | + * @var string[] |
|
60 | + */ |
|
61 | 61 | protected array $excludedParams = array(); |
62 | 62 | |
63 | - /** |
|
64 | - * @var bool |
|
65 | - * @see URLInfo::setParamExclusion() |
|
66 | - */ |
|
63 | + /** |
|
64 | + * @var bool |
|
65 | + * @see URLInfo::setParamExclusion() |
|
66 | + */ |
|
67 | 67 | protected bool $paramExclusion = false; |
68 | 68 | |
69 | - /** |
|
70 | - * @var array<string,string>|NULL |
|
71 | - * @see URLInfo::getTypeLabel() |
|
72 | - */ |
|
69 | + /** |
|
70 | + * @var array<string,string>|NULL |
|
71 | + * @see URLInfo::getTypeLabel() |
|
72 | + */ |
|
73 | 73 | protected static ?array $typeLabels = null; |
74 | 74 | |
75 | - /** |
|
76 | - * @var bool |
|
77 | - */ |
|
75 | + /** |
|
76 | + * @var bool |
|
77 | + */ |
|
78 | 78 | protected bool $highlightExcluded = false; |
79 | 79 | |
80 | - /** |
|
81 | - * @var string[] |
|
82 | - */ |
|
80 | + /** |
|
81 | + * @var string[] |
|
82 | + */ |
|
83 | 83 | protected array $infoKeys = array( |
84 | 84 | 'scheme', |
85 | 85 | 'host', |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | 'fragment' |
92 | 92 | ); |
93 | 93 | |
94 | - /** |
|
95 | - * @var string |
|
96 | - */ |
|
94 | + /** |
|
95 | + * @var string |
|
96 | + */ |
|
97 | 97 | protected string $url; |
98 | 98 | |
99 | - /** |
|
100 | - * @var URIParser |
|
101 | - */ |
|
99 | + /** |
|
100 | + * @var URIParser |
|
101 | + */ |
|
102 | 102 | protected URIParser $parser; |
103 | 103 | |
104 | - /** |
|
105 | - * @var URINormalizer|NULL |
|
106 | - */ |
|
104 | + /** |
|
105 | + * @var URINormalizer|NULL |
|
106 | + */ |
|
107 | 107 | protected ?URINormalizer $normalizer = null; |
108 | 108 | |
109 | - /** |
|
110 | - * @var bool |
|
111 | - */ |
|
109 | + /** |
|
110 | + * @var bool |
|
111 | + */ |
|
112 | 112 | protected bool $encodeUTFChars = false; |
113 | 113 | |
114 | 114 | public function __construct(string $url) |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | $this->info = $this->parser->getInfo(); |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
130 | - * Default is to leave them as-is for better readability, since |
|
131 | - * browsers handle this well. |
|
132 | - * |
|
133 | - * @param bool $enabled |
|
134 | - * @return URLInfo |
|
135 | - */ |
|
128 | + /** |
|
129 | + * Whether to URL encode any non-encoded UTF8 characters in the URL. |
|
130 | + * Default is to leave them as-is for better readability, since |
|
131 | + * browsers handle this well. |
|
132 | + * |
|
133 | + * @param bool $enabled |
|
134 | + * @return URLInfo |
|
135 | + */ |
|
136 | 136 | public function setUTFEncoding(bool $enabled=true) : URLInfo |
137 | 137 | { |
138 | 138 | if($this->encodeUTFChars !== $enabled) |
@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | return $this->encodeUTFChars; |
150 | 150 | } |
151 | 151 | |
152 | - /** |
|
153 | - * Filters a URL: removes control characters and the |
|
154 | - * like to have a clean URL to work with. |
|
155 | - * |
|
156 | - * @param string $url |
|
157 | - * @return string |
|
158 | - */ |
|
152 | + /** |
|
153 | + * Filters a URL: removes control characters and the |
|
154 | + * like to have a clean URL to work with. |
|
155 | + * |
|
156 | + * @param string $url |
|
157 | + * @return string |
|
158 | + */ |
|
159 | 159 | public static function filterURL(string $url) : string |
160 | 160 | { |
161 | 161 | return URIFilter::filter($url); |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | return $this->info['type'] === self::TYPE_PHONE; |
186 | 186 | } |
187 | 187 | |
188 | - /** |
|
189 | - * Whether the URL is a regular URL, not one of the |
|
190 | - * other types like a phone number or email address. |
|
191 | - * |
|
192 | - * @return bool |
|
193 | - */ |
|
188 | + /** |
|
189 | + * Whether the URL is a regular URL, not one of the |
|
190 | + * other types like a phone number or email address. |
|
191 | + * |
|
192 | + * @return bool |
|
193 | + */ |
|
194 | 194 | public function isURL() : bool |
195 | 195 | { |
196 | 196 | $host = $this->getHost(); |
@@ -202,20 +202,20 @@ discard block |
||
202 | 202 | return $this->parser->isValid(); |
203 | 203 | } |
204 | 204 | |
205 | - /** |
|
206 | - * Retrieves the host name, or an empty string if none is present. |
|
207 | - * |
|
208 | - * @return string |
|
209 | - */ |
|
205 | + /** |
|
206 | + * Retrieves the host name, or an empty string if none is present. |
|
207 | + * |
|
208 | + * @return string |
|
209 | + */ |
|
210 | 210 | public function getHost() : string |
211 | 211 | { |
212 | 212 | return $this->getInfoKey('host'); |
213 | 213 | } |
214 | 214 | |
215 | - /** |
|
216 | - * Retrieves the path, or an empty string if none is present. |
|
217 | - * @return string |
|
218 | - */ |
|
215 | + /** |
|
216 | + * Retrieves the path, or an empty string if none is present. |
|
217 | + * @return string |
|
218 | + */ |
|
219 | 219 | public function getPath() : string |
220 | 220 | { |
221 | 221 | return $this->getInfoKey('path'); |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | return $this->getInfoKey('scheme'); |
232 | 232 | } |
233 | 233 | |
234 | - /** |
|
235 | - * Retrieves the port specified in the URL, or -1 if none is present. |
|
236 | - * @return int |
|
237 | - */ |
|
234 | + /** |
|
235 | + * Retrieves the port specified in the URL, or -1 if none is present. |
|
236 | + * @return int |
|
237 | + */ |
|
238 | 238 | public function getPort() : int |
239 | 239 | { |
240 | 240 | $port = $this->getInfoKey('port'); |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | return -1; |
247 | 247 | } |
248 | 248 | |
249 | - /** |
|
250 | - * Retrieves the raw query string, or an empty string if none is present. |
|
251 | - * |
|
252 | - * @return string |
|
253 | - * |
|
254 | - * @see URLInfo::getParams() |
|
255 | - */ |
|
249 | + /** |
|
250 | + * Retrieves the raw query string, or an empty string if none is present. |
|
251 | + * |
|
252 | + * @return string |
|
253 | + * |
|
254 | + * @see URLInfo::getParams() |
|
255 | + */ |
|
256 | 256 | public function getQuery() : string |
257 | 257 | { |
258 | 258 | return $this->getInfoKey('query'); |
@@ -268,20 +268,20 @@ discard block |
||
268 | 268 | return $this->getInfoKey('pass'); |
269 | 269 | } |
270 | 270 | |
271 | - /** |
|
272 | - * Whether the URL contains a port number. |
|
273 | - * @return bool |
|
274 | - */ |
|
271 | + /** |
|
272 | + * Whether the URL contains a port number. |
|
273 | + * @return bool |
|
274 | + */ |
|
275 | 275 | public function hasPort() : bool |
276 | 276 | { |
277 | 277 | return $this->getPort() !== -1; |
278 | 278 | } |
279 | 279 | |
280 | - /** |
|
281 | - * Alias for the hasParams() method. |
|
282 | - * @return bool |
|
283 | - * @see URLInfo::hasParams() |
|
284 | - */ |
|
280 | + /** |
|
281 | + * Alias for the hasParams() method. |
|
282 | + * @return bool |
|
283 | + * @see URLInfo::hasParams() |
|
284 | + */ |
|
285 | 285 | public function hasQuery() : bool |
286 | 286 | { |
287 | 287 | return $this->hasParams(); |
@@ -326,23 +326,23 @@ discard block |
||
326 | 326 | return ''; |
327 | 327 | } |
328 | 328 | |
329 | - /** |
|
330 | - * Retrieves a normalized URL: this ensures that all parameters |
|
331 | - * in the URL are always in the same order. |
|
332 | - * |
|
333 | - * @return string |
|
334 | - */ |
|
329 | + /** |
|
330 | + * Retrieves a normalized URL: this ensures that all parameters |
|
331 | + * in the URL are always in the same order. |
|
332 | + * |
|
333 | + * @return string |
|
334 | + */ |
|
335 | 335 | public function getNormalized() : string |
336 | 336 | { |
337 | 337 | return $this->normalize(); |
338 | 338 | } |
339 | 339 | |
340 | - /** |
|
341 | - * Like getNormalized(), but if a username and password are present |
|
342 | - * in the URL, returns the URL without them. |
|
343 | - * |
|
344 | - * @return string |
|
345 | - */ |
|
340 | + /** |
|
341 | + * Like getNormalized(), but if a username and password are present |
|
342 | + * in the URL, returns the URL without them. |
|
343 | + * |
|
344 | + * @return string |
|
345 | + */ |
|
346 | 346 | public function getNormalizedWithoutAuth() : string |
347 | 347 | { |
348 | 348 | return $this->normalize(false); |
@@ -363,25 +363,25 @@ discard block |
||
363 | 363 | return $this->normalizer->normalize(); |
364 | 364 | } |
365 | 365 | |
366 | - /** |
|
367 | - * Creates a hash of the URL, which can be used for comparisons. |
|
368 | - * Since any parameters in the URL's query are sorted alphabetically, |
|
369 | - * the same links with a different parameter order will have the |
|
370 | - * same hash. |
|
371 | - * |
|
372 | - * @return string |
|
373 | - */ |
|
366 | + /** |
|
367 | + * Creates a hash of the URL, which can be used for comparisons. |
|
368 | + * Since any parameters in the URL's query are sorted alphabetically, |
|
369 | + * the same links with a different parameter order will have the |
|
370 | + * same hash. |
|
371 | + * |
|
372 | + * @return string |
|
373 | + */ |
|
374 | 374 | public function getHash() : string |
375 | 375 | { |
376 | 376 | return ConvertHelper::string2shortHash($this->getNormalized()); |
377 | 377 | } |
378 | 378 | |
379 | - /** |
|
380 | - * Highlights the URL using HTML tags with specific highlighting |
|
381 | - * class names. |
|
382 | - * |
|
383 | - * @return string Will return an empty string if the URL is not valid. |
|
384 | - */ |
|
379 | + /** |
|
380 | + * Highlights the URL using HTML tags with specific highlighting |
|
381 | + * class names. |
|
382 | + * |
|
383 | + * @return string Will return an empty string if the URL is not valid. |
|
384 | + */ |
|
385 | 385 | public function getHighlighted() : string |
386 | 386 | { |
387 | 387 | if(!$this->isValid()) { |
@@ -413,15 +413,15 @@ discard block |
||
413 | 413 | return count($params); |
414 | 414 | } |
415 | 415 | |
416 | - /** |
|
417 | - * Retrieves all parameters specified in the url, |
|
418 | - * if any, as an associative array. |
|
419 | - * |
|
420 | - * NOTE: Ignores parameters that have been added |
|
421 | - * to the excluded parameters list. |
|
422 | - * |
|
423 | - * @return array<string,string> |
|
424 | - */ |
|
416 | + /** |
|
417 | + * Retrieves all parameters specified in the url, |
|
418 | + * if any, as an associative array. |
|
419 | + * |
|
420 | + * NOTE: Ignores parameters that have been added |
|
421 | + * to the excluded parameters list. |
|
422 | + * |
|
423 | + * @return array<string,string> |
|
424 | + */ |
|
425 | 425 | public function getParams() : array |
426 | 426 | { |
427 | 427 | if(!$this->paramExclusion || empty($this->excludedParams)) { |
@@ -439,37 +439,37 @@ discard block |
||
439 | 439 | return $keep; |
440 | 440 | } |
441 | 441 | |
442 | - /** |
|
443 | - * Retrieves the names of all parameters present in the URL, if any. |
|
444 | - * @return string[] |
|
445 | - */ |
|
442 | + /** |
|
443 | + * Retrieves the names of all parameters present in the URL, if any. |
|
444 | + * @return string[] |
|
445 | + */ |
|
446 | 446 | public function getParamNames() : array |
447 | 447 | { |
448 | 448 | $params = $this->getParams(); |
449 | 449 | return array_keys($params); |
450 | 450 | } |
451 | 451 | |
452 | - /** |
|
453 | - * Retrieves a specific parameter value from the URL. |
|
454 | - * |
|
455 | - * @param string $name |
|
456 | - * @return string The parameter value, or an empty string if it does not exist. |
|
457 | - */ |
|
452 | + /** |
|
453 | + * Retrieves a specific parameter value from the URL. |
|
454 | + * |
|
455 | + * @param string $name |
|
456 | + * @return string The parameter value, or an empty string if it does not exist. |
|
457 | + */ |
|
458 | 458 | public function getParam(string $name) : string |
459 | 459 | { |
460 | 460 | return $this->info['params'][$name] ?? ''; |
461 | 461 | } |
462 | 462 | |
463 | - /** |
|
464 | - * Excludes a URL parameter entirely if present: |
|
465 | - * the parser will act as if the parameter was not |
|
466 | - * even present in the source URL, effectively |
|
467 | - * stripping it. |
|
468 | - * |
|
469 | - * @param string $name |
|
470 | - * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
|
471 | - * @return URLInfo |
|
472 | - */ |
|
463 | + /** |
|
464 | + * Excludes a URL parameter entirely if present: |
|
465 | + * the parser will act as if the parameter was not |
|
466 | + * even present in the source URL, effectively |
|
467 | + * stripping it. |
|
468 | + * |
|
469 | + * @param string $name |
|
470 | + * @param string $reason A human-readable explanation why this is excluded - used when highlighting links. |
|
471 | + * @return URLInfo |
|
472 | + */ |
|
473 | 473 | public function excludeParam(string $name, string $reason='') : URLInfo |
474 | 474 | { |
475 | 475 | if(!isset($this->excludedParams[$name])) |
@@ -522,14 +522,14 @@ discard block |
||
522 | 522 | return self::$typeLabels[$this->getType()]; |
523 | 523 | } |
524 | 524 | |
525 | - /** |
|
526 | - * Whether excluded parameters should be highlighted in |
|
527 | - * a different color in the URL when using the |
|
528 | - * {@link URLInfo::getHighlighted()} method. |
|
529 | - * |
|
530 | - * @param bool $highlight |
|
531 | - * @return URLInfo |
|
532 | - */ |
|
525 | + /** |
|
526 | + * Whether excluded parameters should be highlighted in |
|
527 | + * a different color in the URL when using the |
|
528 | + * {@link URLInfo::getHighlighted()} method. |
|
529 | + * |
|
530 | + * @param bool $highlight |
|
531 | + * @return URLInfo |
|
532 | + */ |
|
533 | 533 | public function setHighlightExcluded(bool $highlight=true) : URLInfo |
534 | 534 | { |
535 | 535 | $this->highlightExcluded = $highlight; |
@@ -585,24 +585,24 @@ discard block |
||
585 | 585 | return $this; |
586 | 586 | } |
587 | 587 | |
588 | - /** |
|
589 | - * Whether the parameter exclusion mode is enabled: |
|
590 | - * In this case, if any parameters have been added to the |
|
591 | - * exclusion list, all relevant methods will exclude these. |
|
592 | - * |
|
593 | - * @return bool |
|
594 | - */ |
|
588 | + /** |
|
589 | + * Whether the parameter exclusion mode is enabled: |
|
590 | + * In this case, if any parameters have been added to the |
|
591 | + * exclusion list, all relevant methods will exclude these. |
|
592 | + * |
|
593 | + * @return bool |
|
594 | + */ |
|
595 | 595 | public function isParamExclusionEnabled() : bool |
596 | 596 | { |
597 | 597 | return $this->paramExclusion; |
598 | 598 | } |
599 | 599 | |
600 | - /** |
|
601 | - * Checks whether the link contains any parameters that |
|
602 | - * are on the list of excluded parameters. |
|
603 | - * |
|
604 | - * @return bool |
|
605 | - */ |
|
600 | + /** |
|
601 | + * Checks whether the link contains any parameters that |
|
602 | + * are on the list of excluded parameters. |
|
603 | + * |
|
604 | + * @return bool |
|
605 | + */ |
|
606 | 606 | public function containsExcludedParams() : bool |
607 | 607 | { |
608 | 608 | if(empty($this->excludedParams)) { |
@@ -690,26 +690,26 @@ discard block |
||
690 | 690 | ->canConnect(); |
691 | 691 | } |
692 | 692 | |
693 | - /** |
|
694 | - * Creates the connection tester instance that is used |
|
695 | - * to check if a URL can be connected to, and which is |
|
696 | - * used in the {@see URLInfo::tryConnect()} method. It |
|
697 | - * allows more settings to be used. |
|
698 | - * |
|
699 | - * @return URIConnectionTester |
|
700 | - */ |
|
693 | + /** |
|
694 | + * Creates the connection tester instance that is used |
|
695 | + * to check if a URL can be connected to, and which is |
|
696 | + * used in the {@see URLInfo::tryConnect()} method. It |
|
697 | + * allows more settings to be used. |
|
698 | + * |
|
699 | + * @return URIConnectionTester |
|
700 | + */ |
|
701 | 701 | public function createConnectionTester() : URIConnectionTester |
702 | 702 | { |
703 | 703 | return new URIConnectionTester($this); |
704 | 704 | } |
705 | 705 | |
706 | - /** |
|
707 | - * Adds/overwrites a URL parameter. |
|
708 | - * |
|
709 | - * @param string $name |
|
710 | - * @param string $val |
|
711 | - * @return URLInfo |
|
712 | - */ |
|
706 | + /** |
|
707 | + * Adds/overwrites a URL parameter. |
|
708 | + * |
|
709 | + * @param string $name |
|
710 | + * @param string $val |
|
711 | + * @return URLInfo |
|
712 | + */ |
|
713 | 713 | public function setParam(string $name, string $val) : URLInfo |
714 | 714 | { |
715 | 715 | $this->info['params'][$name] = $val; |
@@ -717,13 +717,13 @@ discard block |
||
717 | 717 | return $this; |
718 | 718 | } |
719 | 719 | |
720 | - /** |
|
721 | - * Removes a URL parameter. Has no effect if the |
|
722 | - * parameter is not present to begin with. |
|
723 | - * |
|
724 | - * @param string $param |
|
725 | - * @return URLInfo |
|
726 | - */ |
|
720 | + /** |
|
721 | + * Removes a URL parameter. Has no effect if the |
|
722 | + * parameter is not present to begin with. |
|
723 | + * |
|
724 | + * @param string $param |
|
725 | + * @return URLInfo |
|
726 | + */ |
|
727 | 727 | public function removeParam(string $param) : URLInfo |
728 | 728 | { |
729 | 729 | if(isset($this->info['params'][$param])) |
@@ -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); |