【发布时间】:2016-02-21 02:40:45
【问题描述】:
<?hh //strict
foreach ($list as $id) {
$items = new DestinationsByCountry($id);
$remapped = $items->byKey('destination_id')->map($stringed ==> (int) $stringed);
$this->ids->addAll($remapped);
}
foreach ($list as $id) {
$this->ids->addAll(
// ******* error line below *******
new DestinationsByCountry($id)
->byKey('destination_id')
->map($stringed ==> (int) $stringed)
);
}
对于类型检查器来说两者都可以,但第二个导致致命错误
致命错误:语法错误,意外的 T_OBJECT_OPERATOR,期待 ')'
【问题讨论】:
-
在 PHP 中这是非法语法,可以使用
(new DestinationsByCountry($id))->byKey ...解决 - 不确定这是否适用于 hacklang? -
谢谢,这是我的错。这适用于hacklang。我只是对类型检查器对此感到困惑。
标签: hacklang