2017-03-12 13:58 GMT+05:00 Sherif Ramadan <theanomaly...@gmail.com>:

> I think you're trying desperately to find a problem that is fitting of
the proposal

Checks in business logic are popular task.

> If the problem you're trying to solve pertains to object state that I
have no idea how this proposal hopes to achieve that. You can readily
control object state in PHP without the need for declarative types (e.g.
magic getters/setters)

I described in first message the way how the proposal can help with this.
There is no magic getters/setters there.

> Not seeing how this proposal improves or even achieves such a thing.

Now we need to write in business logic the following:

function checkout(Order $order)
{
    if (count($order->products) > 0) {
        throw new SomeException1();
    }
    if ($order->date === null) {
        throw new SomeException2();
    }
    if ($order->address === null) {
        throw new SomeException3();
    }

    // checkout steps
    ...
    someActionWithOrderForCheckout($order);
    ...
}

function someActionWithOrderForCheckout(Order $order)
{
    if (count($order->products) > 0) {
        ...
    }
    if ()
    ...
}


Of course, we can move all checks to some function like
'ensureOrderIsReadyForCheckout()' and call it everywhere manually.
But this is the same as call is_integer() manually instead of type hinting.

Reply via email to