// 文件或目录是否存在
public static function exists($path): bool
{
return file_exists($path);
}
这里的 : bool 有必要吗?感谢!
// 文件或目录是否存在
public static function exists($path): bool
{
return file_exists($path);
}
这里的 : bool 有必要吗?感谢!
|
1
感觉你这个函数就没有必要…
|
|
simple2025Jun 22, 2021
2
@Trim21 可能只是为了函数别名
|
|
3
有必要,虽然现代 IDE 已经很聪明,这种情况即使不声明,也能知道他是返回 bool 。
|
|
4
何止声明有必要, 函数名还得改成 isExist 让人看到名字都知道这是个 bool
|
|
CodeCodeStudyJun 23, 2021
5
有必要,对人的阅读和 IDE 的识别非常有帮助,可以易于排查程序中的错误
|
|
back0893Jun 28, 2021
6
可以
|