这个语法是什么意思:方法中的 bool 是什么意思?

What does this syntax : bool in the method mean?

我在我的一个项目中使用了包名 laravel-google-calander。当我检查包的代码时,我发现下面的方法的语法为:

public function exists(): bool
   {
       return $this->id != '';
   }

:bool 在方法中代表什么?它是 php7 的新语法还是其他任何东西?

谢谢

是的,这是 return type declaration 的 PHP 7 语法。它将确保 return 值为布尔值。