stackphp/builder — pull request #12 by igorw (2014-11-20 00:32:07+00:00)
Title: Assume Terminable middlewares will delegate (fixes #10)

This is a much simpler and cheaper solution than #11.

We are defining terminables to never be conditional. They must always delegate. This makes it safe to always call them.

Now we must prevent terminables from being called more than once. If we assume that a terminable will delegate to the next terminable middleware in the chain, we can skip terminate calls while the previous middleware was terminable.

We only need to kick off the chain for two cases:

* If the first element in the chain is terminable
* Any terminable followed by a non-terminable