2017-06-22 89 views

回答

0

这是诀窍吗? private static function myfun( string $param1, :xhp $param2=null, ): :xhp { return //somethinf }

+0

不,它不工作:/ –

1

为了能够通过null英寸,您的类型提示必须允许它。在Hack中,这是通过使用nullable type完成的。

private static function myfun(
    string $param1, 
    ?:xhp $param2, 
): :xhp { 
    return 
     //somethinf 
} 

然后哈克类型检查还将确保您检查$param2不使用它之前空。

相关问题