You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API Platform version(s) affected:
I currently use api-platform/symfony in version 4.0.6
Description
The PHP8 return data type of the method is ignored. Only the old notation for annotations is taken into account.
You then get an error message when you call the whole thing via the API platform: Unexpected non-iterable value for to-many relation.
How to reproduce
I call a collection in my entity and only want to return a single item or null from it.
#[Groups(['Vehicles', 'readVehicle'])]
public function getDriver(): null|VehiclesDriver // null|VehiclesDriver is completly ignored
{
if (0 < count($this->getVehiclesDriver()))
foreach ($this->getVehiclesDriver() as $driver)
return $driver;
return null;
}
Possible Solution
Currently you can fix the error by returning the return type in the annotation.
/**
* @return VehiclesDriver|null
*/
#[Groups(['Vehicles', 'readVehicle'])]
public function getDriver(): null|VehiclesDriver
{
if (0 < count($this->getVehiclesDriver()))
foreach ($this->getVehiclesDriver() as $driver)
return $driver;
return null;
}
The text was updated successfully, but these errors were encountered:
API Platform version(s) affected:
I currently use api-platform/symfony in version 4.0.6
Description
The PHP8 return data type of the method is ignored. Only the old notation for annotations is taken into account.
You then get an error message when you call the whole thing via the API platform: Unexpected non-iterable value for to-many relation.
How to reproduce
I call a collection in my entity and only want to return a single item or null from it.
Possible Solution
Currently you can fix the error by returning the return type in the annotation.
The text was updated successfully, but these errors were encountered: