I have no idea why, but after a few (unrelated) changes all my returns are objects instead of arrays. For example:
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();
}
Returns:
{"0":{"email":"[email protected]","first_name"...
While i would expect [{"email":"[email protected]","first_name"... ?
So it returns an object with multiple objects in it instead of an array.
But that's weird, because all my functions are typed to return array's, and I don't get any errors?
{"code":500,"message":"Warning: get_class() expects parameter 1 to be object, array given"}. Interesting.