Hey Larry,

On Tue, May 5, 2020 at 5:29 PM Larry Garfield <la...@garfieldtech.com>
wrote:

> The biggest use case I see is, as discussed previously, value object
> constructors.  "Pass an entirely untyped and undocumentable array of
> parameters" is not an sufficient userland solution in my mind, but is the
> only available alternative right now.
>

This is easily mitigated by named constructors (
https://verraes.net/2014/06/named-constructors-in-php/), which are a
good/established practice among those using value objects.

You can create multiple (meaningful) constructor signatures depending on
use-case, which is still a much safer approach than delegating this
responsibility to a caller.

My example above uses a `::fromArray()` "factory" precisely for that
purpose.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

Reply via email to