Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

untymage's avatar

Cast all array in php into collection by default

Hello this is weird question, Is it possible to make php to return collection when array returned? because i find my doing same thing in all methods: return collect($data)

0 likes
3 replies
Snapey's avatar

create collections in the first place, not $data

untymage's avatar

i mean making php return collection instead of raw array "In all application" automaticly

Sinnbeck's avatar

Can you show an example of where you are doing it manually?

Please or to participate in this conversation.