@@ -73,18 +73,18 @@ discard block |
||
73 | 73 | public const ERROR_PATH_NOT_WRITABLE = 340039; |
74 | 74 | public const ERROR_PATH_INVALID = 340040; |
75 | 75 | |
76 | - /** |
|
77 | - * Opens a serialized file and returns the unserialized data. |
|
78 | - * |
|
79 | - * @param string $file |
|
80 | - * @throws FileHelper_Exception |
|
81 | - * @return array<int|string,mixed> |
|
82 | - * @see SerializedFile::parse() |
|
83 | - * |
|
84 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
85 | - * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ |
|
86 | - * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED |
|
87 | - */ |
|
76 | + /** |
|
77 | + * Opens a serialized file and returns the unserialized data. |
|
78 | + * |
|
79 | + * @param string $file |
|
80 | + * @throws FileHelper_Exception |
|
81 | + * @return array<int|string,mixed> |
|
82 | + * @see SerializedFile::parse() |
|
83 | + * |
|
84 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
85 | + * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ |
|
86 | + * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED |
|
87 | + */ |
|
88 | 88 | public static function parseSerializedFile(string $file) : array |
89 | 89 | { |
90 | 90 | return SerializedFile::factory(self::getFileInfo($file)) |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | return FolderTree::delete($rootFolder); |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Create a folder, if it does not exist yet. |
|
109 | - * |
|
110 | - * @param string|PathInfoInterface $path |
|
111 | - * @throws FileHelper_Exception |
|
112 | - * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
113 | - */ |
|
107 | + /** |
|
108 | + * Create a folder, if it does not exist yet. |
|
109 | + * |
|
110 | + * @param string|PathInfoInterface $path |
|
111 | + * @throws FileHelper_Exception |
|
112 | + * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
113 | + */ |
|
114 | 114 | public static function createFolder($path) : FolderInfo |
115 | 115 | { |
116 | 116 | return self::getFolderInfo($path)->create(); |
@@ -138,36 +138,36 @@ discard block |
||
138 | 138 | FolderTree::copy($source, $target); |
139 | 139 | } |
140 | 140 | |
141 | - /** |
|
142 | - * Copies a file to the target location. Includes checks |
|
143 | - * for most error sources, like the source file not being |
|
144 | - * readable. Automatically creates the target folder if it |
|
145 | - * does not exist yet. |
|
146 | - * |
|
147 | - * @param string $sourcePath |
|
148 | - * @param string $targetPath |
|
149 | - * @throws FileHelper_Exception |
|
150 | - * |
|
151 | - * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
152 | - * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND |
|
153 | - * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE |
|
154 | - * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE |
|
155 | - * @see FileHelper::ERROR_CANNOT_COPY_FILE |
|
156 | - */ |
|
141 | + /** |
|
142 | + * Copies a file to the target location. Includes checks |
|
143 | + * for most error sources, like the source file not being |
|
144 | + * readable. Automatically creates the target folder if it |
|
145 | + * does not exist yet. |
|
146 | + * |
|
147 | + * @param string $sourcePath |
|
148 | + * @param string $targetPath |
|
149 | + * @throws FileHelper_Exception |
|
150 | + * |
|
151 | + * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
152 | + * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND |
|
153 | + * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE |
|
154 | + * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE |
|
155 | + * @see FileHelper::ERROR_CANNOT_COPY_FILE |
|
156 | + */ |
|
157 | 157 | public static function copyFile(string $sourcePath, string $targetPath) : void |
158 | 158 | { |
159 | 159 | self::getFileInfo($sourcePath)->copyTo($targetPath); |
160 | 160 | } |
161 | 161 | |
162 | - /** |
|
163 | - * Deletes the target file. Ignored if it cannot be found, |
|
164 | - * and throws an exception if it fails. |
|
165 | - * |
|
166 | - * @param string $filePath |
|
167 | - * @throws FileHelper_Exception |
|
168 | - * |
|
169 | - * @see FileHelper::ERROR_CANNOT_DELETE_FILE |
|
170 | - */ |
|
162 | + /** |
|
163 | + * Deletes the target file. Ignored if it cannot be found, |
|
164 | + * and throws an exception if it fails. |
|
165 | + * |
|
166 | + * @param string $filePath |
|
167 | + * @throws FileHelper_Exception |
|
168 | + * |
|
169 | + * @see FileHelper::ERROR_CANNOT_DELETE_FILE |
|
170 | + */ |
|
171 | 171 | public static function deleteFile(string $filePath) : void |
172 | 172 | { |
173 | 173 | self::getFileInfo($filePath)->delete(); |
@@ -272,29 +272,29 @@ discard block |
||
272 | 272 | ->download(); |
273 | 273 | } |
274 | 274 | |
275 | - /** |
|
276 | - * Verifies whether the target file is a PHP file. The path |
|
277 | - * to the file can be a path to a file as a string, or a |
|
278 | - * DirectoryIterator object instance. |
|
279 | - * |
|
280 | - * @param string|DirectoryIterator $pathOrDirIterator |
|
281 | - * @return boolean |
|
282 | - */ |
|
275 | + /** |
|
276 | + * Verifies whether the target file is a PHP file. The path |
|
277 | + * to the file can be a path to a file as a string, or a |
|
278 | + * DirectoryIterator object instance. |
|
279 | + * |
|
280 | + * @param string|DirectoryIterator $pathOrDirIterator |
|
281 | + * @return boolean |
|
282 | + */ |
|
283 | 283 | public static function isPHPFile($pathOrDirIterator) : bool |
284 | 284 | { |
285 | - return self::getExtension($pathOrDirIterator) === 'php'; |
|
285 | + return self::getExtension($pathOrDirIterator) === 'php'; |
|
286 | 286 | } |
287 | 287 | |
288 | - /** |
|
289 | - * Retrieves the extension of the specified file. Can be a path |
|
290 | - * to a file as a string, or a DirectoryIterator object instance. |
|
291 | - * |
|
292 | - * NOTE: A folder will return an empty string. |
|
293 | - * |
|
294 | - * @param string|DirectoryIterator $pathOrDirIterator |
|
295 | - * @param bool $lowercase |
|
296 | - * @return string |
|
297 | - */ |
|
288 | + /** |
|
289 | + * Retrieves the extension of the specified file. Can be a path |
|
290 | + * to a file as a string, or a DirectoryIterator object instance. |
|
291 | + * |
|
292 | + * NOTE: A folder will return an empty string. |
|
293 | + * |
|
294 | + * @param string|DirectoryIterator $pathOrDirIterator |
|
295 | + * @param bool $lowercase |
|
296 | + * @return string |
|
297 | + */ |
|
298 | 298 | public static function getExtension($pathOrDirIterator, bool $lowercase = true) : string |
299 | 299 | { |
300 | 300 | $info = self::getPathInfo($pathOrDirIterator); |
@@ -307,18 +307,18 @@ discard block |
||
307 | 307 | return ''; |
308 | 308 | } |
309 | 309 | |
310 | - /** |
|
311 | - * Retrieves the file name from a path, with or without extension. |
|
312 | - * The path to the file can be a string, or a DirectoryIterator object |
|
313 | - * instance. |
|
314 | - * |
|
315 | - * In case of folders, behaves like the "pathinfo" function: returns |
|
316 | - * the name of the folder. |
|
317 | - * |
|
318 | - * @param string|DirectoryIterator $pathOrDirIterator |
|
319 | - * @param bool $extension |
|
320 | - * @return string |
|
321 | - */ |
|
310 | + /** |
|
311 | + * Retrieves the file name from a path, with or without extension. |
|
312 | + * The path to the file can be a string, or a DirectoryIterator object |
|
313 | + * instance. |
|
314 | + * |
|
315 | + * In case of folders, behaves like the "pathinfo" function: returns |
|
316 | + * the name of the folder. |
|
317 | + * |
|
318 | + * @param string|DirectoryIterator $pathOrDirIterator |
|
319 | + * @param bool $extension |
|
320 | + * @return string |
|
321 | + */ |
|
322 | 322 | public static function getFilename($pathOrDirIterator, bool $extension = true) : string |
323 | 323 | { |
324 | 324 | $info = self::getPathInfo($pathOrDirIterator); |
@@ -352,16 +352,16 @@ discard block |
||
352 | 352 | ->parse(); |
353 | 353 | } |
354 | 354 | |
355 | - /** |
|
356 | - * Corrects common formatting mistakes when users enter |
|
357 | - * file names, like too many spaces, dots and the like. |
|
358 | - * |
|
359 | - * NOTE: if the file name contains a path, the path is |
|
360 | - * stripped, leaving only the file name. |
|
361 | - * |
|
362 | - * @param string $name |
|
363 | - * @return string |
|
364 | - */ |
|
355 | + /** |
|
356 | + * Corrects common formatting mistakes when users enter |
|
357 | + * file names, like too many spaces, dots and the like. |
|
358 | + * |
|
359 | + * NOTE: if the file name contains a path, the path is |
|
360 | + * stripped, leaving only the file name. |
|
361 | + * |
|
362 | + * @param string $name |
|
363 | + * @return string |
|
364 | + */ |
|
365 | 365 | public static function fixFileName(string $name) : string |
366 | 366 | { |
367 | 367 | return NameFixer::fixName($name); |
@@ -421,23 +421,23 @@ discard block |
||
421 | 421 | return self::findFiles($targetFolder, array('php'), $options); |
422 | 422 | } |
423 | 423 | |
424 | - /** |
|
425 | - * Finds files according to the specified options. |
|
426 | - * |
|
427 | - * NOTE: This method only exists for backwards compatibility. |
|
428 | - * Use the {@see FileHelper::createFileFinder()} method instead, |
|
429 | - * which offers an object-oriented interface that is much easier |
|
430 | - * to use. |
|
431 | - * |
|
432 | - * @param string|PathInfoInterface|DirectoryIterator $targetFolder |
|
433 | - * @param string[] $extensions |
|
434 | - * @param array<string,mixed> $options |
|
435 | - * @throws FileHelper_Exception |
|
436 | - * @return string[] |
|
437 | - * |
|
438 | - * @see FileHelper::createFileFinder() |
|
439 | - * @deprecated Use the file finder instead. |
|
440 | - */ |
|
424 | + /** |
|
425 | + * Finds files according to the specified options. |
|
426 | + * |
|
427 | + * NOTE: This method only exists for backwards compatibility. |
|
428 | + * Use the {@see FileHelper::createFileFinder()} method instead, |
|
429 | + * which offers an object-oriented interface that is much easier |
|
430 | + * to use. |
|
431 | + * |
|
432 | + * @param string|PathInfoInterface|DirectoryIterator $targetFolder |
|
433 | + * @param string[] $extensions |
|
434 | + * @param array<string,mixed> $options |
|
435 | + * @throws FileHelper_Exception |
|
436 | + * @return string[] |
|
437 | + * |
|
438 | + * @see FileHelper::createFileFinder() |
|
439 | + * @deprecated Use the file finder instead. |
|
440 | + */ |
|
441 | 441 | public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array |
442 | 442 | { |
443 | 443 | $finder = self::createFileFinder($targetFolder); |
@@ -467,14 +467,14 @@ discard block |
||
467 | 467 | return $finder->getAll(); |
468 | 468 | } |
469 | 469 | |
470 | - /** |
|
471 | - * Removes the extension from the specified path or file name, |
|
472 | - * if any, and returns the name without the extension. |
|
473 | - * |
|
474 | - * @param string $filename |
|
475 | - * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to. |
|
476 | - * @return string |
|
477 | - */ |
|
470 | + /** |
|
471 | + * Removes the extension from the specified path or file name, |
|
472 | + * if any, and returns the name without the extension. |
|
473 | + * |
|
474 | + * @param string $filename |
|
475 | + * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to. |
|
476 | + * @return string |
|
477 | + */ |
|
478 | 478 | public static function removeExtension(string $filename, bool $keepPath=false) : string |
479 | 479 | { |
480 | 480 | return self::getFileInfo($filename)->removeExtension($keepPath); |
@@ -495,49 +495,49 @@ discard block |
||
495 | 495 | return self::$unicodeHandling; |
496 | 496 | } |
497 | 497 | |
498 | - /** |
|
499 | - * Normalizes the slash style in a file or folder path, |
|
500 | - * by replacing any anti-slashes with forward slashes. |
|
501 | - * |
|
502 | - * @param string $path |
|
503 | - * @return string |
|
504 | - */ |
|
498 | + /** |
|
499 | + * Normalizes the slash style in a file or folder path, |
|
500 | + * by replacing any anti-slashes with forward slashes. |
|
501 | + * |
|
502 | + * @param string $path |
|
503 | + * @return string |
|
504 | + */ |
|
505 | 505 | public static function normalizePath(string $path) : string |
506 | 506 | { |
507 | 507 | return str_replace(array('\\', '//'), array('/', '/'), $path); |
508 | 508 | } |
509 | 509 | |
510 | - /** |
|
511 | - * Saves the specified data to a file, JSON encoded. |
|
512 | - * |
|
513 | - * @param mixed $data |
|
514 | - * @param string $file |
|
515 | - * @param bool $pretty |
|
516 | - * @throws FileHelper_Exception |
|
517 | - * |
|
518 | - * @see FileHelper::ERROR_JSON_ENCODE_ERROR |
|
519 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
520 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
521 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
522 | - */ |
|
510 | + /** |
|
511 | + * Saves the specified data to a file, JSON encoded. |
|
512 | + * |
|
513 | + * @param mixed $data |
|
514 | + * @param string $file |
|
515 | + * @param bool $pretty |
|
516 | + * @throws FileHelper_Exception |
|
517 | + * |
|
518 | + * @see FileHelper::ERROR_JSON_ENCODE_ERROR |
|
519 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
520 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
521 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
522 | + */ |
|
523 | 523 | public static function saveAsJSON($data, string $file, bool $pretty=false) : void |
524 | 524 | { |
525 | 525 | JSONFile::factory(self::getFileInfo($file)) |
526 | 526 | ->putData($data, $pretty); |
527 | 527 | } |
528 | 528 | |
529 | - /** |
|
530 | - * Saves the specified content to the target file, creating |
|
531 | - * the file and the folder as necessary. |
|
532 | - * |
|
533 | - * @param string $filePath |
|
534 | - * @param string $content |
|
535 | - * @throws FileHelper_Exception |
|
536 | - * |
|
537 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
538 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
539 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
540 | - */ |
|
529 | + /** |
|
530 | + * Saves the specified content to the target file, creating |
|
531 | + * the file and the folder as necessary. |
|
532 | + * |
|
533 | + * @param string $filePath |
|
534 | + * @param string $content |
|
535 | + * @throws FileHelper_Exception |
|
536 | + * |
|
537 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
538 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
539 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
540 | + */ |
|
541 | 541 | public static function saveFile(string $filePath, string $content='') : void |
542 | 542 | { |
543 | 543 | self::getFileInfo($filePath)->putContents($content); |
@@ -602,14 +602,14 @@ discard block |
||
602 | 602 | return $output; |
603 | 603 | } |
604 | 604 | |
605 | - /** |
|
606 | - * Retrieves the last modified date for the specified file or folder. |
|
607 | - * |
|
608 | - * Note: If the target does not exist, returns null. |
|
609 | - * |
|
610 | - * @param string $path |
|
611 | - * @return DateTime|NULL |
|
612 | - */ |
|
605 | + /** |
|
606 | + * Retrieves the last modified date for the specified file or folder. |
|
607 | + * |
|
608 | + * Note: If the target does not exist, returns null. |
|
609 | + * |
|
610 | + * @param string $path |
|
611 | + * @return DateTime|NULL |
|
612 | + */ |
|
613 | 613 | public static function getModifiedDate(string $path) : ?DateTime |
614 | 614 | { |
615 | 615 | $time = filemtime($path); |
@@ -649,70 +649,70 @@ discard block |
||
649 | 649 | ->getPaths(); |
650 | 650 | } |
651 | 651 | |
652 | - /** |
|
653 | - * Retrieves the maximum allowed upload file size, in bytes. |
|
654 | - * Takes into account the PHP ini settings <code>post_max_size</code> |
|
655 | - * and <code>upload_max_filesize</code>. Since these cannot |
|
656 | - * be modified at runtime, they are the hard limits for uploads. |
|
657 | - * |
|
658 | - * NOTE: Based on binary values, where 1KB = 1024 Bytes. |
|
659 | - * |
|
660 | - * @return int Will return <code>-1</code> if no limit. |
|
661 | - */ |
|
652 | + /** |
|
653 | + * Retrieves the maximum allowed upload file size, in bytes. |
|
654 | + * Takes into account the PHP ini settings <code>post_max_size</code> |
|
655 | + * and <code>upload_max_filesize</code>. Since these cannot |
|
656 | + * be modified at runtime, they are the hard limits for uploads. |
|
657 | + * |
|
658 | + * NOTE: Based on binary values, where 1KB = 1024 Bytes. |
|
659 | + * |
|
660 | + * @return int Will return <code>-1</code> if no limit. |
|
661 | + */ |
|
662 | 662 | public static function getMaxUploadFilesize() : int |
663 | 663 | { |
664 | 664 | return UploadFileSizeInfo::getFileSize(); |
665 | 665 | } |
666 | 666 | |
667 | - /** |
|
668 | - * Makes a path relative using a folder depth: will reduce the |
|
669 | - * length of the path so that only the amount of folders defined |
|
670 | - * in the <code>$depth</code> attribute are shown below the actual |
|
671 | - * folder or file in the path. |
|
672 | - * |
|
673 | - * @param string $path The absolute or relative path |
|
674 | - * @param int $depth The folder depth to reduce the path to |
|
675 | - * @return string |
|
676 | - */ |
|
667 | + /** |
|
668 | + * Makes a path relative using a folder depth: will reduce the |
|
669 | + * length of the path so that only the amount of folders defined |
|
670 | + * in the <code>$depth</code> attribute are shown below the actual |
|
671 | + * folder or file in the path. |
|
672 | + * |
|
673 | + * @param string $path The absolute or relative path |
|
674 | + * @param int $depth The folder depth to reduce the path to |
|
675 | + * @return string |
|
676 | + */ |
|
677 | 677 | public static function relativizePathByDepth(string $path, int $depth=2) : string |
678 | 678 | { |
679 | 679 | return PathRelativizer::relativizeByDepth($path, $depth); |
680 | 680 | } |
681 | 681 | |
682 | - /** |
|
683 | - * Makes the specified path relative to another path, |
|
684 | - * by removing one from the other if found. Also |
|
685 | - * normalizes the path to use forward slashes. |
|
686 | - * |
|
687 | - * Example: |
|
688 | - * |
|
689 | - * <pre> |
|
690 | - * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder'); |
|
691 | - * </pre> |
|
692 | - * |
|
693 | - * Result: <code>to/file.txt</code> |
|
694 | - * |
|
695 | - * @param string $path |
|
696 | - * @param string $relativeTo |
|
697 | - * @return string |
|
698 | - */ |
|
682 | + /** |
|
683 | + * Makes the specified path relative to another path, |
|
684 | + * by removing one from the other if found. Also |
|
685 | + * normalizes the path to use forward slashes. |
|
686 | + * |
|
687 | + * Example: |
|
688 | + * |
|
689 | + * <pre> |
|
690 | + * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder'); |
|
691 | + * </pre> |
|
692 | + * |
|
693 | + * Result: <code>to/file.txt</code> |
|
694 | + * |
|
695 | + * @param string $path |
|
696 | + * @param string $relativeTo |
|
697 | + * @return string |
|
698 | + */ |
|
699 | 699 | public static function relativizePath(string $path, string $relativeTo) : string |
700 | 700 | { |
701 | 701 | return PathRelativizer::relativize($path, $relativeTo); |
702 | 702 | } |
703 | 703 | |
704 | - /** |
|
705 | - * Checks that the target file exists, and throws an exception |
|
706 | - * if it does not. |
|
707 | - * |
|
708 | - * @param string|DirectoryIterator $path |
|
709 | - * @param int|NULL $errorCode Optional custom error code |
|
710 | - * @throws FileHelper_Exception |
|
711 | - * @return string The real path to the file |
|
712 | - * |
|
713 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
714 | - * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
|
715 | - */ |
|
704 | + /** |
|
705 | + * Checks that the target file exists, and throws an exception |
|
706 | + * if it does not. |
|
707 | + * |
|
708 | + * @param string|DirectoryIterator $path |
|
709 | + * @param int|NULL $errorCode Optional custom error code |
|
710 | + * @throws FileHelper_Exception |
|
711 | + * @return string The real path to the file |
|
712 | + * |
|
713 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
714 | + * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
|
715 | + */ |
|
716 | 716 | public static function requireFileExists($path, ?int $errorCode=null) : string |
717 | 717 | { |
718 | 718 | return self::getPathInfo($path) |
@@ -735,18 +735,18 @@ discard block |
||
735 | 735 | ->getPath(); |
736 | 736 | } |
737 | 737 | |
738 | - /** |
|
739 | - * Reads a specific line number from the target file and returns its |
|
740 | - * contents, if the file has such a line. Does so with little memory |
|
741 | - * usage, as the file is not read entirely into memory. |
|
742 | - * |
|
743 | - * @param string $path |
|
744 | - * @param int $lineNumber Note: 1-based; the first line is number 1. |
|
745 | - * @return string|NULL Will return null if the requested line does not exist. |
|
746 | - * @throws FileHelper_Exception |
|
747 | - * |
|
748 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
749 | - */ |
|
738 | + /** |
|
739 | + * Reads a specific line number from the target file and returns its |
|
740 | + * contents, if the file has such a line. Does so with little memory |
|
741 | + * usage, as the file is not read entirely into memory. |
|
742 | + * |
|
743 | + * @param string $path |
|
744 | + * @param int $lineNumber Note: 1-based; the first line is number 1. |
|
745 | + * @return string|NULL Will return null if the requested line does not exist. |
|
746 | + * @throws FileHelper_Exception |
|
747 | + * |
|
748 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
749 | + */ |
|
750 | 750 | public static function getLineFromFile(string $path, int $lineNumber) : ?string |
751 | 751 | { |
752 | 752 | return self::getFileInfo($path) |
@@ -823,33 +823,33 @@ discard block |
||
823 | 823 | ->getLines($amount); |
824 | 824 | } |
825 | 825 | |
826 | - /** |
|
827 | - * Reads all content from a file. |
|
828 | - * |
|
829 | - * @param string $filePath |
|
830 | - * @throws FileHelper_Exception |
|
831 | - * @return string |
|
832 | - * |
|
833 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
834 | - * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
835 | - */ |
|
826 | + /** |
|
827 | + * Reads all content from a file. |
|
828 | + * |
|
829 | + * @param string $filePath |
|
830 | + * @throws FileHelper_Exception |
|
831 | + * @return string |
|
832 | + * |
|
833 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
834 | + * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
835 | + */ |
|
836 | 836 | public static function readContents(string $filePath) : string |
837 | 837 | { |
838 | 838 | return self::getFileInfo($filePath)->getContents(); |
839 | 839 | } |
840 | 840 | |
841 | - /** |
|
842 | - * Ensures that the target path exists on disk, and is a folder. |
|
843 | - * |
|
844 | - * @param string $path |
|
845 | - * @return string The real path, with normalized slashes. |
|
846 | - * @throws FileHelper_Exception |
|
847 | - * |
|
848 | - * @see FileHelper::normalizePath() |
|
849 | - * |
|
850 | - * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST |
|
851 | - * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
852 | - */ |
|
841 | + /** |
|
842 | + * Ensures that the target path exists on disk, and is a folder. |
|
843 | + * |
|
844 | + * @param string $path |
|
845 | + * @return string The real path, with normalized slashes. |
|
846 | + * @throws FileHelper_Exception |
|
847 | + * |
|
848 | + * @see FileHelper::normalizePath() |
|
849 | + * |
|
850 | + * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST |
|
851 | + * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
852 | + */ |
|
853 | 853 | public static function requireFolderExists(string $path) : string |
854 | 854 | { |
855 | 855 | return self::getFolderInfo($path) |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | return ConvertHelper_String::tabs2spaces($string, $tabSize); |
61 | 61 | } |
62 | 62 | |
63 | - /** |
|
64 | - * Converts spaces to tabs in the specified string. |
|
65 | - * |
|
66 | - * @param string $string |
|
67 | - * @param int $tabSize The amount of spaces per tab in the source string. |
|
68 | - * @return string |
|
69 | - */ |
|
63 | + /** |
|
64 | + * Converts spaces to tabs in the specified string. |
|
65 | + * |
|
66 | + * @param string $string |
|
67 | + * @param int $tabSize The amount of spaces per tab in the source string. |
|
68 | + * @return string |
|
69 | + */ |
|
70 | 70 | public static function spaces2tabs(string $string, int $tabSize=4) : string |
71 | 71 | { |
72 | 72 | return ConvertHelper_String::spaces2tabs($string, $tabSize); |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | return ConvertHelper_String::hidden2visible($string); |
85 | 85 | } |
86 | 86 | |
87 | - /** |
|
88 | - * Converts the specified amount of seconds into |
|
89 | - * a human-readable string split in months, weeks, |
|
90 | - * days, hours, minutes and seconds. |
|
91 | - * |
|
92 | - * @param float $seconds |
|
93 | - * @return string |
|
94 | - */ |
|
87 | + /** |
|
88 | + * Converts the specified amount of seconds into |
|
89 | + * a human-readable string split in months, weeks, |
|
90 | + * days, hours, minutes and seconds. |
|
91 | + * |
|
92 | + * @param float $seconds |
|
93 | + * @return string |
|
94 | + */ |
|
95 | 95 | public static function time2string($seconds) : string |
96 | 96 | { |
97 | 97 | $converter = new ConvertHelper_TimeConverter($seconds); |
@@ -115,85 +115,85 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public static function duration2string($datefrom, $dateto = -1) : string |
117 | 117 | { |
118 | - return ConvertHelper_DurationConverter::toString($datefrom, $dateto); |
|
118 | + return ConvertHelper_DurationConverter::toString($datefrom, $dateto); |
|
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Adds HTML syntax highlighting to the specified SQL string. |
|
123 | - * |
|
124 | - * @param string $sql |
|
125 | - * @return string |
|
126 | - * @deprecated Use the Highlighter class directly instead. |
|
127 | - * @see Highlighter::sql() |
|
128 | - */ |
|
121 | + /** |
|
122 | + * Adds HTML syntax highlighting to the specified SQL string. |
|
123 | + * |
|
124 | + * @param string $sql |
|
125 | + * @return string |
|
126 | + * @deprecated Use the Highlighter class directly instead. |
|
127 | + * @see Highlighter::sql() |
|
128 | + */ |
|
129 | 129 | public static function highlight_sql(string $sql) : string |
130 | 130 | { |
131 | 131 | return Highlighter::sql($sql); |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Adds HTML syntax highlighting to the specified XML code. |
|
136 | - * |
|
137 | - * @param string $xml The XML to highlight. |
|
138 | - * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
139 | - * @return string |
|
140 | - * @deprecated Use the Highlighter class directly instead. |
|
141 | - * @see Highlighter::xml() |
|
142 | - */ |
|
134 | + /** |
|
135 | + * Adds HTML syntax highlighting to the specified XML code. |
|
136 | + * |
|
137 | + * @param string $xml The XML to highlight. |
|
138 | + * @param bool $formatSource Whether to format the source with indentation to make it readable. |
|
139 | + * @return string |
|
140 | + * @deprecated Use the Highlighter class directly instead. |
|
141 | + * @see Highlighter::xml() |
|
142 | + */ |
|
143 | 143 | public static function highlight_xml(string $xml, bool $formatSource=false) : string |
144 | 144 | { |
145 | 145 | return Highlighter::xml($xml, $formatSource); |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * @param string $phpCode |
|
150 | - * @return string |
|
151 | - * @deprecated Use the Highlighter class directly instead. |
|
152 | - * @see Highlighter::php() |
|
153 | - */ |
|
148 | + /** |
|
149 | + * @param string $phpCode |
|
150 | + * @return string |
|
151 | + * @deprecated Use the Highlighter class directly instead. |
|
152 | + * @see Highlighter::php() |
|
153 | + */ |
|
154 | 154 | public static function highlight_php(string $phpCode) : string |
155 | 155 | { |
156 | 156 | return Highlighter::php($phpCode); |
157 | 157 | } |
158 | 158 | |
159 | - /** |
|
160 | - * Converts a number of bytes to a human-readable form, |
|
161 | - * e.g. xx Kb / xx Mb / xx Gb |
|
162 | - * |
|
163 | - * @param int $bytes The amount of bytes to convert. |
|
164 | - * @param int $precision The amount of decimals |
|
165 | - * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB). |
|
166 | - * @return string |
|
167 | - * |
|
168 | - * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
169 | - */ |
|
159 | + /** |
|
160 | + * Converts a number of bytes to a human-readable form, |
|
161 | + * e.g. xx Kb / xx Mb / xx Gb |
|
162 | + * |
|
163 | + * @param int $bytes The amount of bytes to convert. |
|
164 | + * @param int $precision The amount of decimals |
|
165 | + * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB). |
|
166 | + * @return string |
|
167 | + * |
|
168 | + * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions |
|
169 | + */ |
|
170 | 170 | public static function bytes2readable(int $bytes, int $precision = 1, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string |
171 | 171 | { |
172 | 172 | return self::parseBytes($bytes)->toString($precision, $base); |
173 | 173 | } |
174 | 174 | |
175 | - /** |
|
176 | - * Parses a number of bytes, and creates a converter instance which |
|
177 | - * allows doing common operations with it. |
|
178 | - * |
|
179 | - * @param int $bytes |
|
180 | - * @return ConvertHelper_ByteConverter |
|
181 | - */ |
|
175 | + /** |
|
176 | + * Parses a number of bytes, and creates a converter instance which |
|
177 | + * allows doing common operations with it. |
|
178 | + * |
|
179 | + * @param int $bytes |
|
180 | + * @return ConvertHelper_ByteConverter |
|
181 | + */ |
|
182 | 182 | public static function parseBytes(int $bytes) : ConvertHelper_ByteConverter |
183 | 183 | { |
184 | 184 | return new ConvertHelper_ByteConverter($bytes); |
185 | 185 | } |
186 | 186 | |
187 | - /** |
|
188 | - * Cuts a text to the specified length if it is longer than the |
|
189 | - * target length. Appends a text to signify it has been cut at |
|
190 | - * the end of the string. |
|
191 | - * |
|
192 | - * @param string $text |
|
193 | - * @param int $targetLength |
|
194 | - * @param string $append |
|
195 | - * @return string |
|
196 | - */ |
|
187 | + /** |
|
188 | + * Cuts a text to the specified length if it is longer than the |
|
189 | + * target length. Appends a text to signify it has been cut at |
|
190 | + * the end of the string. |
|
191 | + * |
|
192 | + * @param string $text |
|
193 | + * @param int $targetLength |
|
194 | + * @param string $append |
|
195 | + * @return string |
|
196 | + */ |
|
197 | 197 | public static function text_cut(string $text, int $targetLength, string $append = '...') : string |
198 | 198 | { |
199 | 199 | return ConvertHelper_String::cutText($text, $targetLength, $append); |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | return $info->toString(); |
218 | 218 | } |
219 | 219 | |
220 | - /** |
|
221 | - * Pretty `print_r`. |
|
222 | - * |
|
223 | - * @param mixed $var The variable to dump. |
|
224 | - * @param bool $return Whether to return the dumped code. |
|
225 | - * @param bool $html Whether to style the dump as HTML. |
|
226 | - * @return string |
|
227 | - */ |
|
220 | + /** |
|
221 | + * Pretty `print_r`. |
|
222 | + * |
|
223 | + * @param mixed $var The variable to dump. |
|
224 | + * @param bool $return Whether to return the dumped code. |
|
225 | + * @param bool $html Whether to style the dump as HTML. |
|
226 | + * @return string |
|
227 | + */ |
|
228 | 228 | public static function print_r($var, bool $return=false, bool $html=true) : string |
229 | 229 | { |
230 | 230 | $result = parseVariable($var)->enableType()->toString(); |
@@ -245,29 +245,29 @@ discard block |
||
245 | 245 | return $result; |
246 | 246 | } |
247 | 247 | |
248 | - /** |
|
249 | - * Converts a string, number or boolean value to a boolean value. |
|
250 | - * |
|
251 | - * @param mixed $string |
|
252 | - * @throws ConvertHelper_Exception |
|
253 | - * @return bool |
|
254 | - * |
|
255 | - * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING |
|
256 | - */ |
|
248 | + /** |
|
249 | + * Converts a string, number or boolean value to a boolean value. |
|
250 | + * |
|
251 | + * @param mixed $string |
|
252 | + * @throws ConvertHelper_Exception |
|
253 | + * @return bool |
|
254 | + * |
|
255 | + * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING |
|
256 | + */ |
|
257 | 257 | public static function string2bool($string) : bool |
258 | 258 | { |
259 | 259 | return ConvertHelper_Bool::fromString($string); |
260 | 260 | } |
261 | 261 | |
262 | - /** |
|
263 | - * Whether the specified string is a boolean string or boolean value. |
|
264 | - * Alias for {@link ConvertHelper::isBoolean()}. |
|
265 | - * |
|
266 | - * @param mixed $string |
|
267 | - * @return bool |
|
268 | - * @deprecated |
|
269 | - * @see ConvertHelper::isBoolean() |
|
270 | - */ |
|
262 | + /** |
|
263 | + * Whether the specified string is a boolean string or boolean value. |
|
264 | + * Alias for {@link ConvertHelper::isBoolean()}. |
|
265 | + * |
|
266 | + * @param mixed $string |
|
267 | + * @return bool |
|
268 | + * @deprecated |
|
269 | + * @see ConvertHelper::isBoolean() |
|
270 | + */ |
|
271 | 271 | public static function isBooleanString($string) : bool |
272 | 272 | { |
273 | 273 | return self::isBoolean($string); |
@@ -337,36 +337,36 @@ discard block |
||
337 | 337 | return ConvertHelper_String::transliterate($string, $spaceChar, $lowercase); |
338 | 338 | } |
339 | 339 | |
340 | - /** |
|
341 | - * Retrieves the HEX character codes for all control |
|
342 | - * characters that the {@link stripControlCharacters()} |
|
343 | - * method will remove. |
|
344 | - * |
|
345 | - * @return string[] |
|
346 | - */ |
|
340 | + /** |
|
341 | + * Retrieves the HEX character codes for all control |
|
342 | + * characters that the {@link stripControlCharacters()} |
|
343 | + * method will remove. |
|
344 | + * |
|
345 | + * @return string[] |
|
346 | + */ |
|
347 | 347 | public static function getControlCharactersAsHex() : array |
348 | 348 | { |
349 | 349 | return self::createControlCharacters()->getCharsAsHex(); |
350 | 350 | } |
351 | 351 | |
352 | - /** |
|
353 | - * Retrieves an array of all control characters that |
|
354 | - * the {@link stripControlCharacters()} method will |
|
355 | - * remove, as the actual UTF-8 characters. |
|
356 | - * |
|
357 | - * @return string[] |
|
358 | - */ |
|
352 | + /** |
|
353 | + * Retrieves an array of all control characters that |
|
354 | + * the {@link stripControlCharacters()} method will |
|
355 | + * remove, as the actual UTF-8 characters. |
|
356 | + * |
|
357 | + * @return string[] |
|
358 | + */ |
|
359 | 359 | public static function getControlCharactersAsUTF8() : array |
360 | 360 | { |
361 | 361 | return self::createControlCharacters()->getCharsAsUTF8(); |
362 | 362 | } |
363 | 363 | |
364 | - /** |
|
365 | - * Retrieves all control characters as JSON encoded |
|
366 | - * characters, e.g. "\u200b". |
|
367 | - * |
|
368 | - * @return string[] |
|
369 | - */ |
|
364 | + /** |
|
365 | + * Retrieves all control characters as JSON encoded |
|
366 | + * characters, e.g. "\u200b". |
|
367 | + * |
|
368 | + * @return string[] |
|
369 | + */ |
|
370 | 370 | public static function getControlCharactersAsJSON() : array |
371 | 371 | { |
372 | 372 | return self::createControlCharacters()->getCharsAsJSON(); |
@@ -387,31 +387,31 @@ discard block |
||
387 | 387 | return self::createControlCharacters()->stripControlCharacters($string); |
388 | 388 | } |
389 | 389 | |
390 | - /** |
|
391 | - * Creates the control characters class, used to |
|
392 | - * work with control characters in strings. |
|
393 | - * |
|
394 | - * @return ConvertHelper_ControlCharacters |
|
395 | - */ |
|
390 | + /** |
|
391 | + * Creates the control characters class, used to |
|
392 | + * work with control characters in strings. |
|
393 | + * |
|
394 | + * @return ConvertHelper_ControlCharacters |
|
395 | + */ |
|
396 | 396 | public static function createControlCharacters() : ConvertHelper_ControlCharacters |
397 | 397 | { |
398 | 398 | return new ConvertHelper_ControlCharacters(); |
399 | 399 | } |
400 | 400 | |
401 | - /** |
|
402 | - * Converts a unicode character to the PHP notation. |
|
403 | - * |
|
404 | - * Example: |
|
405 | - * |
|
406 | - * <pre>unicodeChar2php('"\u0000"')</pre> |
|
407 | - * |
|
408 | - * Returns |
|
409 | - * |
|
410 | - * <pre>\x0</pre> |
|
411 | - * |
|
412 | - * @param string $unicodeChar |
|
413 | - * @return string |
|
414 | - */ |
|
401 | + /** |
|
402 | + * Converts a unicode character to the PHP notation. |
|
403 | + * |
|
404 | + * Example: |
|
405 | + * |
|
406 | + * <pre>unicodeChar2php('"\u0000"')</pre> |
|
407 | + * |
|
408 | + * Returns |
|
409 | + * |
|
410 | + * <pre>\x0</pre> |
|
411 | + * |
|
412 | + * @param string $unicodeChar |
|
413 | + * @return string |
|
414 | + */ |
|
415 | 415 | public static function unicodeChar2php(string $unicodeChar) : string |
416 | 416 | { |
417 | 417 | $unicodeChar = json_decode($unicodeChar); |
@@ -525,138 +525,138 @@ discard block |
||
525 | 525 | return ConvertHelper_Bool::toStringStrict($boolean, $yesNo); |
526 | 526 | } |
527 | 527 | |
528 | - /** |
|
529 | - * Converts an associative array with attribute name > value pairs |
|
530 | - * to an attribute string that can be used in an HTML tag. Empty |
|
531 | - * attribute values are ignored. |
|
532 | - * |
|
533 | - * Example: |
|
534 | - * |
|
535 | - * array2attributeString(array( |
|
536 | - * 'id' => 45, |
|
537 | - * 'href' => 'http://www.mistralys.com' |
|
538 | - * )); |
|
539 | - * |
|
540 | - * Result: |
|
541 | - * |
|
542 | - * id="45" href="http://www.mistralys.com" |
|
543 | - * |
|
544 | - * @param array<string,mixed> $array |
|
545 | - * @return string |
|
546 | - */ |
|
528 | + /** |
|
529 | + * Converts an associative array with attribute name > value pairs |
|
530 | + * to an attribute string that can be used in an HTML tag. Empty |
|
531 | + * attribute values are ignored. |
|
532 | + * |
|
533 | + * Example: |
|
534 | + * |
|
535 | + * array2attributeString(array( |
|
536 | + * 'id' => 45, |
|
537 | + * 'href' => 'http://www.mistralys.com' |
|
538 | + * )); |
|
539 | + * |
|
540 | + * Result: |
|
541 | + * |
|
542 | + * id="45" href="http://www.mistralys.com" |
|
543 | + * |
|
544 | + * @param array<string,mixed> $array |
|
545 | + * @return string |
|
546 | + */ |
|
547 | 547 | public static function array2attributeString(array $array) : string |
548 | 548 | { |
549 | 549 | return ConvertHelper_Array::toAttributeString($array); |
550 | 550 | } |
551 | 551 | |
552 | - /** |
|
553 | - * Converts a string, so it can safely be used in a javascript |
|
554 | - * statement in an HTML tag: uses single quotes around the string |
|
555 | - * and encodes all special characters as needed. |
|
556 | - * |
|
557 | - * @param string $string |
|
558 | - * @return string |
|
559 | - * @deprecated Use the JSHelper class instead. |
|
560 | - * @see JSHelper::phpVariable2AttributeJS() |
|
561 | - */ |
|
552 | + /** |
|
553 | + * Converts a string, so it can safely be used in a javascript |
|
554 | + * statement in an HTML tag: uses single quotes around the string |
|
555 | + * and encodes all special characters as needed. |
|
556 | + * |
|
557 | + * @param string $string |
|
558 | + * @return string |
|
559 | + * @deprecated Use the JSHelper class instead. |
|
560 | + * @see JSHelper::phpVariable2AttributeJS() |
|
561 | + */ |
|
562 | 562 | public static function string2attributeJS(string $string) : string |
563 | 563 | { |
564 | 564 | return JSHelper::phpVariable2AttributeJS($string); |
565 | 565 | } |
566 | 566 | |
567 | - /** |
|
568 | - * Checks if the specified string is a boolean value, which |
|
569 | - * includes string representations of boolean values, like |
|
570 | - * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
571 | - * or <code>false</code>. |
|
572 | - * |
|
573 | - * @param mixed $value |
|
574 | - * @return boolean |
|
575 | - */ |
|
567 | + /** |
|
568 | + * Checks if the specified string is a boolean value, which |
|
569 | + * includes string representations of boolean values, like |
|
570 | + * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
571 | + * or <code>false</code>. |
|
572 | + * |
|
573 | + * @param mixed $value |
|
574 | + * @return boolean |
|
575 | + */ |
|
576 | 576 | public static function isBoolean($value) : bool |
577 | 577 | { |
578 | 578 | return ConvertHelper_Bool::isBoolean($value); |
579 | 579 | } |
580 | 580 | |
581 | - /** |
|
582 | - * Converts an associative array to an HTML style attribute value string. |
|
583 | - * |
|
584 | - * @param array<string,mixed> $subject |
|
585 | - * @return string |
|
586 | - */ |
|
581 | + /** |
|
582 | + * Converts an associative array to an HTML style attribute value string. |
|
583 | + * |
|
584 | + * @param array<string,mixed> $subject |
|
585 | + * @return string |
|
586 | + */ |
|
587 | 587 | public static function array2styleString(array $subject) : string |
588 | 588 | { |
589 | 589 | return ConvertHelper_Array::toStyleString($subject); |
590 | 590 | } |
591 | 591 | |
592 | - /** |
|
593 | - * Converts a DateTime object to a timestamp, which |
|
594 | - * is PHP 5.2 compatible. |
|
595 | - * |
|
596 | - * @param DateTime $date |
|
597 | - * @return integer |
|
598 | - */ |
|
592 | + /** |
|
593 | + * Converts a DateTime object to a timestamp, which |
|
594 | + * is PHP 5.2 compatible. |
|
595 | + * |
|
596 | + * @param DateTime $date |
|
597 | + * @return integer |
|
598 | + */ |
|
599 | 599 | public static function date2timestamp(DateTime $date) : int |
600 | 600 | { |
601 | 601 | return ConvertHelper_Date::toTimestamp($date); |
602 | 602 | } |
603 | 603 | |
604 | - /** |
|
605 | - * Converts a timestamp into a DateTime instance. |
|
606 | - * @param int $timestamp |
|
607 | - * @return DateTime |
|
608 | - */ |
|
604 | + /** |
|
605 | + * Converts a timestamp into a DateTime instance. |
|
606 | + * @param int $timestamp |
|
607 | + * @return DateTime |
|
608 | + */ |
|
609 | 609 | public static function timestamp2date(int $timestamp) : DateTime |
610 | 610 | { |
611 | 611 | return ConvertHelper_Date::fromTimestamp($timestamp); |
612 | 612 | } |
613 | 613 | |
614 | - /** |
|
615 | - * Strips an absolute path to a file within the application |
|
616 | - * to make the path relative to the application root path. |
|
617 | - * |
|
618 | - * @param string $path |
|
619 | - * @return string |
|
620 | - * |
|
621 | - * @see FileHelper::relativizePath() |
|
622 | - * @see FileHelper::relativizePathByDepth() |
|
623 | - */ |
|
614 | + /** |
|
615 | + * Strips an absolute path to a file within the application |
|
616 | + * to make the path relative to the application root path. |
|
617 | + * |
|
618 | + * @param string $path |
|
619 | + * @return string |
|
620 | + * |
|
621 | + * @see FileHelper::relativizePath() |
|
622 | + * @see FileHelper::relativizePathByDepth() |
|
623 | + */ |
|
624 | 624 | public static function fileRelativize(string $path) : string |
625 | 625 | { |
626 | 626 | return FileHelper::relativizePathByDepth($path); |
627 | 627 | } |
628 | 628 | |
629 | 629 | /** |
630 | - * Converts a PHP regex to a javascript RegExp object statement. |
|
631 | - * |
|
632 | - * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
633 | - * More details are available on its usage there. |
|
634 | - * |
|
635 | - * @param string $regex A PHP preg regex |
|
636 | - * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
637 | - * @return string Depending on the specified return type. |
|
638 | - * |
|
639 | - * @see JSHelper::buildRegexStatement() |
|
640 | - */ |
|
630 | + * Converts a PHP regex to a javascript RegExp object statement. |
|
631 | + * |
|
632 | + * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
633 | + * More details are available on its usage there. |
|
634 | + * |
|
635 | + * @param string $regex A PHP preg regex |
|
636 | + * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
637 | + * @return string Depending on the specified return type. |
|
638 | + * |
|
639 | + * @see JSHelper::buildRegexStatement() |
|
640 | + */ |
|
641 | 641 | public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string |
642 | 642 | { |
643 | 643 | return JSHelper::buildRegexStatement($regex, $statementType); |
644 | 644 | } |
645 | 645 | |
646 | - /** |
|
647 | - * Converts the specified variable to JSON. Works just |
|
648 | - * like the native `json_encode` method, except that it |
|
649 | - * will trigger an exception on failure, which has the |
|
650 | - * json error details included in its developer details. |
|
651 | - * |
|
652 | - * @param mixed $variable |
|
653 | - * @param int $options JSON encode options. |
|
654 | - * @param int $depth |
|
655 | - * @return string |
|
656 | - * |
|
657 | - * @throws ConvertHelper_Exception |
|
658 | - * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
|
659 | - */ |
|
646 | + /** |
|
647 | + * Converts the specified variable to JSON. Works just |
|
648 | + * like the native `json_encode` method, except that it |
|
649 | + * will trigger an exception on failure, which has the |
|
650 | + * json error details included in its developer details. |
|
651 | + * |
|
652 | + * @param mixed $variable |
|
653 | + * @param int $options JSON encode options. |
|
654 | + * @param int $depth |
|
655 | + * @return string |
|
656 | + * |
|
657 | + * @throws ConvertHelper_Exception |
|
658 | + * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
|
659 | + */ |
|
660 | 660 | public static function var2json($variable, int $options=0, int $depth=512) : string |
661 | 661 | { |
662 | 662 | $result = json_encode($variable, $options, $depth); |
@@ -691,12 +691,12 @@ discard block |
||
691 | 691 | ->toString(); |
692 | 692 | } |
693 | 693 | |
694 | - /** |
|
695 | - * Strips all known UTF byte order marks from the specified string. |
|
696 | - * |
|
697 | - * @param string $string |
|
698 | - * @return string |
|
699 | - */ |
|
694 | + /** |
|
695 | + * Strips all known UTF byte order marks from the specified string. |
|
696 | + * |
|
697 | + * @param string $string |
|
698 | + * @return string |
|
699 | + */ |
|
700 | 700 | public static function stripUTFBom(string $string) : string |
701 | 701 | { |
702 | 702 | $boms = FileHelper::createUnicodeHandling()->getUTFBOMs(); |
@@ -715,69 +715,69 @@ discard block |
||
715 | 715 | return $string; |
716 | 716 | } |
717 | 717 | |
718 | - /** |
|
719 | - * Converts a string to valid utf8, regardless |
|
720 | - * of the string's encoding(s). |
|
721 | - * |
|
722 | - * @param string $string |
|
723 | - * @return string |
|
724 | - */ |
|
718 | + /** |
|
719 | + * Converts a string to valid utf8, regardless |
|
720 | + * of the string's encoding(s). |
|
721 | + * |
|
722 | + * @param string $string |
|
723 | + * @return string |
|
724 | + */ |
|
725 | 725 | public static function string2utf8(string $string) : string |
726 | 726 | { |
727 | 727 | return ConvertHelper_String::toUtf8($string); |
728 | 728 | } |
729 | 729 | |
730 | - /** |
|
731 | - * Checks whether the specified string is an ASCII |
|
732 | - * string, without any special or UTF8 characters. |
|
733 | - * Note: empty strings and NULL are considered ASCII. |
|
734 | - * Any variable types other than strings are not. |
|
735 | - * |
|
736 | - * @param string|float|int|NULL $string |
|
737 | - * @return boolean |
|
738 | - */ |
|
730 | + /** |
|
731 | + * Checks whether the specified string is an ASCII |
|
732 | + * string, without any special or UTF8 characters. |
|
733 | + * Note: empty strings and NULL are considered ASCII. |
|
734 | + * Any variable types other than strings are not. |
|
735 | + * |
|
736 | + * @param string|float|int|NULL $string |
|
737 | + * @return boolean |
|
738 | + */ |
|
739 | 739 | public static function isStringASCII($string) : bool |
740 | 740 | { |
741 | 741 | return ConvertHelper_String::isASCII(strval($string)); |
742 | 742 | } |
743 | 743 | |
744 | - /** |
|
745 | - * Adds HTML syntax highlighting to an URL. |
|
746 | - * |
|
747 | - * NOTE: Includes the necessary CSS styles. When |
|
748 | - * highlighting several URLs in the same page, |
|
749 | - * prefer using the `parseURL` function instead. |
|
750 | - * |
|
751 | - * @param string $url |
|
752 | - * @return string |
|
753 | - * @deprecated Use the Highlighter class directly instead. |
|
754 | - * @see Highlighter |
|
755 | - */ |
|
744 | + /** |
|
745 | + * Adds HTML syntax highlighting to an URL. |
|
746 | + * |
|
747 | + * NOTE: Includes the necessary CSS styles. When |
|
748 | + * highlighting several URLs in the same page, |
|
749 | + * prefer using the `parseURL` function instead. |
|
750 | + * |
|
751 | + * @param string $url |
|
752 | + * @return string |
|
753 | + * @deprecated Use the Highlighter class directly instead. |
|
754 | + * @see Highlighter |
|
755 | + */ |
|
756 | 756 | public static function highlight_url(string $url) : string |
757 | 757 | { |
758 | 758 | return Highlighter::url($url); |
759 | 759 | } |
760 | 760 | |
761 | - /** |
|
762 | - * Calculates a percentage match of the source string with the target string. |
|
763 | - * |
|
764 | - * Options are: |
|
765 | - * |
|
766 | - * - maxLevenshtein, default: 10 |
|
767 | - * Any levenshtein results above this value are ignored. |
|
768 | - * |
|
769 | - * - precision, default: 1 |
|
770 | - * The precision of the percentage float value |
|
771 | - * |
|
772 | - * @param string $source |
|
773 | - * @param string $target |
|
774 | - * @param array<string,mixed> $options |
|
775 | - * @return float |
|
776 | - * |
|
777 | - * @see ConvertHelper_TextComparer |
|
778 | - * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE |
|
779 | - * @see ConvertHelper_TextComparer::OPTION_PRECISION |
|
780 | - */ |
|
761 | + /** |
|
762 | + * Calculates a percentage match of the source string with the target string. |
|
763 | + * |
|
764 | + * Options are: |
|
765 | + * |
|
766 | + * - maxLevenshtein, default: 10 |
|
767 | + * Any levenshtein results above this value are ignored. |
|
768 | + * |
|
769 | + * - precision, default: 1 |
|
770 | + * The precision of the percentage float value |
|
771 | + * |
|
772 | + * @param string $source |
|
773 | + * @param string $target |
|
774 | + * @param array<string,mixed> $options |
|
775 | + * @return float |
|
776 | + * |
|
777 | + * @see ConvertHelper_TextComparer |
|
778 | + * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE |
|
779 | + * @see ConvertHelper_TextComparer::OPTION_PRECISION |
|
780 | + */ |
|
781 | 781 | public static function matchString(string $source, string $target, array $options=array()) : float |
782 | 782 | { |
783 | 783 | return (new ConvertHelper_TextComparer()) |
@@ -785,109 +785,109 @@ discard block |
||
785 | 785 | ->match($source, $target); |
786 | 786 | } |
787 | 787 | |
788 | - /** |
|
789 | - * Converts a date interval to a human-readable string with |
|
790 | - * all necessary time components, e.g. "1 year, 2 months and 4 days". |
|
791 | - * |
|
792 | - * @param DateInterval $interval |
|
793 | - * @return string |
|
794 | - * @see ConvertHelper_IntervalConverter |
|
795 | - * |
|
796 | - * @throws ConvertHelper_Exception |
|
797 | - * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
798 | - */ |
|
788 | + /** |
|
789 | + * Converts a date interval to a human-readable string with |
|
790 | + * all necessary time components, e.g. "1 year, 2 months and 4 days". |
|
791 | + * |
|
792 | + * @param DateInterval $interval |
|
793 | + * @return string |
|
794 | + * @see ConvertHelper_IntervalConverter |
|
795 | + * |
|
796 | + * @throws ConvertHelper_Exception |
|
797 | + * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
798 | + */ |
|
799 | 799 | public static function interval2string(DateInterval $interval) : string |
800 | 800 | { |
801 | 801 | return (new ConvertHelper_IntervalConverter()) |
802 | 802 | ->toString($interval); |
803 | 803 | } |
804 | 804 | |
805 | - /** |
|
806 | - * Converts an interval to its total amount of days. |
|
807 | - * @param DateInterval $interval |
|
808 | - * @return int |
|
809 | - */ |
|
805 | + /** |
|
806 | + * Converts an interval to its total amount of days. |
|
807 | + * @param DateInterval $interval |
|
808 | + * @return int |
|
809 | + */ |
|
810 | 810 | public static function interval2days(DateInterval $interval) : int |
811 | 811 | { |
812 | 812 | return ConvertHelper_DateInterval::toDays($interval); |
813 | 813 | } |
814 | 814 | |
815 | - /** |
|
816 | - * Converts an interval to its total amount of hours. |
|
817 | - * @param DateInterval $interval |
|
818 | - * @return int |
|
819 | - */ |
|
815 | + /** |
|
816 | + * Converts an interval to its total amount of hours. |
|
817 | + * @param DateInterval $interval |
|
818 | + * @return int |
|
819 | + */ |
|
820 | 820 | public static function interval2hours(DateInterval $interval) : int |
821 | 821 | { |
822 | 822 | return ConvertHelper_DateInterval::toHours($interval); |
823 | 823 | } |
824 | 824 | |
825 | - /** |
|
826 | - * Converts an interval to its total amount of minutes. |
|
827 | - * @param DateInterval $interval |
|
828 | - * @return int |
|
829 | - */ |
|
825 | + /** |
|
826 | + * Converts an interval to its total amount of minutes. |
|
827 | + * @param DateInterval $interval |
|
828 | + * @return int |
|
829 | + */ |
|
830 | 830 | public static function interval2minutes(DateInterval $interval) : int |
831 | 831 | { |
832 | 832 | return ConvertHelper_DateInterval::toMinutes($interval); |
833 | 833 | } |
834 | 834 | |
835 | - /** |
|
836 | - * Converts an interval to its total amount of seconds. |
|
837 | - * @param DateInterval $interval |
|
838 | - * @return int |
|
839 | - */ |
|
835 | + /** |
|
836 | + * Converts an interval to its total amount of seconds. |
|
837 | + * @param DateInterval $interval |
|
838 | + * @return int |
|
839 | + */ |
|
840 | 840 | public static function interval2seconds(DateInterval $interval) : int |
841 | 841 | { |
842 | 842 | return ConvertHelper_DateInterval::toSeconds($interval); |
843 | 843 | } |
844 | 844 | |
845 | - /** |
|
846 | - * Calculates the total amount of days / hours / minutes or seconds |
|
847 | - * of a date interval object (depending on the specified units), and |
|
848 | - * returns the total amount. |
|
849 | - * |
|
850 | - * @param DateInterval $interval |
|
851 | - * @param string $unit What total value to calculate. |
|
852 | - * @return integer |
|
853 | - * |
|
854 | - * @see ConvertHelper::INTERVAL_SECONDS |
|
855 | - * @see ConvertHelper::INTERVAL_MINUTES |
|
856 | - * @see ConvertHelper::INTERVAL_HOURS |
|
857 | - * @see ConvertHelper::INTERVAL_DAYS |
|
858 | - */ |
|
845 | + /** |
|
846 | + * Calculates the total amount of days / hours / minutes or seconds |
|
847 | + * of a date interval object (depending on the specified units), and |
|
848 | + * returns the total amount. |
|
849 | + * |
|
850 | + * @param DateInterval $interval |
|
851 | + * @param string $unit What total value to calculate. |
|
852 | + * @return integer |
|
853 | + * |
|
854 | + * @see ConvertHelper::INTERVAL_SECONDS |
|
855 | + * @see ConvertHelper::INTERVAL_MINUTES |
|
856 | + * @see ConvertHelper::INTERVAL_HOURS |
|
857 | + * @see ConvertHelper::INTERVAL_DAYS |
|
858 | + */ |
|
859 | 859 | public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int |
860 | 860 | { |
861 | 861 | return ConvertHelper_DateInterval::toTotal($interval, $unit); |
862 | 862 | } |
863 | 863 | |
864 | - /** |
|
865 | - * Converts a date to the corresponding day name. |
|
866 | - * |
|
867 | - * @param DateTime $date |
|
868 | - * @param bool $short |
|
869 | - * @return string|NULL |
|
870 | - */ |
|
864 | + /** |
|
865 | + * Converts a date to the corresponding day name. |
|
866 | + * |
|
867 | + * @param DateTime $date |
|
868 | + * @param bool $short |
|
869 | + * @return string|NULL |
|
870 | + */ |
|
871 | 871 | public static function date2dayName(DateTime $date, bool $short=false) : ?string |
872 | 872 | { |
873 | 873 | return ConvertHelper_Date::toDayName($date, $short); |
874 | 874 | } |
875 | 875 | |
876 | - /** |
|
877 | - * Retrieves a list of english day names. |
|
878 | - * @return string[] |
|
879 | - */ |
|
876 | + /** |
|
877 | + * Retrieves a list of english day names. |
|
878 | + * @return string[] |
|
879 | + */ |
|
880 | 880 | public static function getDayNamesInvariant() : array |
881 | 881 | { |
882 | 882 | return ConvertHelper_Date::getDayNamesInvariant(); |
883 | 883 | } |
884 | 884 | |
885 | - /** |
|
886 | - * Retrieves the day names list for the current locale. |
|
887 | - * |
|
888 | - * @param bool $short |
|
889 | - * @return string[] |
|
890 | - */ |
|
885 | + /** |
|
886 | + * Retrieves the day names list for the current locale. |
|
887 | + * |
|
888 | + * @param bool $short |
|
889 | + * @return string[] |
|
890 | + */ |
|
891 | 891 | public static function getDayNames(bool $short=false) : array |
892 | 892 | { |
893 | 893 | return ConvertHelper_Date::getDayNames($short); |
@@ -906,68 +906,68 @@ discard block |
||
906 | 906 | return ConvertHelper_Array::implodeWithAnd($list, $sep, $conjunction); |
907 | 907 | } |
908 | 908 | |
909 | - /** |
|
910 | - * Splits a string into an array of all characters it is composed of. |
|
911 | - * Unicode character safe. |
|
912 | - * |
|
913 | - * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
914 | - * characters. |
|
915 | - * |
|
916 | - * @param string $string |
|
917 | - * @return string[] |
|
918 | - */ |
|
909 | + /** |
|
910 | + * Splits a string into an array of all characters it is composed of. |
|
911 | + * Unicode character safe. |
|
912 | + * |
|
913 | + * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
914 | + * characters. |
|
915 | + * |
|
916 | + * @param string $string |
|
917 | + * @return string[] |
|
918 | + */ |
|
919 | 919 | public static function string2array(string $string) : array |
920 | 920 | { |
921 | 921 | return ConvertHelper_String::toArray($string); |
922 | 922 | } |
923 | 923 | |
924 | - /** |
|
925 | - * Checks whether the specified string contains HTML code. |
|
926 | - * |
|
927 | - * @param string $string |
|
928 | - * @return boolean |
|
929 | - */ |
|
924 | + /** |
|
925 | + * Checks whether the specified string contains HTML code. |
|
926 | + * |
|
927 | + * @param string $string |
|
928 | + * @return boolean |
|
929 | + */ |
|
930 | 930 | public static function isStringHTML(string $string) : bool |
931 | 931 | { |
932 | 932 | return ConvertHelper_String::isHTML($string); |
933 | 933 | } |
934 | 934 | |
935 | - /** |
|
936 | - * UTF8-safe wordwrap method: works like the regular wordwrap |
|
937 | - * PHP function but compatible with UTF8. Otherwise the lengths |
|
938 | - * are not calculated correctly. |
|
939 | - * |
|
940 | - * @param string $str |
|
941 | - * @param int $width |
|
942 | - * @param string $break |
|
943 | - * @param bool $cut |
|
944 | - * @return string |
|
945 | - */ |
|
935 | + /** |
|
936 | + * UTF8-safe wordwrap method: works like the regular wordwrap |
|
937 | + * PHP function but compatible with UTF8. Otherwise the lengths |
|
938 | + * are not calculated correctly. |
|
939 | + * |
|
940 | + * @param string $str |
|
941 | + * @param int $width |
|
942 | + * @param string $break |
|
943 | + * @param bool $cut |
|
944 | + * @return string |
|
945 | + */ |
|
946 | 946 | public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string |
947 | 947 | { |
948 | 948 | return ConvertHelper_String::wordwrap($str, $width, $break, $cut); |
949 | 949 | } |
950 | 950 | |
951 | - /** |
|
952 | - * Calculates the byte length of a string, taking into |
|
953 | - * account any unicode characters. |
|
954 | - * |
|
955 | - * @param string $string |
|
956 | - * @return int |
|
957 | - */ |
|
951 | + /** |
|
952 | + * Calculates the byte length of a string, taking into |
|
953 | + * account any unicode characters. |
|
954 | + * |
|
955 | + * @param string $string |
|
956 | + * @return int |
|
957 | + */ |
|
958 | 958 | public static function string2bytes(string $string): int |
959 | 959 | { |
960 | 960 | return ConvertHelper_String::toBytes($string); |
961 | 961 | } |
962 | 962 | |
963 | - /** |
|
964 | - * Creates a short, 8-character long hash for the specified string. |
|
965 | - * |
|
966 | - * WARNING: Not cryptographically safe. |
|
967 | - * |
|
968 | - * @param string $string |
|
969 | - * @return string |
|
970 | - */ |
|
963 | + /** |
|
964 | + * Creates a short, 8-character long hash for the specified string. |
|
965 | + * |
|
966 | + * WARNING: Not cryptographically safe. |
|
967 | + * |
|
968 | + * @param string $string |
|
969 | + * @return string |
|
970 | + */ |
|
971 | 971 | public static function string2shortHash(string $string) : string |
972 | 972 | { |
973 | 973 | return ConvertHelper_String::toShortHash($string); |
@@ -1013,88 +1013,88 @@ discard block |
||
1013 | 1013 | return ConvertHelper_ThrowableInfo::fromThrowable($e); |
1014 | 1014 | } |
1015 | 1015 | |
1016 | - /** |
|
1017 | - * Parses the specified query string like the native |
|
1018 | - * function <code>parse_str</code>, without the key |
|
1019 | - * naming limitations. |
|
1020 | - * |
|
1021 | - * Using parse_str, dots or spaces in key names are |
|
1022 | - * replaced by underscores. This method keeps all names |
|
1023 | - * intact. |
|
1024 | - * |
|
1025 | - * It still uses the parse_str implementation as it |
|
1026 | - * is tested and tried, but fixes the parameter names |
|
1027 | - * after parsing, as needed. |
|
1028 | - * |
|
1029 | - * @param string $queryString |
|
1030 | - * @return array<string,string> |
|
1031 | - * @see ConvertHelper_QueryParser |
|
1032 | - */ |
|
1016 | + /** |
|
1017 | + * Parses the specified query string like the native |
|
1018 | + * function <code>parse_str</code>, without the key |
|
1019 | + * naming limitations. |
|
1020 | + * |
|
1021 | + * Using parse_str, dots or spaces in key names are |
|
1022 | + * replaced by underscores. This method keeps all names |
|
1023 | + * intact. |
|
1024 | + * |
|
1025 | + * It still uses the parse_str implementation as it |
|
1026 | + * is tested and tried, but fixes the parameter names |
|
1027 | + * after parsing, as needed. |
|
1028 | + * |
|
1029 | + * @param string $queryString |
|
1030 | + * @return array<string,string> |
|
1031 | + * @see ConvertHelper_QueryParser |
|
1032 | + */ |
|
1033 | 1033 | public static function parseQueryString(string $queryString) : array |
1034 | 1034 | { |
1035 | 1035 | $parser = new ConvertHelper_QueryParser(); |
1036 | 1036 | return $parser->parse($queryString); |
1037 | 1037 | } |
1038 | 1038 | |
1039 | - /** |
|
1040 | - * Searches for needle in the specified string, and returns a list |
|
1041 | - * of all occurrences, including the matched string. The matched |
|
1042 | - * string is useful when doing a case-insensitive search, as it |
|
1043 | - * shows the exact matched case of needle. |
|
1044 | - * |
|
1045 | - * @param string $needle |
|
1046 | - * @param string $haystack |
|
1047 | - * @param bool $caseInsensitive |
|
1048 | - * @return ConvertHelper_StringMatch[] |
|
1049 | - */ |
|
1039 | + /** |
|
1040 | + * Searches for needle in the specified string, and returns a list |
|
1041 | + * of all occurrences, including the matched string. The matched |
|
1042 | + * string is useful when doing a case-insensitive search, as it |
|
1043 | + * shows the exact matched case of needle. |
|
1044 | + * |
|
1045 | + * @param string $needle |
|
1046 | + * @param string $haystack |
|
1047 | + * @param bool $caseInsensitive |
|
1048 | + * @return ConvertHelper_StringMatch[] |
|
1049 | + */ |
|
1050 | 1050 | public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array |
1051 | 1051 | { |
1052 | 1052 | return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive); |
1053 | 1053 | } |
1054 | 1054 | |
1055 | - /** |
|
1056 | - * Like explode, but trims all entries, and removes |
|
1057 | - * empty entries from the resulting array. |
|
1058 | - * |
|
1059 | - * @param string $delimiter |
|
1060 | - * @param string $string |
|
1061 | - * @return string[] |
|
1062 | - */ |
|
1055 | + /** |
|
1056 | + * Like explode, but trims all entries, and removes |
|
1057 | + * empty entries from the resulting array. |
|
1058 | + * |
|
1059 | + * @param string $delimiter |
|
1060 | + * @param string $string |
|
1061 | + * @return string[] |
|
1062 | + */ |
|
1063 | 1063 | public static function explodeTrim(string $delimiter, string $string) : array |
1064 | 1064 | { |
1065 | 1065 | return ConvertHelper_String::explodeTrim($delimiter, $string); |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - /** |
|
1069 | - * Detects the most used end-of-line character in the subject string. |
|
1070 | - * |
|
1071 | - * @param string $subjectString The string to check. |
|
1072 | - * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
1073 | - */ |
|
1068 | + /** |
|
1069 | + * Detects the most used end-of-line character in the subject string. |
|
1070 | + * |
|
1071 | + * @param string $subjectString The string to check. |
|
1072 | + * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
1073 | + */ |
|
1074 | 1074 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
1075 | 1075 | { |
1076 | 1076 | return ConvertHelper_EOL::detect($subjectString); |
1077 | 1077 | } |
1078 | 1078 | |
1079 | - /** |
|
1080 | - * Removes the specified keys from the target array, |
|
1081 | - * if they exist. |
|
1082 | - * |
|
1083 | - * @param array<string|int,mixed> $array |
|
1084 | - * @param string[] $keys |
|
1085 | - */ |
|
1079 | + /** |
|
1080 | + * Removes the specified keys from the target array, |
|
1081 | + * if they exist. |
|
1082 | + * |
|
1083 | + * @param array<string|int,mixed> $array |
|
1084 | + * @param string[] $keys |
|
1085 | + */ |
|
1086 | 1086 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
1087 | 1087 | { |
1088 | 1088 | ConvertHelper_Array::removeKeys($array, $keys); |
1089 | 1089 | } |
1090 | 1090 | |
1091 | - /** |
|
1092 | - * Checks if the specified variable is an integer or a string containing an integer. |
|
1093 | - * Accepts both positive and negative integers. |
|
1094 | - * |
|
1095 | - * @param mixed $value |
|
1096 | - * @return bool |
|
1097 | - */ |
|
1091 | + /** |
|
1092 | + * Checks if the specified variable is an integer or a string containing an integer. |
|
1093 | + * Accepts both positive and negative integers. |
|
1094 | + * |
|
1095 | + * @param mixed $value |
|
1096 | + * @return bool |
|
1097 | + */ |
|
1098 | 1098 | public static function isInteger($value) : bool |
1099 | 1099 | { |
1100 | 1100 | if(is_int($value)) { |
@@ -1114,52 +1114,52 @@ discard block |
||
1114 | 1114 | return false; |
1115 | 1115 | } |
1116 | 1116 | |
1117 | - /** |
|
1118 | - * Converts an amount of seconds to a DateInterval object. |
|
1119 | - * |
|
1120 | - * @param int $seconds |
|
1121 | - * @return DateInterval |
|
1122 | - * @throws ConvertHelper_Exception If the date interval cannot be created. |
|
1123 | - * |
|
1124 | - * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF |
|
1125 | - */ |
|
1117 | + /** |
|
1118 | + * Converts an amount of seconds to a DateInterval object. |
|
1119 | + * |
|
1120 | + * @param int $seconds |
|
1121 | + * @return DateInterval |
|
1122 | + * @throws ConvertHelper_Exception If the date interval cannot be created. |
|
1123 | + * |
|
1124 | + * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF |
|
1125 | + */ |
|
1126 | 1126 | public static function seconds2interval(int $seconds) : DateInterval |
1127 | 1127 | { |
1128 | 1128 | return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval(); |
1129 | 1129 | } |
1130 | 1130 | |
1131 | - /** |
|
1132 | - * Converts a size string like "50 MB" to the corresponding byte size. |
|
1133 | - * It is case-insensitive, ignores spaces, and supports both traditional |
|
1134 | - * "MB" and "MiB" notations. |
|
1135 | - * |
|
1136 | - * @param string $size |
|
1137 | - * @return int |
|
1138 | - */ |
|
1131 | + /** |
|
1132 | + * Converts a size string like "50 MB" to the corresponding byte size. |
|
1133 | + * It is case-insensitive, ignores spaces, and supports both traditional |
|
1134 | + * "MB" and "MiB" notations. |
|
1135 | + * |
|
1136 | + * @param string $size |
|
1137 | + * @return int |
|
1138 | + */ |
|
1139 | 1139 | public static function size2bytes(string $size) : int |
1140 | 1140 | { |
1141 | 1141 | return self::parseSize($size)->toBytes(); |
1142 | 1142 | } |
1143 | 1143 | |
1144 | - /** |
|
1145 | - * Parses a size string like "50 MB" and returns a size notation instance |
|
1146 | - * that has utility methods to access information on it, and convert it. |
|
1147 | - * |
|
1148 | - * @param string $size |
|
1149 | - * @return ConvertHelper_SizeNotation |
|
1150 | - */ |
|
1144 | + /** |
|
1145 | + * Parses a size string like "50 MB" and returns a size notation instance |
|
1146 | + * that has utility methods to access information on it, and convert it. |
|
1147 | + * |
|
1148 | + * @param string $size |
|
1149 | + * @return ConvertHelper_SizeNotation |
|
1150 | + */ |
|
1151 | 1151 | public static function parseSize(string $size) : ConvertHelper_SizeNotation |
1152 | 1152 | { |
1153 | 1153 | return new ConvertHelper_SizeNotation($size); |
1154 | 1154 | } |
1155 | 1155 | |
1156 | - /** |
|
1157 | - * Creates a URL finder instance, which can be used to find |
|
1158 | - * URLs in a string - be it plain text, or HTML. |
|
1159 | - * |
|
1160 | - * @param string $subject |
|
1161 | - * @return ConvertHelper_URLFinder |
|
1162 | - */ |
|
1156 | + /** |
|
1157 | + * Creates a URL finder instance, which can be used to find |
|
1158 | + * URLs in a string - be it plain text, or HTML. |
|
1159 | + * |
|
1160 | + * @param string $subject |
|
1161 | + * @return ConvertHelper_URLFinder |
|
1162 | + */ |
|
1163 | 1163 | public static function createURLFinder(string $subject) : ConvertHelper_URLFinder |
1164 | 1164 | { |
1165 | 1165 | return new ConvertHelper_URLFinder($subject); |
@@ -43,20 +43,20 @@ discard block |
||
43 | 43 | |
44 | 44 | protected FolderInfo $path; |
45 | 45 | |
46 | - /** |
|
47 | - * @var string[] |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var string[] |
|
48 | + */ |
|
49 | 49 | protected array $found = array(); |
50 | 50 | |
51 | - /** |
|
52 | - * The path must exist when the class is instantiated: its |
|
53 | - * real path will be determined to work with. |
|
54 | - * |
|
55 | - * @param string|PathInfoInterface|DirectoryIterator $path The absolute path to the target folder. |
|
56 | - * |
|
57 | - * @throws FileHelper_Exception |
|
58 | - * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
59 | - */ |
|
51 | + /** |
|
52 | + * The path must exist when the class is instantiated: its |
|
53 | + * real path will be determined to work with. |
|
54 | + * |
|
55 | + * @param string|PathInfoInterface|DirectoryIterator $path The absolute path to the target folder. |
|
56 | + * |
|
57 | + * @throws FileHelper_Exception |
|
58 | + * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
59 | + */ |
|
60 | 60 | public function __construct($path) |
61 | 61 | { |
62 | 62 | $this->path = AbstractPathInfo::resolveType($path)->requireExists()->requireIsFolder(); |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * Enables extension stripping, to return file names without extension. |
|
79 | - * |
|
80 | - * @return FileFinder |
|
81 | - */ |
|
77 | + /** |
|
78 | + * Enables extension stripping, to return file names without extension. |
|
79 | + * |
|
80 | + * @return FileFinder |
|
81 | + */ |
|
82 | 82 | public function stripExtensions() : FileFinder |
83 | 83 | { |
84 | 84 | return $this->setOption('strip-extensions', true); |
@@ -95,46 +95,46 @@ discard block |
||
95 | 95 | return $this->setOption('recursive', $enabled); |
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Retrieves all extensions that were added to |
|
100 | - * the list of included extensions. |
|
101 | - * |
|
102 | - * @return string[] |
|
103 | - */ |
|
98 | + /** |
|
99 | + * Retrieves all extensions that were added to |
|
100 | + * the list of included extensions. |
|
101 | + * |
|
102 | + * @return string[] |
|
103 | + */ |
|
104 | 104 | public function getIncludeExtensions() : array |
105 | 105 | { |
106 | 106 | return $this->getArrayOption(self::OPTION_INCLUDE_EXTENSIONS); |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * Includes a single extension in the file search: only |
|
111 | - * files with this extension will be used in the results. |
|
112 | - * |
|
113 | - * NOTE: Included extensions take precedence before excluded |
|
114 | - * extensions. If any excluded extensions are specified, they |
|
115 | - * will be ignored. |
|
116 | - * |
|
117 | - * @param string $extension Extension name, without dot (`php` for example). |
|
118 | - * @return FileFinder |
|
119 | - * @see FileFinder::includeExtensions() |
|
120 | - */ |
|
109 | + /** |
|
110 | + * Includes a single extension in the file search: only |
|
111 | + * files with this extension will be used in the results. |
|
112 | + * |
|
113 | + * NOTE: Included extensions take precedence before excluded |
|
114 | + * extensions. If any excluded extensions are specified, they |
|
115 | + * will be ignored. |
|
116 | + * |
|
117 | + * @param string $extension Extension name, without dot (`php` for example). |
|
118 | + * @return FileFinder |
|
119 | + * @see FileFinder::includeExtensions() |
|
120 | + */ |
|
121 | 121 | public function includeExtension(string $extension) : FileFinder |
122 | 122 | { |
123 | 123 | return $this->includeExtensions(array($extension)); |
124 | 124 | } |
125 | 125 | |
126 | - /** |
|
127 | - * Includes several extensions in the file search: only |
|
128 | - * files with these extensions wil be used in the results. |
|
129 | - * |
|
130 | - * NOTE: Included extensions take precedence before excluded |
|
131 | - * extensions. If any excluded extensions are specified, they |
|
132 | - * will be ignored. |
|
133 | - * |
|
134 | - * @param string[] $extensions Extension names, without dot (`php` for example). |
|
135 | - * @return FileFinder |
|
136 | - * @see FileFinder::includeExtension() |
|
137 | - */ |
|
126 | + /** |
|
127 | + * Includes several extensions in the file search: only |
|
128 | + * files with these extensions wil be used in the results. |
|
129 | + * |
|
130 | + * NOTE: Included extensions take precedence before excluded |
|
131 | + * extensions. If any excluded extensions are specified, they |
|
132 | + * will be ignored. |
|
133 | + * |
|
134 | + * @param string[] $extensions Extension names, without dot (`php` for example). |
|
135 | + * @return FileFinder |
|
136 | + * @see FileFinder::includeExtension() |
|
137 | + */ |
|
138 | 138 | public function includeExtensions(array $extensions) : FileFinder |
139 | 139 | { |
140 | 140 | $items = $this->getIncludeExtensions(); |
@@ -145,37 +145,37 @@ discard block |
||
145 | 145 | return $this; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * Retrieves a list of all extensions currently set as |
|
150 | - * excluded from the search. |
|
151 | - * |
|
152 | - * @return string[] |
|
153 | - */ |
|
148 | + /** |
|
149 | + * Retrieves a list of all extensions currently set as |
|
150 | + * excluded from the search. |
|
151 | + * |
|
152 | + * @return string[] |
|
153 | + */ |
|
154 | 154 | public function getExcludeExtensions() : array |
155 | 155 | { |
156 | 156 | return $this->getArrayOption(self::OPTION_EXCLUDE_EXTENSIONS); |
157 | 157 | } |
158 | 158 | |
159 | - /** |
|
160 | - * Excludes a single extension from the search. |
|
161 | - * |
|
162 | - * @param string $extension Extension name, without dot (`php` for example). |
|
163 | - * @return FileFinder |
|
164 | - * @see FileFinder::excludeExtensions() |
|
165 | - */ |
|
159 | + /** |
|
160 | + * Excludes a single extension from the search. |
|
161 | + * |
|
162 | + * @param string $extension Extension name, without dot (`php` for example). |
|
163 | + * @return FileFinder |
|
164 | + * @see FileFinder::excludeExtensions() |
|
165 | + */ |
|
166 | 166 | public function excludeExtension(string $extension) : FileFinder |
167 | 167 | { |
168 | 168 | return $this->excludeExtensions(array($extension)); |
169 | 169 | } |
170 | 170 | |
171 | - /** |
|
172 | - * Add several extensions to the list of extensions to |
|
173 | - * exclude from the file search. |
|
174 | - * |
|
175 | - * @param string[] $extensions Extension names, without dot (`php` for example). |
|
176 | - * @return FileFinder |
|
177 | - * @see FileFinder::excludeExtension() |
|
178 | - */ |
|
171 | + /** |
|
172 | + * Add several extensions to the list of extensions to |
|
173 | + * exclude from the file search. |
|
174 | + * |
|
175 | + * @param string[] $extensions Extension names, without dot (`php` for example). |
|
176 | + * @return FileFinder |
|
177 | + * @see FileFinder::excludeExtension() |
|
178 | + */ |
|
179 | 179 | public function excludeExtensions(array $extensions) : FileFinder |
180 | 180 | { |
181 | 181 | $items = $this->getExcludeExtensions(); |
@@ -186,52 +186,52 @@ discard block |
||
186 | 186 | return $this; |
187 | 187 | } |
188 | 188 | |
189 | - /** |
|
190 | - * In this mode, the entire path to the file will be stripped, |
|
191 | - * leaving only the file name in the files list. |
|
192 | - * |
|
193 | - * @return FileFinder |
|
194 | - */ |
|
189 | + /** |
|
190 | + * In this mode, the entire path to the file will be stripped, |
|
191 | + * leaving only the file name in the files list. |
|
192 | + * |
|
193 | + * @return FileFinder |
|
194 | + */ |
|
195 | 195 | public function setPathmodeStrip() : FileFinder |
196 | 196 | { |
197 | 197 | return $this->setPathmode(self::PATH_MODE_STRIP); |
198 | 198 | } |
199 | 199 | |
200 | - /** |
|
201 | - * In this mode, only the path relative to the source folder |
|
202 | - * will be included in the files list. |
|
203 | - * |
|
204 | - * @return FileFinder |
|
205 | - */ |
|
200 | + /** |
|
201 | + * In this mode, only the path relative to the source folder |
|
202 | + * will be included in the files list. |
|
203 | + * |
|
204 | + * @return FileFinder |
|
205 | + */ |
|
206 | 206 | public function setPathmodeRelative() : FileFinder |
207 | 207 | { |
208 | 208 | return $this->setPathmode(self::PATH_MODE_RELATIVE); |
209 | 209 | } |
210 | 210 | |
211 | - /** |
|
212 | - * In this mode, the full, absolute paths to the files will |
|
213 | - * be included in the files list. |
|
214 | - * |
|
215 | - * @return FileFinder |
|
216 | - */ |
|
211 | + /** |
|
212 | + * In this mode, the full, absolute paths to the files will |
|
213 | + * be included in the files list. |
|
214 | + * |
|
215 | + * @return FileFinder |
|
216 | + */ |
|
217 | 217 | public function setPathmodeAbsolute() : FileFinder |
218 | 218 | { |
219 | 219 | return $this->setPathmode(self::PATH_MODE_ABSOLUTE); |
220 | 220 | } |
221 | 221 | |
222 | - /** |
|
223 | - * This sets a character or string to replace the slashes |
|
224 | - * in the paths with. |
|
225 | - * |
|
226 | - * This is used for example in the `getPHPClassNames()` |
|
227 | - * method, to return files from subfolders as class names |
|
228 | - * using the "_" character: |
|
229 | - * |
|
230 | - * Subfolder/To/File.php => Subfolder_To_File.php |
|
231 | - * |
|
232 | - * @param string $character |
|
233 | - * @return FileFinder |
|
234 | - */ |
|
222 | + /** |
|
223 | + * This sets a character or string to replace the slashes |
|
224 | + * in the paths with. |
|
225 | + * |
|
226 | + * This is used for example in the `getPHPClassNames()` |
|
227 | + * method, to return files from subfolders as class names |
|
228 | + * using the "_" character: |
|
229 | + * |
|
230 | + * Subfolder/To/File.php => Subfolder_To_File.php |
|
231 | + * |
|
232 | + * @param string $character |
|
233 | + * @return FileFinder |
|
234 | + */ |
|
235 | 235 | public function setSlashReplacement(string $character) : FileFinder |
236 | 236 | { |
237 | 237 | return $this->setOption('slash-replacement', $character); |
@@ -254,12 +254,12 @@ discard block |
||
254 | 254 | return $this->setOption(self::OPTION_PATHMODE, $mode); |
255 | 255 | } |
256 | 256 | |
257 | - /** |
|
258 | - * Retrieves a list of all matching file names/paths, |
|
259 | - * depending on the selected options. |
|
260 | - * |
|
261 | - * @return string[] |
|
262 | - */ |
|
257 | + /** |
|
258 | + * Retrieves a list of all matching file names/paths, |
|
259 | + * depending on the selected options. |
|
260 | + * |
|
261 | + * @return string[] |
|
262 | + */ |
|
263 | 263 | public function getAll() : array |
264 | 264 | { |
265 | 265 | $this->find((string)$this->path, true); |
@@ -267,24 +267,24 @@ discard block |
||
267 | 267 | return $this->found; |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Retrieves only PHP files. Can be combined with other |
|
272 | - * options like enabling recursion into sub-folders. |
|
273 | - * |
|
274 | - * @return string[] |
|
275 | - */ |
|
270 | + /** |
|
271 | + * Retrieves only PHP files. Can be combined with other |
|
272 | + * options like enabling recursion into sub-folders. |
|
273 | + * |
|
274 | + * @return string[] |
|
275 | + */ |
|
276 | 276 | public function getPHPFiles() : array |
277 | 277 | { |
278 | 278 | $this->includeExtensions(array('php')); |
279 | 279 | return $this->getAll(); |
280 | 280 | } |
281 | 281 | |
282 | - /** |
|
283 | - * Generates PHP class names from file paths: it replaces |
|
284 | - * slashes with underscores, and removes file extensions. |
|
285 | - * |
|
286 | - * @return string[] An array of PHP file names without extension. |
|
287 | - */ |
|
282 | + /** |
|
283 | + * Generates PHP class names from file paths: it replaces |
|
284 | + * slashes with underscores, and removes file extensions. |
|
285 | + * |
|
286 | + * @return string[] An array of PHP file names without extension. |
|
287 | + */ |
|
288 | 288 | public function getPHPClassNames() : array |
289 | 289 | { |
290 | 290 | $this->includeExtensions(array('php')); |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | return $path; |
356 | 356 | } |
357 | 357 | |
358 | - /** |
|
359 | - * Checks whether the specified extension is allowed |
|
360 | - * with the current settings. |
|
361 | - * |
|
362 | - * @param string $extension |
|
363 | - * @return bool |
|
364 | - */ |
|
358 | + /** |
|
359 | + * Checks whether the specified extension is allowed |
|
360 | + * with the current settings. |
|
361 | + * |
|
362 | + * @param string $extension |
|
363 | + * @return bool |
|
364 | + */ |
|
365 | 365 | protected function filterExclusion(string $extension) : bool |
366 | 366 | { |
367 | 367 | $include = $this->getOption(self::OPTION_INCLUDE_EXTENSIONS); |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | return true; |
382 | 382 | } |
383 | 383 | |
384 | - /** |
|
385 | - * Adjusts the path according to the selected path mode. |
|
386 | - * |
|
387 | - * @param string $path |
|
388 | - * @return string |
|
389 | - */ |
|
384 | + /** |
|
385 | + * Adjusts the path according to the selected path mode. |
|
386 | + * |
|
387 | + * @param string $path |
|
388 | + * @return string |
|
389 | + */ |
|
390 | 390 | protected function filterPath(string $path) : string |
391 | 391 | { |
392 | 392 | switch($this->getStringOption(self::OPTION_PATHMODE)) |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | return $this->applyValidations($value); |
178 | 178 | } |
179 | 179 | |
180 | - /** |
|
181 | - * Runs the value through all validations that were added. |
|
182 | - * |
|
183 | - * @param mixed $value |
|
184 | - * @return mixed |
|
185 | - */ |
|
180 | + /** |
|
181 | + * Runs the value through all validations that were added. |
|
182 | + * |
|
183 | + * @param mixed $value |
|
184 | + * @return mixed |
|
185 | + */ |
|
186 | 186 | protected function applyValidations($value, bool $subval=false) |
187 | 187 | { |
188 | 188 | // go through all enqueued validations in turn, each time |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | return $value; |
196 | 196 | } |
197 | 197 | |
198 | - /** |
|
199 | - * Validates the specified value using the validation type. Returns |
|
200 | - * the validated value. |
|
201 | - * |
|
202 | - * @param mixed $value |
|
203 | - * @param string $type |
|
204 | - * @param array<string,mixed> $params |
|
205 | - * @param bool $subval Whether this is a subvalue in a list |
|
206 | - * @throws Request_Exception |
|
207 | - * @return mixed |
|
208 | - */ |
|
198 | + /** |
|
199 | + * Validates the specified value using the validation type. Returns |
|
200 | + * the validated value. |
|
201 | + * |
|
202 | + * @param mixed $value |
|
203 | + * @param string $type |
|
204 | + * @param array<string,mixed> $params |
|
205 | + * @param bool $subval Whether this is a subvalue in a list |
|
206 | + * @throws Request_Exception |
|
207 | + * @return mixed |
|
208 | + */ |
|
209 | 209 | protected function validateType($value, string $type, array $params, bool $subval) |
210 | 210 | { |
211 | 211 | $class = Request_Param_Validator::class.'_'.ucfirst($type); |
@@ -270,13 +270,13 @@ discard block |
||
270 | 270 | return $this->setValidation(self::VALIDATION_TYPE_URL); |
271 | 271 | } |
272 | 272 | |
273 | - /** |
|
274 | - * Sets the variable to contain a comma-separated list of integer IDs. |
|
275 | - * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
276 | - * <code>145</code>. |
|
277 | - * |
|
278 | - * @return $this |
|
279 | - */ |
|
273 | + /** |
|
274 | + * Sets the variable to contain a comma-separated list of integer IDs. |
|
275 | + * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
276 | + * <code>145</code>. |
|
277 | + * |
|
278 | + * @return $this |
|
279 | + */ |
|
280 | 280 | public function setIDList() : self |
281 | 281 | { |
282 | 282 | $this->valueType = self::VALUE_TYPE_LIST; |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | return $this; |
287 | 287 | } |
288 | 288 | |
289 | - /** |
|
290 | - * Sets the variable to be an alias, as defined by the |
|
291 | - * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
292 | - * |
|
293 | - * @return $this |
|
294 | - * @see RegexHelper::REGEX_ALIAS |
|
295 | - */ |
|
289 | + /** |
|
290 | + * Sets the variable to be an alias, as defined by the |
|
291 | + * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
292 | + * |
|
293 | + * @return $this |
|
294 | + * @see RegexHelper::REGEX_ALIAS |
|
295 | + */ |
|
296 | 296 | public function setAlias() : self |
297 | 297 | { |
298 | 298 | return $this->setRegex(RegexHelper::REGEX_ALIAS); |
@@ -333,12 +333,12 @@ discard block |
||
333 | 333 | return $this->setValidation(self::VALIDATION_TYPE_ALPHA); |
334 | 334 | } |
335 | 335 | |
336 | - /** |
|
337 | - * Sets the parameter value as a string containing lowercase |
|
338 | - * and/or uppercase letters, as well as numbers. |
|
339 | - * |
|
340 | - * @return $this |
|
341 | - */ |
|
336 | + /** |
|
337 | + * Sets the parameter value as a string containing lowercase |
|
338 | + * and/or uppercase letters, as well as numbers. |
|
339 | + * |
|
340 | + * @return $this |
|
341 | + */ |
|
342 | 342 | public function setAlnum() : self |
343 | 343 | { |
344 | 344 | return $this->setValidation(self::VALIDATION_TYPE_ALNUM); |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | ); |
397 | 397 | } |
398 | 398 | |
399 | - /** |
|
400 | - * Whether the parameter is a list of values. |
|
401 | - * |
|
402 | - * @return bool |
|
403 | - */ |
|
399 | + /** |
|
400 | + * Whether the parameter is a list of values. |
|
401 | + * |
|
402 | + * @return bool |
|
403 | + */ |
|
404 | 404 | public function isList() : bool |
405 | 405 | { |
406 | 406 | return $this->valueType === self::VALUE_TYPE_LIST; |
@@ -442,28 +442,28 @@ discard block |
||
442 | 442 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => false)); |
443 | 443 | } |
444 | 444 | |
445 | - /** |
|
446 | - * The parameter is a string boolean representation. This means |
|
447 | - * it can be any of the following: "yes", "true", "no", "false". |
|
448 | - * The value is automatically converted to a boolean when retrieving |
|
449 | - * the parameter. |
|
450 | - * |
|
451 | - * @return $this |
|
452 | - */ |
|
445 | + /** |
|
446 | + * The parameter is a string boolean representation. This means |
|
447 | + * it can be any of the following: "yes", "true", "no", "false". |
|
448 | + * The value is automatically converted to a boolean when retrieving |
|
449 | + * the parameter. |
|
450 | + * |
|
451 | + * @return $this |
|
452 | + */ |
|
453 | 453 | public function setBoolean() : self |
454 | 454 | { |
455 | 455 | return $this->addClassFilter('Boolean'); |
456 | 456 | } |
457 | 457 | |
458 | - /** |
|
459 | - * Validates the request parameter as an MD5 string, |
|
460 | - * so that only values resembling md5 values are accepted. |
|
461 | - * |
|
462 | - * NOTE: This can only guarantee the format, not whether |
|
463 | - * it is an actual valid hash of something. |
|
464 | - * |
|
465 | - * @return $this |
|
466 | - */ |
|
458 | + /** |
|
459 | + * Validates the request parameter as an MD5 string, |
|
460 | + * so that only values resembling md5 values are accepted. |
|
461 | + * |
|
462 | + * NOTE: This can only guarantee the format, not whether |
|
463 | + * it is an actual valid hash of something. |
|
464 | + * |
|
465 | + * @return $this |
|
466 | + */ |
|
467 | 467 | public function setMD5() : self |
468 | 468 | { |
469 | 469 | return $this->setRegex(RegexHelper::REGEX_MD5); |
@@ -503,14 +503,14 @@ discard block |
||
503 | 503 | return $this; |
504 | 504 | } |
505 | 505 | |
506 | - /** |
|
507 | - * Retrieves the value of the request parameter, |
|
508 | - * applying all filters (if any) and validation |
|
509 | - * (if any). |
|
510 | - * |
|
511 | - * @param mixed $default |
|
512 | - * @return mixed |
|
513 | - */ |
|
506 | + /** |
|
507 | + * Retrieves the value of the request parameter, |
|
508 | + * applying all filters (if any) and validation |
|
509 | + * (if any). |
|
510 | + * |
|
511 | + * @param mixed $default |
|
512 | + * @return mixed |
|
513 | + */ |
|
514 | 514 | public function get($default=null) |
515 | 515 | { |
516 | 516 | $value = $this->request->getParam($this->paramName); |
@@ -523,17 +523,17 @@ discard block |
||
523 | 523 | |
524 | 524 | // region: Filtering |
525 | 525 | |
526 | - /** |
|
527 | - * Filters the specified value by going through all available |
|
528 | - * filters, if any. If none have been set, the value is simply |
|
529 | - * passed through. |
|
530 | - * |
|
531 | - * @param mixed $value |
|
532 | - * @return mixed |
|
533 | - * |
|
534 | - * @see RequestParam::applyFilter_callback() |
|
535 | - * @see RequestParam::applyFilter_class() |
|
536 | - */ |
|
526 | + /** |
|
527 | + * Filters the specified value by going through all available |
|
528 | + * filters, if any. If none have been set, the value is simply |
|
529 | + * passed through. |
|
530 | + * |
|
531 | + * @param mixed $value |
|
532 | + * @return mixed |
|
533 | + * |
|
534 | + * @see RequestParam::applyFilter_callback() |
|
535 | + * @see RequestParam::applyFilter_class() |
|
536 | + */ |
|
537 | 537 | protected function filter($value) |
538 | 538 | { |
539 | 539 | foreach ($this->filters as $filter) |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | return $this; |
623 | 623 | } |
624 | 624 | |
625 | - /** |
|
626 | - * Adds a filter that trims whitespace from the request |
|
627 | - * parameter using the PHP <code>trim</code> function. |
|
628 | - * |
|
629 | - * @return $this |
|
630 | - */ |
|
625 | + /** |
|
626 | + * Adds a filter that trims whitespace from the request |
|
627 | + * parameter using the PHP <code>trim</code> function. |
|
628 | + * |
|
629 | + * @return $this |
|
630 | + */ |
|
631 | 631 | public function addFilterTrim() : self |
632 | 632 | { |
633 | 633 | // to guarantee we only work with strings |
@@ -636,13 +636,13 @@ discard block |
||
636 | 636 | return $this->addCallbackFilter('trim'); |
637 | 637 | } |
638 | 638 | |
639 | - /** |
|
640 | - * Converts the value to a string, even if it is not |
|
641 | - * a string value. Complex types like arrays and objects |
|
642 | - * are converted to an empty string. |
|
643 | - * |
|
644 | - * @return $this |
|
645 | - */ |
|
639 | + /** |
|
640 | + * Converts the value to a string, even if it is not |
|
641 | + * a string value. Complex types like arrays and objects |
|
642 | + * are converted to an empty string. |
|
643 | + * |
|
644 | + * @return $this |
|
645 | + */ |
|
646 | 646 | public function addStringFilter() : self |
647 | 647 | { |
648 | 648 | return $this->addClassFilter('String'); |
@@ -694,12 +694,12 @@ discard block |
||
694 | 694 | return $this->addCallbackFilter('strip_tags', array($allowedTags)); |
695 | 695 | } |
696 | 696 | |
697 | - /** |
|
698 | - * Adds a filter that strips all whitespace from the |
|
699 | - * request parameter, from spaces to tabs and newlines. |
|
700 | - * |
|
701 | - * @return $this |
|
702 | - */ |
|
697 | + /** |
|
698 | + * Adds a filter that strips all whitespace from the |
|
699 | + * request parameter, from spaces to tabs and newlines. |
|
700 | + * |
|
701 | + * @return $this |
|
702 | + */ |
|
703 | 703 | public function addStripWhitespaceFilter() : self |
704 | 704 | { |
705 | 705 | // to ensure we only work with strings. |
@@ -708,14 +708,14 @@ discard block |
||
708 | 708 | return $this->addClassFilter('StripWhitespace'); |
709 | 709 | } |
710 | 710 | |
711 | - /** |
|
712 | - * Adds a filter that transforms comma separated values |
|
713 | - * into an array of values. |
|
714 | - * |
|
715 | - * @param bool $trimEntries Trim whitespace from each entry? |
|
716 | - * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
717 | - * @return $this |
|
718 | - */ |
|
711 | + /** |
|
712 | + * Adds a filter that transforms comma separated values |
|
713 | + * into an array of values. |
|
714 | + * |
|
715 | + * @param bool $trimEntries Trim whitespace from each entry? |
|
716 | + * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
717 | + * @return $this |
|
718 | + */ |
|
719 | 719 | public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : self |
720 | 720 | { |
721 | 721 | $this->setArray(); |
@@ -746,12 +746,12 @@ discard block |
||
746 | 746 | ); |
747 | 747 | } |
748 | 748 | |
749 | - /** |
|
750 | - * Adds a filter that encodes all HTML special characters |
|
751 | - * using the PHP <code>htmlspecialchars</code> function. |
|
752 | - * |
|
753 | - * @return $this |
|
754 | - */ |
|
749 | + /** |
|
750 | + * Adds a filter that encodes all HTML special characters |
|
751 | + * using the PHP <code>htmlspecialchars</code> function. |
|
752 | + * |
|
753 | + * @return $this |
|
754 | + */ |
|
755 | 755 | public function addHTMLSpecialcharsFilter() : self |
756 | 756 | { |
757 | 757 | return $this->addCallbackFilter('htmlspecialchars', array(ENT_QUOTES, 'UTF-8')); |
@@ -764,14 +764,14 @@ discard block |
||
764 | 764 | return $this->paramName; |
765 | 765 | } |
766 | 766 | |
767 | - /** |
|
768 | - * Marks this request parameter as required. To use this feature, |
|
769 | - * you have to call the request's {@link Request::validate()} |
|
770 | - * method. |
|
771 | - * |
|
772 | - * @return RequestParam |
|
773 | - * @see Request::validate() |
|
774 | - */ |
|
767 | + /** |
|
768 | + * Marks this request parameter as required. To use this feature, |
|
769 | + * you have to call the request's {@link Request::validate()} |
|
770 | + * method. |
|
771 | + * |
|
772 | + * @return RequestParam |
|
773 | + * @see Request::validate() |
|
774 | + */ |
|
775 | 775 | public function makeRequired() : RequestParam |
776 | 776 | { |
777 | 777 | $this->required = true; |
@@ -24,9 +24,9 @@ |
||
24 | 24 | { |
25 | 25 | use Traits_Optionable; |
26 | 26 | |
27 | - /** |
|
28 | - * @var RequestParam |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var RequestParam |
|
29 | + */ |
|
30 | 30 | protected $param; |
31 | 31 | |
32 | 32 | protected $value; |
@@ -29,14 +29,14 @@ |
||
29 | 29 | */ |
30 | 30 | protected $param; |
31 | 31 | |
32 | - /** |
|
33 | - * @var mixed |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var mixed |
|
34 | + */ |
|
35 | 35 | protected $value; |
36 | 36 | |
37 | - /** |
|
38 | - * @var bool |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var bool |
|
39 | + */ |
|
40 | 40 | protected $isSubvalue = false; |
41 | 41 | |
42 | 42 | public function __construct(RequestParam $param, bool $subval) |
@@ -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, $code=null, $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, $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); |
@@ -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']; |