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) |
||
44 | |||
45 | /** |
||
46 | * Get all base file names in the given directory with the given file extension |
||
47 | * Check also if the directory exists. |
||
48 | * |
||
49 | * @param string $dirPath |
||
50 | * @param string $fileExtension |
||
51 | * |
||
52 | * @return array |
||
53 | */ |
||
54 | public static function getBaseFilesInDir($dirPath, $fileExtension) |
||
58 | |||
59 | /** |
||
60 | * Get all base file names in the given directory with the given file extension |
||
61 | * Check also if the directory exists. |
||
62 | * |
||
63 | * @param string $dirPath |
||
64 | * @param string $fileExtension |
||
65 | * |
||
66 | * @return array |
||
67 | */ |
||
68 | public static function getBaseFilesWithExtensionInDir($dirPath, $fileExtension) |
||
72 | |||
73 | /** |
||
74 | * Get all base file names in the given directory with the given file extension |
||
75 | * Check also if the directory exists. If you scan the dir recursively you get |
||
76 | * also the folder name. The filename is also "basename" only. |
||
77 | * |
||
78 | * @param string $dirPath |
||
79 | * @param string $fileExtensions |
||
80 | * @param bool $recursively |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | public static function getBaseFilesRecursivelyInDir($dirPath, $fileExtensions, $recursively = true) |
||
99 | |||
100 | /** |
||
101 | * Get file information in the given folder. |
||
102 | * |
||
103 | * @param string $dirPath |
||
104 | * @param string $fileExtension |
||
105 | * @param int $informationType |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | protected static function getFileInformationInDir($dirPath, $fileExtension, $informationType) |
||
121 | } |
||
122 |
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.