PHP 5.4

PHP 5.4 is the next major version of PHP after the PHP 5.3 that we currently require. PHP 5.3 gave us a number of things like closures, namespaces, and late static binding. PHP 5.4 adds a number of new features: http://php.net/manual/en/migration54.changes.php

Once we're able to require PHP 5.4 there are some things we can start doing.

TContextSource (traits)
We can use the new traits feature can now be used in RequestContext. Instead of being stuck with the ContextSource class we can implement a TContextSource trait. Context sources with parent classes would then be able to use the trait instead of having to reimplement a bunch of junk since it can't extend ContextSource.

Our ContextSource class can even become something as small as this.

WebRequest (magic_quotes_gpc)
With magic_quotes_gpc gone WebRequest will no longer need to modify $_COOKIE, $_ENV, $_GET, $_POST, $_REQUEST, and $_SERVER. WebRequest::checkMagicQuotes and WebRequest::fix_magic_quotes can disappear entirely.

As a bonus result thanks to the fact that WebRequest doesn't need to be constructed early on to modify these variables we can stop constructing it inside of Setup.php and can add it properly when the main context is setup.

safe_mode
safe_mode was removed so we won't need to do any more checks for it anymore.

register_globals
register_globals is gone too, WebStart.php will no longer need this mass of code:

parse_url
parse_url now supports protocol relative urls. We won't need to hack around this as much.

$this in Closures
$this is now handled correctly in closures. So cases where we might not have been able to use closures in the past because of needing to use private or protected methods or members can now use closures.

short array syntax
The short array syntax  in place of   is now supported.

Array dereferencing
trapped me several times.