实体数组的正确类型提示是什么?

时间:2017-07-28 09:27:09

标签: php symfony type-hinting

我的symfony控制器中有一个数组,如下所示:

let code = theUsersCodeFragment;

import ForeignClass from code;

render() {
    return <MyContainer> 
                <ForeignClass name={"John"}>
           </MyContainer>
}

我现在把它带到这样的函数:

$schedules = $em->getRepository('AppBundle:Hours')->findBy(
    array(
        'id' => $request->get('ids'),
    ),
        array(
            'start' => 'ASC',
            'status' => 'ASC'
        )
    );

并且函数需要这样的参数:

$result = $this->get('app.wiki')->generateInvoice($schedules, $request->get('invoice'));`

很明显,该函数需要function generateInvoice(Hours $schedules, $invoiceNo) { foreach ($schedules as $schedule) { ... } ... } 的单个实体,但却得到一个数组。如何更改参数以期望Hours数组,例如Hours或类似的。

function generateInvoice(Hours[] $schedules, $invoiceNo)有效,但不完全是我想要的。

0 个答案:

没有答案