@@ -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,46 +272,46 @@ 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 | return self::getPathInfo($pathOrDirIterator)->getExtension($lowercase); |
301 | 301 | } |
302 | 302 | |
303 | - /** |
|
304 | - * Retrieves the file name from a path, with or without extension. |
|
305 | - * The path to the file can be a string, or a DirectoryIterator object |
|
306 | - * instance. |
|
307 | - * |
|
308 | - * In case of folders, behaves like the "pathinfo" function: returns |
|
309 | - * the name of the folder. |
|
310 | - * |
|
311 | - * @param string|DirectoryIterator $pathOrDirIterator |
|
312 | - * @param bool $extension |
|
313 | - * @return string |
|
314 | - */ |
|
303 | + /** |
|
304 | + * Retrieves the file name from a path, with or without extension. |
|
305 | + * The path to the file can be a string, or a DirectoryIterator object |
|
306 | + * instance. |
|
307 | + * |
|
308 | + * In case of folders, behaves like the "pathinfo" function: returns |
|
309 | + * the name of the folder. |
|
310 | + * |
|
311 | + * @param string|DirectoryIterator $pathOrDirIterator |
|
312 | + * @param bool $extension |
|
313 | + * @return string |
|
314 | + */ |
|
315 | 315 | public static function getFilename($pathOrDirIterator, bool $extension = true) : string |
316 | 316 | { |
317 | 317 | $info = self::getPathInfo($pathOrDirIterator); |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | ->parse(); |
346 | 346 | } |
347 | 347 | |
348 | - /** |
|
349 | - * Corrects common formatting mistakes when users enter |
|
350 | - * file names, like too many spaces, dots and the like. |
|
351 | - * |
|
352 | - * NOTE: if the file name contains a path, the path is |
|
353 | - * stripped, leaving only the file name. |
|
354 | - * |
|
355 | - * @param string $name |
|
356 | - * @return string |
|
357 | - */ |
|
348 | + /** |
|
349 | + * Corrects common formatting mistakes when users enter |
|
350 | + * file names, like too many spaces, dots and the like. |
|
351 | + * |
|
352 | + * NOTE: if the file name contains a path, the path is |
|
353 | + * stripped, leaving only the file name. |
|
354 | + * |
|
355 | + * @param string $name |
|
356 | + * @return string |
|
357 | + */ |
|
358 | 358 | public static function fixFileName(string $name) : string |
359 | 359 | { |
360 | 360 | return NameFixer::fixName($name); |
@@ -414,23 +414,23 @@ discard block |
||
414 | 414 | return self::findFiles($targetFolder, array('php'), $options); |
415 | 415 | } |
416 | 416 | |
417 | - /** |
|
418 | - * Finds files according to the specified options. |
|
419 | - * |
|
420 | - * NOTE: This method only exists for backwards compatibility. |
|
421 | - * Use the {@see FileHelper::createFileFinder()} method instead, |
|
422 | - * which offers an object-oriented interface that is much easier |
|
423 | - * to use. |
|
424 | - * |
|
425 | - * @param string|PathInfoInterface|DirectoryIterator $targetFolder |
|
426 | - * @param string[] $extensions |
|
427 | - * @param array<string,mixed> $options |
|
428 | - * @throws FileHelper_Exception |
|
429 | - * @return string[] |
|
430 | - * |
|
431 | - * @see FileHelper::createFileFinder() |
|
432 | - * @deprecated Use the file finder instead. |
|
433 | - */ |
|
417 | + /** |
|
418 | + * Finds files according to the specified options. |
|
419 | + * |
|
420 | + * NOTE: This method only exists for backwards compatibility. |
|
421 | + * Use the {@see FileHelper::createFileFinder()} method instead, |
|
422 | + * which offers an object-oriented interface that is much easier |
|
423 | + * to use. |
|
424 | + * |
|
425 | + * @param string|PathInfoInterface|DirectoryIterator $targetFolder |
|
426 | + * @param string[] $extensions |
|
427 | + * @param array<string,mixed> $options |
|
428 | + * @throws FileHelper_Exception |
|
429 | + * @return string[] |
|
430 | + * |
|
431 | + * @see FileHelper::createFileFinder() |
|
432 | + * @deprecated Use the file finder instead. |
|
433 | + */ |
|
434 | 434 | public static function findFiles($targetFolder, array $extensions=array(), array $options=array()) : array |
435 | 435 | { |
436 | 436 | $finder = self::createFileFinder($targetFolder); |
@@ -460,14 +460,14 @@ discard block |
||
460 | 460 | return $finder->getAll(); |
461 | 461 | } |
462 | 462 | |
463 | - /** |
|
464 | - * Removes the extension from the specified path or file name, |
|
465 | - * if any, and returns the name without the extension. |
|
466 | - * |
|
467 | - * @param string $filename |
|
468 | - * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to. |
|
469 | - * @return string |
|
470 | - */ |
|
463 | + /** |
|
464 | + * Removes the extension from the specified path or file name, |
|
465 | + * if any, and returns the name without the extension. |
|
466 | + * |
|
467 | + * @param string $filename |
|
468 | + * @param bool $keepPath Whether to keep the path component, if any. Default PHP pathinfo behavior is not to. |
|
469 | + * @return string |
|
470 | + */ |
|
471 | 471 | public static function removeExtension(string $filename, bool $keepPath=false) : string |
472 | 472 | { |
473 | 473 | return self::getFileInfo($filename)->removeExtension($keepPath); |
@@ -488,49 +488,49 @@ discard block |
||
488 | 488 | return self::$unicodeHandling; |
489 | 489 | } |
490 | 490 | |
491 | - /** |
|
492 | - * Normalizes the slash style in a file or folder path, |
|
493 | - * by replacing any anti-slashes with forward slashes. |
|
494 | - * |
|
495 | - * @param string $path |
|
496 | - * @return string |
|
497 | - */ |
|
491 | + /** |
|
492 | + * Normalizes the slash style in a file or folder path, |
|
493 | + * by replacing any anti-slashes with forward slashes. |
|
494 | + * |
|
495 | + * @param string $path |
|
496 | + * @return string |
|
497 | + */ |
|
498 | 498 | public static function normalizePath(string $path) : string |
499 | 499 | { |
500 | 500 | return str_replace(array('\\', '//'), array('/', '/'), $path); |
501 | 501 | } |
502 | 502 | |
503 | - /** |
|
504 | - * Saves the specified data to a file, JSON encoded. |
|
505 | - * |
|
506 | - * @param mixed $data |
|
507 | - * @param string $file |
|
508 | - * @param bool $pretty |
|
509 | - * @throws FileHelper_Exception |
|
510 | - * |
|
511 | - * @see FileHelper::ERROR_JSON_ENCODE_ERROR |
|
512 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
513 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
514 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
515 | - */ |
|
503 | + /** |
|
504 | + * Saves the specified data to a file, JSON encoded. |
|
505 | + * |
|
506 | + * @param mixed $data |
|
507 | + * @param string $file |
|
508 | + * @param bool $pretty |
|
509 | + * @throws FileHelper_Exception |
|
510 | + * |
|
511 | + * @see FileHelper::ERROR_JSON_ENCODE_ERROR |
|
512 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
513 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
514 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
515 | + */ |
|
516 | 516 | public static function saveAsJSON($data, string $file, bool $pretty=false) : void |
517 | 517 | { |
518 | 518 | JSONFile::factory(self::getFileInfo($file)) |
519 | 519 | ->putData($data, $pretty); |
520 | 520 | } |
521 | 521 | |
522 | - /** |
|
523 | - * Saves the specified content to the target file, creating |
|
524 | - * the file and the folder as necessary. |
|
525 | - * |
|
526 | - * @param string $filePath |
|
527 | - * @param string $content |
|
528 | - * @throws FileHelper_Exception |
|
529 | - * |
|
530 | - * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
531 | - * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
532 | - * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
533 | - */ |
|
522 | + /** |
|
523 | + * Saves the specified content to the target file, creating |
|
524 | + * the file and the folder as necessary. |
|
525 | + * |
|
526 | + * @param string $filePath |
|
527 | + * @param string $content |
|
528 | + * @throws FileHelper_Exception |
|
529 | + * |
|
530 | + * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE |
|
531 | + * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE |
|
532 | + * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED |
|
533 | + */ |
|
534 | 534 | public static function saveFile(string $filePath, string $content='') : void |
535 | 535 | { |
536 | 536 | self::getFileInfo($filePath)->putContents($content); |
@@ -595,14 +595,14 @@ discard block |
||
595 | 595 | return $output; |
596 | 596 | } |
597 | 597 | |
598 | - /** |
|
599 | - * Retrieves the last modified date for the specified file or folder. |
|
600 | - * |
|
601 | - * Note: If the target does not exist, returns null. |
|
602 | - * |
|
603 | - * @param string $path |
|
604 | - * @return DateTime|NULL |
|
605 | - */ |
|
598 | + /** |
|
599 | + * Retrieves the last modified date for the specified file or folder. |
|
600 | + * |
|
601 | + * Note: If the target does not exist, returns null. |
|
602 | + * |
|
603 | + * @param string $path |
|
604 | + * @return DateTime|NULL |
|
605 | + */ |
|
606 | 606 | public static function getModifiedDate(string $path) : ?DateTime |
607 | 607 | { |
608 | 608 | $time = filemtime($path); |
@@ -642,70 +642,70 @@ discard block |
||
642 | 642 | ->getPaths(); |
643 | 643 | } |
644 | 644 | |
645 | - /** |
|
646 | - * Retrieves the maximum allowed upload file size, in bytes. |
|
647 | - * Takes into account the PHP ini settings <code>post_max_size</code> |
|
648 | - * and <code>upload_max_filesize</code>. Since these cannot |
|
649 | - * be modified at runtime, they are the hard limits for uploads. |
|
650 | - * |
|
651 | - * NOTE: Based on binary values, where 1KB = 1024 Bytes. |
|
652 | - * |
|
653 | - * @return int Will return <code>-1</code> if no limit. |
|
654 | - */ |
|
645 | + /** |
|
646 | + * Retrieves the maximum allowed upload file size, in bytes. |
|
647 | + * Takes into account the PHP ini settings <code>post_max_size</code> |
|
648 | + * and <code>upload_max_filesize</code>. Since these cannot |
|
649 | + * be modified at runtime, they are the hard limits for uploads. |
|
650 | + * |
|
651 | + * NOTE: Based on binary values, where 1KB = 1024 Bytes. |
|
652 | + * |
|
653 | + * @return int Will return <code>-1</code> if no limit. |
|
654 | + */ |
|
655 | 655 | public static function getMaxUploadFilesize() : int |
656 | 656 | { |
657 | 657 | return UploadFileSizeInfo::getFileSize(); |
658 | 658 | } |
659 | 659 | |
660 | - /** |
|
661 | - * Makes a path relative using a folder depth: will reduce the |
|
662 | - * length of the path so that only the amount of folders defined |
|
663 | - * in the <code>$depth</code> attribute are shown below the actual |
|
664 | - * folder or file in the path. |
|
665 | - * |
|
666 | - * @param string $path The absolute or relative path |
|
667 | - * @param int $depth The folder depth to reduce the path to |
|
668 | - * @return string |
|
669 | - */ |
|
660 | + /** |
|
661 | + * Makes a path relative using a folder depth: will reduce the |
|
662 | + * length of the path so that only the amount of folders defined |
|
663 | + * in the <code>$depth</code> attribute are shown below the actual |
|
664 | + * folder or file in the path. |
|
665 | + * |
|
666 | + * @param string $path The absolute or relative path |
|
667 | + * @param int $depth The folder depth to reduce the path to |
|
668 | + * @return string |
|
669 | + */ |
|
670 | 670 | public static function relativizePathByDepth(string $path, int $depth=2) : string |
671 | 671 | { |
672 | 672 | return PathRelativizer::relativizeByDepth($path, $depth); |
673 | 673 | } |
674 | 674 | |
675 | - /** |
|
676 | - * Makes the specified path relative to another path, |
|
677 | - * by removing one from the other if found. Also |
|
678 | - * normalizes the path to use forward slashes. |
|
679 | - * |
|
680 | - * Example: |
|
681 | - * |
|
682 | - * <pre> |
|
683 | - * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder'); |
|
684 | - * </pre> |
|
685 | - * |
|
686 | - * Result: <code>to/file.txt</code> |
|
687 | - * |
|
688 | - * @param string $path |
|
689 | - * @param string $relativeTo |
|
690 | - * @return string |
|
691 | - */ |
|
675 | + /** |
|
676 | + * Makes the specified path relative to another path, |
|
677 | + * by removing one from the other if found. Also |
|
678 | + * normalizes the path to use forward slashes. |
|
679 | + * |
|
680 | + * Example: |
|
681 | + * |
|
682 | + * <pre> |
|
683 | + * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder'); |
|
684 | + * </pre> |
|
685 | + * |
|
686 | + * Result: <code>to/file.txt</code> |
|
687 | + * |
|
688 | + * @param string $path |
|
689 | + * @param string $relativeTo |
|
690 | + * @return string |
|
691 | + */ |
|
692 | 692 | public static function relativizePath(string $path, string $relativeTo) : string |
693 | 693 | { |
694 | 694 | return PathRelativizer::relativize($path, $relativeTo); |
695 | 695 | } |
696 | 696 | |
697 | - /** |
|
698 | - * Checks that the target file exists, and throws an exception |
|
699 | - * if it does not. |
|
700 | - * |
|
701 | - * @param string|DirectoryIterator $path |
|
702 | - * @param int|NULL $errorCode Optional custom error code |
|
703 | - * @throws FileHelper_Exception |
|
704 | - * @return string The real path to the file |
|
705 | - * |
|
706 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
707 | - * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
|
708 | - */ |
|
697 | + /** |
|
698 | + * Checks that the target file exists, and throws an exception |
|
699 | + * if it does not. |
|
700 | + * |
|
701 | + * @param string|DirectoryIterator $path |
|
702 | + * @param int|NULL $errorCode Optional custom error code |
|
703 | + * @throws FileHelper_Exception |
|
704 | + * @return string The real path to the file |
|
705 | + * |
|
706 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
707 | + * @see FileHelper::ERROR_REAL_PATH_NOT_FOUND |
|
708 | + */ |
|
709 | 709 | public static function requireFileExists($path, ?int $errorCode=null) : string |
710 | 710 | { |
711 | 711 | return self::getPathInfo($path) |
@@ -728,18 +728,18 @@ discard block |
||
728 | 728 | ->getPath(); |
729 | 729 | } |
730 | 730 | |
731 | - /** |
|
732 | - * Reads a specific line number from the target file and returns its |
|
733 | - * contents, if the file has such a line. Does so with little memory |
|
734 | - * usage, as the file is not read entirely into memory. |
|
735 | - * |
|
736 | - * @param string $path |
|
737 | - * @param int $lineNumber Note: 1-based; the first line is number 1. |
|
738 | - * @return string|NULL Will return null if the requested line does not exist. |
|
739 | - * @throws FileHelper_Exception |
|
740 | - * |
|
741 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
742 | - */ |
|
731 | + /** |
|
732 | + * Reads a specific line number from the target file and returns its |
|
733 | + * contents, if the file has such a line. Does so with little memory |
|
734 | + * usage, as the file is not read entirely into memory. |
|
735 | + * |
|
736 | + * @param string $path |
|
737 | + * @param int $lineNumber Note: 1-based; the first line is number 1. |
|
738 | + * @return string|NULL Will return null if the requested line does not exist. |
|
739 | + * @throws FileHelper_Exception |
|
740 | + * |
|
741 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
742 | + */ |
|
743 | 743 | public static function getLineFromFile(string $path, int $lineNumber) : ?string |
744 | 744 | { |
745 | 745 | return self::getFileInfo($path) |
@@ -816,33 +816,33 @@ discard block |
||
816 | 816 | ->getLines($amount); |
817 | 817 | } |
818 | 818 | |
819 | - /** |
|
820 | - * Reads all content from a file. |
|
821 | - * |
|
822 | - * @param string $filePath |
|
823 | - * @throws FileHelper_Exception |
|
824 | - * @return string |
|
825 | - * |
|
826 | - * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
827 | - * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
828 | - */ |
|
819 | + /** |
|
820 | + * Reads all content from a file. |
|
821 | + * |
|
822 | + * @param string $filePath |
|
823 | + * @throws FileHelper_Exception |
|
824 | + * @return string |
|
825 | + * |
|
826 | + * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST |
|
827 | + * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS |
|
828 | + */ |
|
829 | 829 | public static function readContents(string $filePath) : string |
830 | 830 | { |
831 | 831 | return self::getFileInfo($filePath)->getContents(); |
832 | 832 | } |
833 | 833 | |
834 | - /** |
|
835 | - * Ensures that the target path exists on disk, and is a folder. |
|
836 | - * |
|
837 | - * @param string $path |
|
838 | - * @return string The real path, with normalized slashes. |
|
839 | - * @throws FileHelper_Exception |
|
840 | - * |
|
841 | - * @see FileHelper::normalizePath() |
|
842 | - * |
|
843 | - * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST |
|
844 | - * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
845 | - */ |
|
834 | + /** |
|
835 | + * Ensures that the target path exists on disk, and is a folder. |
|
836 | + * |
|
837 | + * @param string $path |
|
838 | + * @return string The real path, with normalized slashes. |
|
839 | + * @throws FileHelper_Exception |
|
840 | + * |
|
841 | + * @see FileHelper::normalizePath() |
|
842 | + * |
|
843 | + * @see FileHelper::ERROR_FOLDER_DOES_NOT_EXIST |
|
844 | + * @see FileHelper::ERROR_PATH_IS_NOT_A_FOLDER |
|
845 | + */ |
|
846 | 846 | public static function requireFolderExists(string $path) : string |
847 | 847 | { |
848 | 848 | return self::getFolderInfo($path) |