We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
of()
Seeing this example:
$users = type($users)->as(Collection::class);
Really wants me to append an ->of(User::class) to make sure a Collection<User> is returned.
->of(User::class)
Collection<User>
This could be also be used for arrays: type($users)->asArray()->of(User::class)
type($users)->asArray()->of(User::class)
The text was updated successfully, but these errors were encountered:
I've been experimenting with a dedicated IterableType class. We could resolve it similar to not(), but that might be a bit verbose:
IterableType
not()
type($variable)->iterable()->asArray()->of(User::class);
Alternatively we could introduce a function that returns an IterableType instance:
iterable($variable)->asArray()->of(User::class); iterable($variable)->as(Collection::class)->of(User::class);
Sorry, something went wrong.
How would you suggest dealing with the key?
Maybe something like this:
iterable($variable)->as(Collection::class)->of(User::class, 'int'); // or... iterable($variable)->as(Collection::class)->key('int')->value(User::class);
No branches or pull requests
Seeing this example:
Really wants me to append an
->of(User::class)
to make sure aCollection<User>
is returned.This could be also be used for arrays:
type($users)->asArray()->of(User::class)
The text was updated successfully, but these errors were encountered: