1 | <?php |
||
17 | class FileUtility |
||
18 | { |
||
19 | /** |
||
20 | * Write a file and create the target folder, if the folder do not exists. |
||
21 | * |
||
22 | * @param string $absoluteFileName |
||
23 | * @param string $content |
||
24 | * |
||
25 | * @throws Exception |
||
26 | * |
||
27 | * @return bool |
||
28 | */ |
||
29 | public static function writeFileAndCreateFolder($absoluteFileName, $content) |
||
41 | |||
42 | /** |
||
43 | * Get all base file names in the given directory with the given file extension |
||
44 | * Check also if the directory exists. |
||
45 | * |
||
46 | * @param string $dirPath |
||
47 | * @param string $fileExtension |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | public static function getBaseFilesInDir($dirPath, $fileExtension) |
||
55 | |||
56 | /** |
||
57 | * Get all base file names in the given directory with the given file extension |
||
58 | * Check also if the directory exists. |
||
59 | * |
||
60 | * @param string $dirPath |
||
61 | * @param string $fileExtension |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | public static function getBaseFilesWithExtensionInDir($dirPath, $fileExtension) |
||
69 | |||
70 | /** |
||
71 | * Get all base file names in the given directory with the given file extension |
||
72 | * Check also if the directory exists. If you scan the dir recursively you get |
||
73 | * also the folder name. The filename is also "basename" only. |
||
74 | * |
||
75 | * @param string $dirPath |
||
76 | * @param string $fileExtensions |
||
77 | * @param bool $recursively |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public static function getBaseFilesRecursivelyInDir($dirPath, $fileExtensions, $recursively = true) |
||
96 | |||
97 | /** |
||
98 | * Get file information in the given folder. |
||
99 | * |
||
100 | * @param string $dirPath |
||
101 | * @param string $fileExtension |
||
102 | * @param int $informationType |
||
103 | * |
||
104 | * @return array |
||
105 | */ |
||
106 | protected static function getFileInformationInDir($dirPath, $fileExtension, $informationType) |
||
118 | } |
||
119 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.