Hey David,
On Fri, Feb 12, 2021, 20:24 David Rodrigues <david.proweb@gmail.com> wrote:
> Hello!
>
> It is just a suggestion to be discussed.
>
> A lot of places on my projects I have codes like:
>
> $companies = $user->companies->count()
> ? new Collection($user->companies)
> : null;
>
Even upfront, this looks like a quite bad idea: either you have an empty
collection, or you have a collection with elements in it, but null is a
very different concept that isn't homogeneous with the resulting type.
I've updated multiple projects in the past where array|null was used as
return type for a collection-alike endpoint, removing null and replacing
it with an empty iterable instead.
>