[5.0] Defer Query Builder Bindings Intil The Query Is Being Compiled

The old design of adding bindings as clauses are added to the query worked most of the time had two major issues:
 1. For some complex queries, like unions or sub queries involving joins, the bindings fail to apply or are applied in the wrong order. See #5833 for examples.
 1. Cleanly removing global scopes that introduced bindings is impossible to guarantee, especially if other global scopes are in use.

To fix this we take a very simple approach to defer assigning the query bindings until the query is being compiled. This has two effects:
 1. Query bindings are guaranteed to be added in the same order that the sql string is concatenated.
 1. When removing global scopes you don't need to worry about removing bindings. Just remove the appropriate query clauses and the bindings will be taken care of at compile time.



I never said that at all. I've always said it would be very hard to correctly document all of laravel's coding standards, and isn't worth the effort. People should just read any code that taylor commits to get a feel for how he formats the code.