bastinald / malzahar

A magic PHP framework. Build reactive web apps without writing HTML, CSS, or JavaScript! Powered by Tailwind, Alpine, Laravel, & Livewire.
27 stars 8 forks source link

[Question] Type for items prop in EachStatement::class #2

Closed ghost closed 3 years ago

ghost commented 3 years ago

I'm done with type declarations and docblocks across the package with the exception of the EachStatement

Currently the $items prop is able to accept either an array or a Collection

I'm wondering if it wouldn't be better to declare this as a Collection since we're using Laravel. This would require a user to wrap any raw array in collect() before passing it in, but I think having it as typed declaration is better than worrying about this one tiny extra step.

I'm gonna submit the pull request this way and document it, if you don't want it that way then of course you can edit the request.

bastinald commented 3 years ago

It needs to accept an array, sometimes people just want to use arrays for their items.

We can just always turn it into a collection in the method itself, but it needs to allow basic arrays with indexes or associative.