私は何故か分かりませんが、いくつかの(無関係な)変更の後では、すべての戻り値が配列ではなくオブジェクトです。symfonyのdoctrineは配列の代わりにオブジェクトを返します
ReceiptController.php
/**
* Get all receipts for the team.
*
* @param String $id
* @return array
*
* @SWG\Response(
* response=201,
* description="Get all receipt for the team.",
* @SWG\Schema(
* type="array"
* )
*)
*/
public function getTeamReceiptsAction($id): array
{
$parameterBag = [
'teamId' => $id
];
$items = $this->manager->getAll($parameterBag);
return $items;
}
Receiptrepository
/**
* @inheritdoc
*/
public function getFilterQuery($parameterBag): QueryBuilder
{
$qb = $this
->createQueryBuilder('s')
;
if (isset($parameterBag['id'])) {
$qb->andWhere('s.id=(:id)')
->setParameter('id', $parameterBag['id']);
}
if (isset($parameterBag['teamId'])) {
$qb->andWhere('s.team=(:team)')
->setParameter('team', $parameterBag['teamId']);
}
return $qb;
}
/**
* @inheritdoc
*/
public function getAll($parameterBag): ?array
{
$qb = $this->getFilterQuery($parameterBag);
return $qb->getQuery()->getResult();
}
戻り値:たとえば {"0":{"email":"[email protected]","first_name"...
私は[{"email":"[email protected]","first_name"...
を期待するだろうが?
したがって、配列ではなく複数のオブジェクトを含むオブジェクトを返します。
しかし、私のすべての関数は配列を返すように型付けされているので、何かエラーはありません。これに
return $qb->getQuery()->getResult();
:
ダンプを実行する(get_class($ items))とseそれはどんな種類のものか。さまざまな配列インタフェースを実装するオブジェクトであり、配列型のテストに合格します。 – Cerad
私は、次の内部エラーを受け取ります: '{" code ":500、" message ":警告:get_class()は、パラメータ1がオブジェクトであり、配列が"} 'であると想定しています。 興味深い。 – user3634184