19
19
use Toolkit \FsUtil \Parser \JsonParser ;
20
20
use Toolkit \FsUtil \Parser \YamlParser ;
21
21
use Toolkit \FsUtil \Traits \FileSnippetReadTrait ;
22
+ use function basename ;
22
23
use function dirname ;
23
24
use function file_get_contents ;
24
25
use function file_put_contents ;
28
29
use function is_string ;
29
30
use function stat ;
30
31
use function strlen ;
32
+ use function strstr ;
31
33
32
34
/**
33
35
* Class File
@@ -56,7 +58,7 @@ abstract class File extends FileSystem
56
58
*
57
59
* @return string
58
60
*/
59
- public static function getName ($ file , $ clearExt = false ): string
61
+ public static function getName (string $ file , $ clearExt = false ): string
60
62
{
61
63
$ filename = basename (trim ($ file ));
62
64
@@ -66,12 +68,12 @@ public static function getName($file, $clearExt = false): string
66
68
/**
67
69
* 获得文件扩展名、后缀名
68
70
*
69
- * @param $filename
71
+ * @param string $filename
70
72
* @param bool $clearPoint 是否带点
71
73
*
72
74
* @return string
73
75
*/
74
- public static function getSuffix ($ filename , $ clearPoint = false ): string
76
+ public static function getSuffix (string $ filename , $ clearPoint = false ): string
75
77
{
76
78
$ suffix = strrchr ($ filename , '. ' );
77
79
@@ -98,7 +100,7 @@ public static function getExtension($path, $clearPoint = false): string
98
100
*
99
101
* @return string eg: image/gif
100
102
*/
101
- public static function mimeType ($ file ): string
103
+ public static function mimeType (string $ file ): string
102
104
{
103
105
return finfo_file (finfo_open (FILEINFO_MIME_TYPE ), $ file );
104
106
}
@@ -182,7 +184,7 @@ public static function load(string $src, string $format = self::FORMAT_PHP)
182
184
* @return array
183
185
* @throws FileNotFoundException
184
186
*/
185
- public static function loadPhp ($ file , $ throwError = true ): array
187
+ public static function loadPhp (string $ file , $ throwError = true ): array
186
188
{
187
189
$ ary = [];
188
190
0 commit comments