类型限定

示例:

1
2
3
4
public function onRequest(?string $action): ?bool
{
return parent::onRequest($action); // TODO: Change the autogenerated stub
}

已上示例表示传入的参数$action 可以是 null 或者字符串,不能是其他类型。同理:返回值只能是 bool 或者 null。