@@ -52,32 +52,32 @@ discard block |
||
52 | 52 | const ERROR_PATH_IS_NOT_A_FOLDER = 340034; |
53 | 53 | const ERROR_CANNOT_WRITE_TO_FOLDER = 340035; |
54 | 54 | |
55 | - /** |
|
56 | - * Opens a serialized file and returns the unserialized data. |
|
57 | - * |
|
58 | - * @param string $file |
|
59 | - * @throws FileHelper_Exception |
|
60 | - * @return array |
|
61 | - * @deprecated Use parseSerializedFile() instead. |
|
62 | - * @see FileHelper::parseSerializedFile() |
|
63 | - */ |
|
55 | + /** |
|
56 | + * Opens a serialized file and returns the unserialized data. |
|
57 | + * |
|
58 | + * @param string $file |
|
59 | + * @throws FileHelper_Exception |
|
60 | + * @return array |
|
61 | + * @deprecated Use parseSerializedFile() instead. |
|
62 | + * @see FileHelper::parseSerializedFile() |
|
63 | + */ |
|
64 | 64 | public static function openUnserialized(string $file) : array |
65 | 65 | { |
66 | 66 | return self::parseSerializedFile($file); |
67 | 67 | } |
68 | 68 | |
69 | - /** |
|
70 | - * Opens a serialized file and returns the unserialized data. |
|
71 | - * |
|
72 | - * @param string $file |
|
73 | - * @throws FileHelper_Exception |
|
74 | - * @return array |
|
75 | - * @see FileHelper::parseSerializedFile() |
|
76 | - * |
|
77 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
78 | - * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ |
|
79 | - * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED |
|
80 | - */ |
|
69 | + /** |
|
70 | + * Opens a serialized file and returns the unserialized data. |
|
71 | + * |
|
72 | + * @param string $file |
|
73 | + * @throws FileHelper_Exception |
|
74 | + * @return array |
|
75 | + * @see FileHelper::parseSerializedFile() |
|
76 | + * |
|
77 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
78 | + * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ |
|
79 | + * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED |
|
80 | + */ |
|
81 | 81 | public static function parseSerializedFile(string $file) |
82 | 82 | { |
83 | 83 | self::requireFileExists($file); |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | return rmdir($rootFolder); |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
150 | - * Create a folder, if it does not exist yet. |
|
151 | - * |
|
152 | - * @param string $path |
|
153 | - * @throws FileHelper_Exception |
|
154 | - * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
155 | - */ |
|
149 | + /** |
|
150 | + * Create a folder, if it does not exist yet. |
|
151 | + * |
|
152 | + * @param string $path |
|
153 | + * @throws FileHelper_Exception |
|
154 | + * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
155 | + */ |
|
156 | 156 | public static function createFolder($path) |
157 | 157 | { |
158 | 158 | if(is_dir($path) || mkdir($path, 0777, true)) { |
@@ -199,22 +199,22 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - /** |
|
203 | - * Copies a file to the target location. Includes checks |
|
204 | - * for most error sources, like the source file not being |
|
205 | - * readable. Automatically creates the target folder if it |
|
206 | - * does not exist yet. |
|
207 | - * |
|
208 | - * @param string $sourcePath |
|
209 | - * @param string $targetPath |
|
210 | - * @throws FileHelper_Exception |
|
211 | - * |
|
212 | - * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
213 | - * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND |
|
214 | - * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE |
|
215 | - * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE |
|
216 | - * @see FileHelper::ERROR_CANNOT_COPY_FILE |
|
217 | - */ |
|
202 | + /** |
|
203 | + * Copies a file to the target location. Includes checks |
|
204 | + * for most error sources, like the source file not being |
|
205 | + * readable. Automatically creates the target folder if it |
|
206 | + * does not exist yet. |
|
207 | + * |
|
208 | + * @param string $sourcePath |
|
209 | + * @param string $targetPath |
|
210 | + * @throws FileHelper_Exception |
|
211 | + * |
|
212 | + * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER |
|
213 | + * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND |
|
214 | + * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE |
|
215 | + * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE |
|
216 | + * @see FileHelper::ERROR_CANNOT_COPY_FILE |
|
217 | + */ |
|
218 | 218 | public static function copyFile(string $sourcePath, string $targetPath) : void |
219 | 219 | { |
220 | 220 | self::requireFileExists($sourcePath, self::ERROR_SOURCE_FILE_NOT_FOUND); |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
257 | - /** |
|
258 | - * Deletes the target file. Ignored if it cannot be found, |
|
259 | - * and throws an exception if it fails. |
|
260 | - * |
|
261 | - * @param string $filePath |
|
262 | - * @throws FileHelper_Exception |
|
263 | - * |
|
264 | - * @see FileHelper::ERROR_CANNOT_DELETE_FILE |
|
265 | - */ |
|
257 | + /** |
|
258 | + * Deletes the target file. Ignored if it cannot be found, |
|
259 | + * and throws an exception if it fails. |
|
260 | + * |
|
261 | + * @param string $filePath |
|
262 | + * @throws FileHelper_Exception |
|
263 | + * |
|
264 | + * @see FileHelper::ERROR_CANNOT_DELETE_FILE |
|
265 | + */ |
|
266 | 266 | public static function deleteFile(string $filePath) : void |
267 | 267 | { |
268 | 268 | if(!file_exists($filePath)) { |
@@ -284,15 +284,15 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
287 | - * Creates a new CSV parser instance and returns it. |
|
288 | - * |
|
289 | - * @param string $delimiter |
|
290 | - * @param string $enclosure |
|
291 | - * @param string $escape |
|
292 | - * @param bool $heading |
|
293 | - * @return Csv |
|
287 | + * Creates a new CSV parser instance and returns it. |
|
288 | + * |
|
289 | + * @param string $delimiter |
|
290 | + * @param string $enclosure |
|
291 | + * @param string $escape |
|
292 | + * @param bool $heading |
|
293 | + * @return Csv |
|
294 | 294 | * @see CSVHelper::createParser() |
295 | - */ |
|
295 | + */ |
|
296 | 296 | public static function createCSVParser(string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : Csv |
297 | 297 | { |
298 | 298 | if($delimiter==='') { $delimiter = ';'; } |
@@ -305,21 +305,21 @@ discard block |
||
305 | 305 | return $parser; |
306 | 306 | } |
307 | 307 | |
308 | - /** |
|
309 | - * Parses all lines in the specified string and returns an |
|
310 | - * indexed array with all csv values in each line. |
|
311 | - * |
|
312 | - * @param string $csv |
|
313 | - * @param string $delimiter |
|
314 | - * @param string $enclosure |
|
315 | - * @param string $escape |
|
316 | - * @param bool $heading |
|
317 | - * @return array |
|
318 | - * @throws FileHelper_Exception |
|
319 | - * |
|
320 | - * @see parseCSVFile() |
|
321 | - * @see FileHelper::ERROR_PARSING_CSV |
|
322 | - */ |
|
308 | + /** |
|
309 | + * Parses all lines in the specified string and returns an |
|
310 | + * indexed array with all csv values in each line. |
|
311 | + * |
|
312 | + * @param string $csv |
|
313 | + * @param string $delimiter |
|
314 | + * @param string $enclosure |
|
315 | + * @param string $escape |
|
316 | + * @param bool $heading |
|
317 | + * @return array |
|
318 | + * @throws FileHelper_Exception |
|
319 | + * |
|
320 | + * @see parseCSVFile() |
|
321 | + * @see FileHelper::ERROR_PARSING_CSV |
|
322 | + */ |
|
323 | 323 | public static function parseCSVString(string $csv, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : array |
324 | 324 | { |
325 | 325 | $parser = self::createCSVParser($delimiter, $enclosure, '\\', $heading); |
@@ -490,31 +490,31 @@ discard block |
||
490 | 490 | ); |
491 | 491 | } |
492 | 492 | |
493 | - /** |
|
494 | - * Verifies whether the target file is a PHP file. The path |
|
495 | - * to the file can be a path to a file as a string, or a |
|
496 | - * DirectoryIterator object instance. |
|
497 | - * |
|
498 | - * @param string|\DirectoryIterator $pathOrDirIterator |
|
499 | - * @return boolean |
|
500 | - */ |
|
493 | + /** |
|
494 | + * Verifies whether the target file is a PHP file. The path |
|
495 | + * to the file can be a path to a file as a string, or a |
|
496 | + * DirectoryIterator object instance. |
|
497 | + * |
|
498 | + * @param string|\DirectoryIterator $pathOrDirIterator |
|
499 | + * @return boolean |
|
500 | + */ |
|
501 | 501 | public static function isPHPFile($pathOrDirIterator) |
502 | 502 | { |
503 | - if(self::getExtension($pathOrDirIterator) == 'php') { |
|
504 | - return true; |
|
505 | - } |
|
503 | + if(self::getExtension($pathOrDirIterator) == 'php') { |
|
504 | + return true; |
|
505 | + } |
|
506 | 506 | |
507 | - return false; |
|
507 | + return false; |
|
508 | 508 | } |
509 | 509 | |
510 | - /** |
|
511 | - * Retrieves the extension of the specified file. Can be a path |
|
512 | - * to a file as a string, or a DirectoryIterator object instance. |
|
513 | - * |
|
514 | - * @param string|\DirectoryIterator $pathOrDirIterator |
|
515 | - * @param bool $lowercase |
|
516 | - * @return string |
|
517 | - */ |
|
510 | + /** |
|
511 | + * Retrieves the extension of the specified file. Can be a path |
|
512 | + * to a file as a string, or a DirectoryIterator object instance. |
|
513 | + * |
|
514 | + * @param string|\DirectoryIterator $pathOrDirIterator |
|
515 | + * @param bool $lowercase |
|
516 | + * @return string |
|
517 | + */ |
|
518 | 518 | public static function getExtension($pathOrDirIterator, bool $lowercase = true) : string |
519 | 519 | { |
520 | 520 | if($pathOrDirIterator instanceof \DirectoryIterator) { |
@@ -525,51 +525,51 @@ discard block |
||
525 | 525 | |
526 | 526 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
527 | 527 | if($lowercase) { |
528 | - $ext = mb_strtolower($ext); |
|
528 | + $ext = mb_strtolower($ext); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | return $ext; |
532 | 532 | } |
533 | 533 | |
534 | - /** |
|
535 | - * Retrieves the file name from a path, with or without extension. |
|
536 | - * The path to the file can be a string, or a DirectoryIterator object |
|
537 | - * instance. |
|
538 | - * |
|
539 | - * In case of folders, behaves like the pathinfo function: returns |
|
540 | - * the name of the folder. |
|
541 | - * |
|
542 | - * @param string|\DirectoryIterator $pathOrDirIterator |
|
543 | - * @param bool $extension |
|
544 | - * @return string |
|
545 | - */ |
|
534 | + /** |
|
535 | + * Retrieves the file name from a path, with or without extension. |
|
536 | + * The path to the file can be a string, or a DirectoryIterator object |
|
537 | + * instance. |
|
538 | + * |
|
539 | + * In case of folders, behaves like the pathinfo function: returns |
|
540 | + * the name of the folder. |
|
541 | + * |
|
542 | + * @param string|\DirectoryIterator $pathOrDirIterator |
|
543 | + * @param bool $extension |
|
544 | + * @return string |
|
545 | + */ |
|
546 | 546 | public static function getFilename($pathOrDirIterator, $extension = true) |
547 | 547 | { |
548 | 548 | $path = $pathOrDirIterator; |
549 | - if($pathOrDirIterator instanceof \DirectoryIterator) { |
|
550 | - $path = $pathOrDirIterator->getFilename(); |
|
551 | - } |
|
549 | + if($pathOrDirIterator instanceof \DirectoryIterator) { |
|
550 | + $path = $pathOrDirIterator->getFilename(); |
|
551 | + } |
|
552 | 552 | |
553 | - $path = self::normalizePath($path); |
|
553 | + $path = self::normalizePath($path); |
|
554 | 554 | |
555 | - if(!$extension) { |
|
556 | - return pathinfo($path, PATHINFO_FILENAME); |
|
557 | - } |
|
555 | + if(!$extension) { |
|
556 | + return pathinfo($path, PATHINFO_FILENAME); |
|
557 | + } |
|
558 | 558 | |
559 | - return pathinfo($path, PATHINFO_BASENAME); |
|
559 | + return pathinfo($path, PATHINFO_BASENAME); |
|
560 | 560 | } |
561 | 561 | |
562 | - /** |
|
563 | - * Tries to read the contents of the target file and |
|
564 | - * treat it as JSON to return the decoded JSON data. |
|
565 | - * |
|
566 | - * @param string $file |
|
567 | - * @throws FileHelper_Exception |
|
568 | - * @return array |
|
569 | - * |
|
570 | - * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE |
|
571 | - * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE |
|
572 | - */ |
|
562 | + /** |
|
563 | + * Tries to read the contents of the target file and |
|
564 | + * treat it as JSON to return the decoded JSON data. |
|
565 | + * |
|
566 | + * @param string $file |
|
567 | + * @throws FileHelper_Exception |
|
568 | + * @return array |
|
569 | + * |
|
570 | + * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE |
|
571 | + * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE |
|
572 | + */ |
|
573 | 573 | public static function parseJSONFile(string $file, $targetEncoding=null, $sourceEncoding=null) |
574 | 574 | { |
575 | 575 | self::requireFileExists($file, self::ERROR_CANNOT_FIND_JSON_FILE); |
@@ -605,16 +605,16 @@ discard block |
||
605 | 605 | return $json; |
606 | 606 | } |
607 | 607 | |
608 | - /** |
|
609 | - * Corrects common formatting mistakes when users enter |
|
610 | - * file names, like too many spaces, dots and the like. |
|
611 | - * |
|
612 | - * NOTE: if the file name contains a path, the path is |
|
613 | - * stripped, leaving only the file name. |
|
614 | - * |
|
615 | - * @param string $name |
|
616 | - * @return string |
|
617 | - */ |
|
608 | + /** |
|
609 | + * Corrects common formatting mistakes when users enter |
|
610 | + * file names, like too many spaces, dots and the like. |
|
611 | + * |
|
612 | + * NOTE: if the file name contains a path, the path is |
|
613 | + * stripped, leaving only the file name. |
|
614 | + * |
|
615 | + * @param string $name |
|
616 | + * @return string |
|
617 | + */ |
|
618 | 618 | public static function fixFileName(string $name) : string |
619 | 619 | { |
620 | 620 | $name = trim($name); |
@@ -644,68 +644,68 @@ discard block |
||
644 | 644 | return $name; |
645 | 645 | } |
646 | 646 | |
647 | - /** |
|
648 | - * Creates an instance of the file finder, which is an easier |
|
649 | - * alternative to the other manual findFile methods, since all |
|
650 | - * options can be set by chaining. |
|
651 | - * |
|
652 | - * @param string $path |
|
653 | - * @return FileHelper_FileFinder |
|
654 | - */ |
|
647 | + /** |
|
648 | + * Creates an instance of the file finder, which is an easier |
|
649 | + * alternative to the other manual findFile methods, since all |
|
650 | + * options can be set by chaining. |
|
651 | + * |
|
652 | + * @param string $path |
|
653 | + * @return FileHelper_FileFinder |
|
654 | + */ |
|
655 | 655 | public static function createFileFinder(string $path) : FileHelper_FileFinder |
656 | 656 | { |
657 | 657 | return new FileHelper_FileFinder($path); |
658 | 658 | } |
659 | 659 | |
660 | - /** |
|
661 | - * Searches for all HTML files in the target folder. |
|
662 | - * |
|
663 | - * NOTE: This method only exists for backwards compatibility. |
|
664 | - * Use the `createFileFinder()` method instead, which offers |
|
665 | - * an object oriented interface that is much easier to use. |
|
666 | - * |
|
667 | - * @param string $targetFolder |
|
668 | - * @param array $options |
|
669 | - * @return array An indexed array with files. |
|
670 | - * @see FileHelper::createFileFinder() |
|
671 | - */ |
|
660 | + /** |
|
661 | + * Searches for all HTML files in the target folder. |
|
662 | + * |
|
663 | + * NOTE: This method only exists for backwards compatibility. |
|
664 | + * Use the `createFileFinder()` method instead, which offers |
|
665 | + * an object oriented interface that is much easier to use. |
|
666 | + * |
|
667 | + * @param string $targetFolder |
|
668 | + * @param array $options |
|
669 | + * @return array An indexed array with files. |
|
670 | + * @see FileHelper::createFileFinder() |
|
671 | + */ |
|
672 | 672 | public static function findHTMLFiles(string $targetFolder, array $options=array()) : array |
673 | 673 | { |
674 | 674 | return self::findFiles($targetFolder, array('html'), $options); |
675 | 675 | } |
676 | 676 | |
677 | - /** |
|
678 | - * Searches for all PHP files in the target folder. |
|
679 | - * |
|
680 | - * NOTE: This method only exists for backwards compatibility. |
|
681 | - * Use the `createFileFinder()` method instead, which offers |
|
682 | - * an object oriented interface that is much easier to use. |
|
683 | - * |
|
684 | - * @param string $targetFolder |
|
685 | - * @param array $options |
|
686 | - * @return array An indexed array of PHP files. |
|
687 | - * @see FileHelper::createFileFinder() |
|
688 | - */ |
|
677 | + /** |
|
678 | + * Searches for all PHP files in the target folder. |
|
679 | + * |
|
680 | + * NOTE: This method only exists for backwards compatibility. |
|
681 | + * Use the `createFileFinder()` method instead, which offers |
|
682 | + * an object oriented interface that is much easier to use. |
|
683 | + * |
|
684 | + * @param string $targetFolder |
|
685 | + * @param array $options |
|
686 | + * @return array An indexed array of PHP files. |
|
687 | + * @see FileHelper::createFileFinder() |
|
688 | + */ |
|
689 | 689 | public static function findPHPFiles(string $targetFolder, array $options=array()) : array |
690 | 690 | { |
691 | 691 | return self::findFiles($targetFolder, array('php'), $options); |
692 | 692 | } |
693 | 693 | |
694 | - /** |
|
695 | - * Finds files according to the specified options. |
|
696 | - * |
|
697 | - * NOTE: This method only exists for backwards compatibility. |
|
698 | - * Use the `createFileFinder()` method instead, which offers |
|
699 | - * an object oriented interface that is much easier to use. |
|
700 | - * |
|
701 | - * @param string $targetFolder |
|
702 | - * @param array $extensions |
|
703 | - * @param array $options |
|
704 | - * @param array $files |
|
705 | - * @throws FileHelper_Exception |
|
706 | - * @return array |
|
707 | - * @see FileHelper::createFileFinder() |
|
708 | - */ |
|
694 | + /** |
|
695 | + * Finds files according to the specified options. |
|
696 | + * |
|
697 | + * NOTE: This method only exists for backwards compatibility. |
|
698 | + * Use the `createFileFinder()` method instead, which offers |
|
699 | + * an object oriented interface that is much easier to use. |
|
700 | + * |
|
701 | + * @param string $targetFolder |
|
702 | + * @param array $extensions |
|
703 | + * @param array $options |
|
704 | + * @param array $files |
|
705 | + * @throws FileHelper_Exception |
|
706 | + * @return array |
|
707 | + * @see FileHelper::createFileFinder() |
|
708 | + */ |
|
709 | 709 | public static function findFiles(string $targetFolder, array $extensions=array(), array $options=array(), array $files=array()) : array |
710 | 710 | { |
711 | 711 | $finder = self::createFileFinder($targetFolder); |
@@ -731,14 +731,14 @@ discard block |
||
731 | 731 | return $finder->getAll(); |
732 | 732 | } |
733 | 733 | |
734 | - /** |
|
735 | - * Removes the extension from the specified path or file name, |
|
736 | - * if any, and returns the name without the extension. |
|
737 | - * |
|
738 | - * @param string $filename |
|
739 | - * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to. |
|
740 | - * @return string |
|
741 | - */ |
|
734 | + /** |
|
735 | + * Removes the extension from the specified path or file name, |
|
736 | + * if any, and returns the name without the extension. |
|
737 | + * |
|
738 | + * @param string $filename |
|
739 | + * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to. |
|
740 | + * @return string |
|
741 | + */ |
|
742 | 742 | public static function removeExtension(string $filename, bool $keepPath=false) : string |
743 | 743 | { |
744 | 744 | // normalize paths to allow windows style slashes even on nix servers |
@@ -758,22 +758,22 @@ discard block |
||
758 | 758 | return implode('/', $parts); |
759 | 759 | } |
760 | 760 | |
761 | - /** |
|
762 | - * Detects the UTF BOM in the target file, if any. Returns |
|
763 | - * the encoding matching the BOM, which can be any of the |
|
764 | - * following: |
|
765 | - * |
|
766 | - * <ul> |
|
767 | - * <li>UTF32-BE</li> |
|
768 | - * <li>UTF32-LE</li> |
|
769 | - * <li>UTF16-BE</li> |
|
770 | - * <li>UTF16-LE</li> |
|
771 | - * <li>UTF8</li> |
|
772 | - * </ul> |
|
773 | - * |
|
774 | - * @param string $filename |
|
775 | - * @return string|NULL |
|
776 | - */ |
|
761 | + /** |
|
762 | + * Detects the UTF BOM in the target file, if any. Returns |
|
763 | + * the encoding matching the BOM, which can be any of the |
|
764 | + * following: |
|
765 | + * |
|
766 | + * <ul> |
|
767 | + * <li>UTF32-BE</li> |
|
768 | + * <li>UTF32-LE</li> |
|
769 | + * <li>UTF16-BE</li> |
|
770 | + * <li>UTF16-LE</li> |
|
771 | + * <li>UTF8</li> |
|
772 | + * </ul> |
|
773 | + * |
|
774 | + * @param string $filename |
|
775 | + * @return string|NULL |
|
776 | + */ |
|
777 | 777 | public static function detectUTFBom(string $filename) : ?string |
778 | 778 | { |
779 | 779 | $fp = fopen($filename, 'r'); |
@@ -805,13 +805,13 @@ discard block |
||
805 | 805 | |
806 | 806 | protected static $utfBoms; |
807 | 807 | |
808 | - /** |
|
809 | - * Retrieves a list of all UTF byte order mark character |
|
810 | - * sequences, as an assocative array with UTF encoding => bom sequence |
|
811 | - * pairs. |
|
812 | - * |
|
813 | - * @return array |
|
814 | - */ |
|
808 | + /** |
|
809 | + * Retrieves a list of all UTF byte order mark character |
|
810 | + * sequences, as an assocative array with UTF encoding => bom sequence |
|
811 | + * pairs. |
|
812 | + * |
|
813 | + * @return array |
|
814 | + */ |
|
815 | 815 | public static function getUTFBOMs() |
816 | 816 | { |
817 | 817 | if(!isset(self::$utfBoms)) { |
@@ -827,15 +827,15 @@ discard block |
||
827 | 827 | return self::$utfBoms; |
828 | 828 | } |
829 | 829 | |
830 | - /** |
|
831 | - * Checks whether the specified encoding is a valid |
|
832 | - * unicode encoding, for example "UTF16-LE" or "UTF8". |
|
833 | - * Also accounts for alternate way to write the, like |
|
834 | - * "UTF-8", and omitting little/big endian suffixes. |
|
835 | - * |
|
836 | - * @param string $encoding |
|
837 | - * @return boolean |
|
838 | - */ |
|
830 | + /** |
|
831 | + * Checks whether the specified encoding is a valid |
|
832 | + * unicode encoding, for example "UTF16-LE" or "UTF8". |
|
833 | + * Also accounts for alternate way to write the, like |
|
834 | + * "UTF-8", and omitting little/big endian suffixes. |
|
835 | + * |
|
836 | + * @param string $encoding |
|
837 | + * @return boolean |
|
838 | + */ |
|
839 | 839 | public static function isValidUnicodeEncoding(string $encoding) : bool |
840 | 840 | { |
841 | 841 | $encodings = self::getKnownUnicodeEncodings(); |
@@ -854,40 +854,40 @@ discard block |
||
854 | 854 | return in_array($encoding, $keep); |
855 | 855 | } |
856 | 856 | |
857 | - /** |
|
858 | - * Retrieves a list of all known unicode file encodings. |
|
859 | - * @return array |
|
860 | - */ |
|
857 | + /** |
|
858 | + * Retrieves a list of all known unicode file encodings. |
|
859 | + * @return array |
|
860 | + */ |
|
861 | 861 | public static function getKnownUnicodeEncodings() |
862 | 862 | { |
863 | 863 | return array_keys(self::getUTFBOMs()); |
864 | 864 | } |
865 | 865 | |
866 | - /** |
|
867 | - * Normalizes the slash style in a file or folder path, |
|
868 | - * by replacing any antislashes with forward slashes. |
|
869 | - * |
|
870 | - * @param string $path |
|
871 | - * @return string |
|
872 | - */ |
|
866 | + /** |
|
867 | + * Normalizes the slash style in a file or folder path, |
|
868 | + * by replacing any antislashes with forward slashes. |
|
869 | + * |
|
870 | + * @param string $path |
|
871 | + * @return string |
|
872 | + */ |
|
873 | 873 | public static function normalizePath(string $path) : string |
874 | 874 | { |
875 | 875 | return str_replace(array('\\', '//'), array('/', '/'), $path); |
876 | 876 | } |
877 | 877 | |
878 | - /** |
|
879 | - * Saves the specified data to a file, JSON encoded. |
|
880 | - * |
|
881 | - * @param mixed $data |
|
882 | - * @param string $file |
|
883 | - * @param bool $pretty |
|
884 | - * @throws FileHelper_Exception |
|
885 | - * |
|
886 | - * @see FileHelper::ERROR_JSON_ENCODE_ERROR |
|
887 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
888 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
889 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
890 | - */ |
|
878 | + /** |
|
879 | + * Saves the specified data to a file, JSON encoded. |
|
880 | + * |
|
881 | + * @param mixed $data |
|
882 | + * @param string $file |
|
883 | + * @param bool $pretty |
|
884 | + * @throws FileHelper_Exception |
|
885 | + * |
|
886 | + * @see FileHelper::ERROR_JSON_ENCODE_ERROR |
|
887 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
888 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
889 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
890 | + */ |
|
891 | 891 | public static function saveAsJSON($data, string $file, bool $pretty=false) |
892 | 892 | { |
893 | 893 | $options = null; |
@@ -911,18 +911,18 @@ discard block |
||
911 | 911 | self::saveFile($file, $json); |
912 | 912 | } |
913 | 913 | |
914 | - /** |
|
915 | - * Saves the specified content to the target file, creating |
|
916 | - * the file and the folder as necessary. |
|
917 | - * |
|
918 | - * @param string $filePath |
|
919 | - * @param string $content |
|
920 | - * @throws FileHelper_Exception |
|
921 | - * |
|
922 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
923 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
924 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
925 | - */ |
|
914 | + /** |
|
915 | + * Saves the specified content to the target file, creating |
|
916 | + * the file and the folder as necessary. |
|
917 | + * |
|
918 | + * @param string $filePath |
|
919 | + * @param string $content |
|
920 | + * @throws FileHelper_Exception |
|
921 | + * |
|
922 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
923 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
924 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
925 | + */ |
|
926 | 926 | public static function saveFile(string $filePath, string $content='') : void |
927 | 927 | { |
928 | 928 | $filePath = self::normalizePath($filePath); |
@@ -989,12 +989,12 @@ discard block |
||
989 | 989 | ); |
990 | 990 | } |
991 | 991 | |
992 | - /** |
|
993 | - * Checks whether it is possible to run PHP command |
|
994 | - * line commands. |
|
995 | - * |
|
996 | - * @return boolean |
|
997 | - */ |
|
992 | + /** |
|
993 | + * Checks whether it is possible to run PHP command |
|
994 | + * line commands. |
|
995 | + * |
|
996 | + * @return boolean |
|
997 | + */ |
|
998 | 998 | public static function canMakePHPCalls() : bool |
999 | 999 | { |
1000 | 1000 | return self::cliCommandExists('php'); |
@@ -1071,16 +1071,16 @@ discard block |
||
1071 | 1071 | return $result; |
1072 | 1072 | } |
1073 | 1073 | |
1074 | - /** |
|
1075 | - * Validates a PHP file's syntax. |
|
1076 | - * |
|
1077 | - * NOTE: This will fail silently if the PHP command line |
|
1078 | - * is not available. Use {@link FileHelper::canMakePHPCalls()} |
|
1079 | - * to check this beforehand as needed. |
|
1080 | - * |
|
1081 | - * @param string $path |
|
1082 | - * @return boolean|array A boolean true if the file is valid, an array with validation messages otherwise. |
|
1083 | - */ |
|
1074 | + /** |
|
1075 | + * Validates a PHP file's syntax. |
|
1076 | + * |
|
1077 | + * NOTE: This will fail silently if the PHP command line |
|
1078 | + * is not available. Use {@link FileHelper::canMakePHPCalls()} |
|
1079 | + * to check this beforehand as needed. |
|
1080 | + * |
|
1081 | + * @param string $path |
|
1082 | + * @return boolean|array A boolean true if the file is valid, an array with validation messages otherwise. |
|
1083 | + */ |
|
1084 | 1084 | public static function checkPHPFileSyntax($path) |
1085 | 1085 | { |
1086 | 1086 | if(!self::canMakePHPCalls()) { |
@@ -1104,14 +1104,14 @@ discard block |
||
1104 | 1104 | return $output; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - /** |
|
1108 | - * Retrieves the last modified date for the specified file or folder. |
|
1109 | - * |
|
1110 | - * Note: If the target does not exist, returns null. |
|
1111 | - * |
|
1112 | - * @param string $path |
|
1113 | - * @return \DateTime|NULL |
|
1114 | - */ |
|
1107 | + /** |
|
1108 | + * Retrieves the last modified date for the specified file or folder. |
|
1109 | + * |
|
1110 | + * Note: If the target does not exist, returns null. |
|
1111 | + * |
|
1112 | + * @param string $path |
|
1113 | + * @return \DateTime|NULL |
|
1114 | + */ |
|
1115 | 1115 | public static function getModifiedDate($path) |
1116 | 1116 | { |
1117 | 1117 | $time = filemtime($path); |
@@ -1124,24 +1124,24 @@ discard block |
||
1124 | 1124 | return null; |
1125 | 1125 | } |
1126 | 1126 | |
1127 | - /** |
|
1128 | - * Retrieves the names of all subfolders in the specified path. |
|
1129 | - * |
|
1130 | - * Available options: |
|
1131 | - * |
|
1132 | - * - recursive: true/false |
|
1133 | - * Whether to search for subfolders recursively. |
|
1134 | - * |
|
1135 | - * - absolute-paths: true/false |
|
1136 | - * Whether to return a list of absolute paths. |
|
1137 | - * |
|
1138 | - * @param string $targetFolder |
|
1139 | - * @param array $options |
|
1140 | - * @throws FileHelper_Exception |
|
1141 | - * @return string[] |
|
1142 | - * |
|
1143 | - * @todo Move this to a separate class. |
|
1144 | - */ |
|
1127 | + /** |
|
1128 | + * Retrieves the names of all subfolders in the specified path. |
|
1129 | + * |
|
1130 | + * Available options: |
|
1131 | + * |
|
1132 | + * - recursive: true/false |
|
1133 | + * Whether to search for subfolders recursively. |
|
1134 | + * |
|
1135 | + * - absolute-paths: true/false |
|
1136 | + * Whether to return a list of absolute paths. |
|
1137 | + * |
|
1138 | + * @param string $targetFolder |
|
1139 | + * @param array $options |
|
1140 | + * @throws FileHelper_Exception |
|
1141 | + * @return string[] |
|
1142 | + * |
|
1143 | + * @todo Move this to a separate class. |
|
1144 | + */ |
|
1145 | 1145 | public static function getSubfolders($targetFolder, $options = array()) |
1146 | 1146 | { |
1147 | 1147 | if(!is_dir($targetFolder)) |
@@ -1202,16 +1202,16 @@ discard block |
||
1202 | 1202 | return $result; |
1203 | 1203 | } |
1204 | 1204 | |
1205 | - /** |
|
1206 | - * Retrieves the maximum allowed upload file size, in bytes. |
|
1207 | - * Takes into account the PHP ini settings <code>post_max_size</code> |
|
1208 | - * and <code>upload_max_filesize</code>. Since these cannot |
|
1209 | - * be modified at runtime, they are the hard limits for uploads. |
|
1210 | - * |
|
1211 | - * NOTE: Based on binary values, where 1KB = 1024 Bytes. |
|
1212 | - * |
|
1213 | - * @return int Will return <code>-1</code> if no limit. |
|
1214 | - */ |
|
1205 | + /** |
|
1206 | + * Retrieves the maximum allowed upload file size, in bytes. |
|
1207 | + * Takes into account the PHP ini settings <code>post_max_size</code> |
|
1208 | + * and <code>upload_max_filesize</code>. Since these cannot |
|
1209 | + * be modified at runtime, they are the hard limits for uploads. |
|
1210 | + * |
|
1211 | + * NOTE: Based on binary values, where 1KB = 1024 Bytes. |
|
1212 | + * |
|
1213 | + * @return int Will return <code>-1</code> if no limit. |
|
1214 | + */ |
|
1215 | 1215 | public static function getMaxUploadFilesize() : int |
1216 | 1216 | { |
1217 | 1217 | static $max_size = -1; |
@@ -1249,16 +1249,16 @@ discard block |
||
1249 | 1249 | return round($size); |
1250 | 1250 | } |
1251 | 1251 | |
1252 | - /** |
|
1253 | - * Makes a path relative using a folder depth: will reduce the |
|
1254 | - * length of the path so that only the amount of folders defined |
|
1255 | - * in the <code>$depth</code> attribute are shown below the actual |
|
1256 | - * folder or file in the path. |
|
1257 | - * |
|
1258 | - * @param string $path The absolute or relative path |
|
1259 | - * @param int $depth The folder depth to reduce the path to |
|
1260 | - * @return string |
|
1261 | - */ |
|
1252 | + /** |
|
1253 | + * Makes a path relative using a folder depth: will reduce the |
|
1254 | + * length of the path so that only the amount of folders defined |
|
1255 | + * in the <code>$depth</code> attribute are shown below the actual |
|
1256 | + * folder or file in the path. |
|
1257 | + * |
|
1258 | + * @param string $path The absolute or relative path |
|
1259 | + * @param int $depth The folder depth to reduce the path to |
|
1260 | + * @return string |
|
1261 | + */ |
|
1262 | 1262 | public static function relativizePathByDepth(string $path, int $depth=2) : string |
1263 | 1263 | { |
1264 | 1264 | $path = self::normalizePath($path); |
@@ -1296,23 +1296,23 @@ discard block |
||
1296 | 1296 | return trim(implode('/', $tokens), '/'); |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - /** |
|
1300 | - * Makes the specified path relative to another path, |
|
1301 | - * by removing one from the other if found. Also |
|
1302 | - * normalizes the path to use forward slashes. |
|
1303 | - * |
|
1304 | - * Example: |
|
1305 | - * |
|
1306 | - * <pre> |
|
1307 | - * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder'); |
|
1308 | - * </pre> |
|
1309 | - * |
|
1310 | - * Result: <code>to/file.txt</code> |
|
1311 | - * |
|
1312 | - * @param string $path |
|
1313 | - * @param string $relativeTo |
|
1314 | - * @return string |
|
1315 | - */ |
|
1299 | + /** |
|
1300 | + * Makes the specified path relative to another path, |
|
1301 | + * by removing one from the other if found. Also |
|
1302 | + * normalizes the path to use forward slashes. |
|
1303 | + * |
|
1304 | + * Example: |
|
1305 | + * |
|
1306 | + * <pre> |
|
1307 | + * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder'); |
|
1308 | + * </pre> |
|
1309 | + * |
|
1310 | + * Result: <code>to/file.txt</code> |
|
1311 | + * |
|
1312 | + * @param string $path |
|
1313 | + * @param string $relativeTo |
|
1314 | + * @return string |
|
1315 | + */ |
|
1316 | 1316 | public static function relativizePath(string $path, string $relativeTo) : string |
1317 | 1317 | { |
1318 | 1318 | $path = self::normalizePath($path); |
@@ -1324,17 +1324,17 @@ discard block |
||
1324 | 1324 | return $relative; |
1325 | 1325 | } |
1326 | 1326 | |
1327 | - /** |
|
1328 | - * Checks that the target file exists, and throws an exception |
|
1329 | - * if it does not. |
|
1330 | - * |
|
1331 | - * @param string $path |
|
1332 | - * @param int|NULL $errorCode Optional custom error code |
|
1333 | - * @throws FileHelper_Exception |
|
1334 | - * @return string The real path to the file |
|
1335 | - * |
|
1336 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
1337 | - */ |
|
1327 | + /** |
|
1328 | + * Checks that the target file exists, and throws an exception |
|
1329 | + * if it does not. |
|
1330 | + * |
|
1331 | + * @param string $path |
|
1332 | + * @param int|NULL $errorCode Optional custom error code |
|
1333 | + * @throws FileHelper_Exception |
|
1334 | + * @return string The real path to the file |
|
1335 | + * |
|
1336 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
1337 | + */ |
|
1338 | 1338 | public static function requireFileExists(string $path, ?int $errorCode=null) : string |
1339 | 1339 | { |
1340 | 1340 | $result = realpath($path); |
@@ -1372,18 +1372,18 @@ discard block |
||
1372 | 1372 | ); |
1373 | 1373 | } |
1374 | 1374 | |
1375 | - /** |
|
1376 | - * Reads a specific line number from the target file and returns its |
|
1377 | - * contents, if the file has such a line. Does so with little memory |
|
1378 | - * usage, as the file is not read entirely into memory. |
|
1379 | - * |
|
1380 | - * @param string $path |
|
1381 | - * @param int $lineNumber Note: 1-based; the first line is number 1. |
|
1382 | - * @return string|NULL Will return null if the requested line does not exist. |
|
1383 | - * @throws FileHelper_Exception |
|
1384 | - * |
|
1385 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
1386 | - */ |
|
1375 | + /** |
|
1376 | + * Reads a specific line number from the target file and returns its |
|
1377 | + * contents, if the file has such a line. Does so with little memory |
|
1378 | + * usage, as the file is not read entirely into memory. |
|
1379 | + * |
|
1380 | + * @param string $path |
|
1381 | + * @param int $lineNumber Note: 1-based; the first line is number 1. |
|
1382 | + * @return string|NULL Will return null if the requested line does not exist. |
|
1383 | + * @throws FileHelper_Exception |
|
1384 | + * |
|
1385 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
1386 | + */ |
|
1387 | 1387 | public static function getLineFromFile(string $path, int $lineNumber) : ?string |
1388 | 1388 | { |
1389 | 1389 | self::requireFileExists($path); |
@@ -1399,19 +1399,19 @@ discard block |
||
1399 | 1399 | $file->seek($targetLine); |
1400 | 1400 | |
1401 | 1401 | if($file->key() !== $targetLine) { |
1402 | - return null; |
|
1402 | + return null; |
|
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | return $file->current(); |
1406 | 1406 | } |
1407 | 1407 | |
1408 | - /** |
|
1409 | - * Retrieves the total amount of lines in the file, without |
|
1410 | - * reading the whole file into memory. |
|
1411 | - * |
|
1412 | - * @param string $path |
|
1413 | - * @return int |
|
1414 | - */ |
|
1408 | + /** |
|
1409 | + * Retrieves the total amount of lines in the file, without |
|
1410 | + * reading the whole file into memory. |
|
1411 | + * |
|
1412 | + * @param string $path |
|
1413 | + * @return int |
|
1414 | + */ |
|
1415 | 1415 | public static function countFileLines(string $path) : int |
1416 | 1416 | { |
1417 | 1417 | self::requireFileExists($path); |
@@ -1441,26 +1441,26 @@ discard block |
||
1441 | 1441 | return $number+1; |
1442 | 1442 | } |
1443 | 1443 | |
1444 | - /** |
|
1445 | - * Parses the target file to detect any PHP classes contained |
|
1446 | - * within, and retrieve information on them. Does not use the |
|
1447 | - * PHP reflection API. |
|
1448 | - * |
|
1449 | - * @param string $filePath |
|
1450 | - * @return FileHelper_PHPClassInfo |
|
1451 | - */ |
|
1444 | + /** |
|
1445 | + * Parses the target file to detect any PHP classes contained |
|
1446 | + * within, and retrieve information on them. Does not use the |
|
1447 | + * PHP reflection API. |
|
1448 | + * |
|
1449 | + * @param string $filePath |
|
1450 | + * @return FileHelper_PHPClassInfo |
|
1451 | + */ |
|
1452 | 1452 | public static function findPHPClasses(string $filePath) : FileHelper_PHPClassInfo |
1453 | 1453 | { |
1454 | 1454 | return new FileHelper_PHPClassInfo($filePath); |
1455 | 1455 | } |
1456 | 1456 | |
1457 | - /** |
|
1458 | - * Detects the end of line style used in the target file, if any. |
|
1459 | - * Can be used with large files, because it only reads part of it. |
|
1460 | - * |
|
1461 | - * @param string $filePath The path to the file. |
|
1462 | - * @return NULL|ConvertHelper_EOL The end of line character information, or NULL if none is found. |
|
1463 | - */ |
|
1457 | + /** |
|
1458 | + * Detects the end of line style used in the target file, if any. |
|
1459 | + * Can be used with large files, because it only reads part of it. |
|
1460 | + * |
|
1461 | + * @param string $filePath The path to the file. |
|
1462 | + * @return NULL|ConvertHelper_EOL The end of line character information, or NULL if none is found. |
|
1463 | + */ |
|
1464 | 1464 | public static function detectEOLCharacter(string $filePath) : ?ConvertHelper_EOL |
1465 | 1465 | { |
1466 | 1466 | // 20 lines is enough to get a good picture of the newline style in the file. |
@@ -1473,18 +1473,18 @@ discard block |
||
1473 | 1473 | return ConvertHelper::detectEOLCharacter($string); |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - /** |
|
1477 | - * Reads the specified amount of lines from the target file. |
|
1478 | - * Unicode BOM compatible: any byte order marker is stripped |
|
1479 | - * from the resulting lines. |
|
1480 | - * |
|
1481 | - * @param string $filePath |
|
1482 | - * @param int $amount Set to 0 to read all lines. |
|
1483 | - * @return array |
|
1484 | - * |
|
1485 | - * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES |
|
1486 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
1487 | - */ |
|
1476 | + /** |
|
1477 | + * Reads the specified amount of lines from the target file. |
|
1478 | + * Unicode BOM compatible: any byte order marker is stripped |
|
1479 | + * from the resulting lines. |
|
1480 | + * |
|
1481 | + * @param string $filePath |
|
1482 | + * @param int $amount Set to 0 to read all lines. |
|
1483 | + * @return array |
|
1484 | + * |
|
1485 | + * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES |
|
1486 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
1487 | + */ |
|
1488 | 1488 | public static function readLines(string $filePath, int $amount=0) : array |
1489 | 1489 | { |
1490 | 1490 | self::requireFileExists($filePath); |
@@ -1537,16 +1537,16 @@ discard block |
||
1537 | 1537 | return $result; |
1538 | 1538 | } |
1539 | 1539 | |
1540 | - /** |
|
1541 | - * Reads all content from a file. |
|
1542 | - * |
|
1543 | - * @param string $filePath |
|
1544 | - * @throws FileHelper_Exception |
|
1545 | - * @return string |
|
1546 | - * |
|
1547 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
1548 | - * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
1549 | - */ |
|
1540 | + /** |
|
1541 | + * Reads all content from a file. |
|
1542 | + * |
|
1543 | + * @param string $filePath |
|
1544 | + * @throws FileHelper_Exception |
|
1545 | + * @return string |
|
1546 | + * |
|
1547 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
1548 | + * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
1549 | + */ |
|
1550 | 1550 | public static function readContents(string $filePath) : string |
1551 | 1551 | { |
1552 | 1552 | self::requireFileExists($filePath); |
@@ -1567,18 +1567,18 @@ discard block |
||
1567 | 1567 | ); |
1568 | 1568 | } |
1569 | 1569 | |
1570 | - /** |
|
1571 | - * Ensures that the target path exists on disk, and is a folder. |
|
1572 | - * |
|
1573 | - * @param string $path |
|
1574 | - * @return string The real path, with normalized slashes. |
|
1575 | - * @throws FileHelper_Exception |
|
1576 | - * |
|
1577 | - * @see FileHelper::normalizePath() |
|
1578 | - * |
|
1579 | - * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST |
|
1580 | - * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
1581 | - */ |
|
1570 | + /** |
|
1571 | + * Ensures that the target path exists on disk, and is a folder. |
|
1572 | + * |
|
1573 | + * @param string $path |
|
1574 | + * @return string The real path, with normalized slashes. |
|
1575 | + * @throws FileHelper_Exception |
|
1576 | + * |
|
1577 | + * @see FileHelper::normalizePath() |
|
1578 | + * |
|
1579 | + * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST |
|
1580 | + * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
1581 | + */ |
|
1582 | 1582 | public static function requireFolderExists(string $path) : string |
1583 | 1583 | { |
1584 | 1584 | $actual = realpath($path); |