在 PHP 7.1 下使用以下代码
class MySqlSessionHandler implements \SessionHandlerInterface {
public function read(string $session_id) : string { ... }
}
我得到:
致命错误:Sessions\MySqlSessionHandler::read(string $session_id) 声明:字符串必须与 SessionHandlerInterface::read($key) 兼容
当我删除类型声明“字符串”而不是像
public function read($session_id) : string { ... }
不抛出异常。所有其他 SessionHandlerInterface 函数也是如此。阅读 PHP 文档类型字符串应该是正确的。
怎么了 ?