dpi / pinto

0 stars 1 forks source link

Add list of slots to Slots object type #20

Open dpi opened 22 hours ago

dpi commented 22 hours ago

Currently only reflection is supported.

Instead we should support an iterable parameter on #[Slots], which may take enums or strings, alongside default values.

E.g

#[Slots(slots: [
  \An\Enum::Case,
  'a_slot',
])]
final class ThemeObject {}
dpi commented 6 hours ago

An iterable collection (Weakmap or SplObjectStorage) cannot have objects and strings as keys simultaneously, so default values could be iterable values. Another object is required to capture whether the slot needs a default value. This object should also be an attribute which can be used on the [#Slots] entry point in order for it to become a explicit opt in of parameters to slots. Where at least one parameter having this attribute forces the opt in.