I'm fetching entities with Doctrine and using it to hydrate the results as arrays. The problem is, I'm not sure how to create annotations for this kind of return:
@return annotation of method \App\Repository\UserRepository::findOneByIdAsArray() does not specify type hint for items of its traversable return value.
How I'm suppose to annotate a return array with a lot of types?
I could use something like this:
/**
* @return (string|int|bool)[]
*/
But if the source entity object changes ( UserEntity
), this annotation will not be correct.
I could also do something like this:
/**
* @return UserEntity[]
*/
But I don't think its correct because I'm not returning the objects themselves, but the array version of their values.
How should I proceed?
Separate multiple types by | and using [] in the end to specify it's an array.
Something like:
/**
* @return string|int|bool|UserEntity[]
*/
Preferably you use the full namepsace for UserEntity.
/**
* @return string|int|bool|\My\Namespace\UserEntity[]
*/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.