PHP Sadness

(<5.4) Cannot chain lookups/calls

Prior to PHP 5.4 (untested, but according to the patch notes), you must very often put values into a variable before using it for something else:

// works
$c = new ReflectionClass("test");
var_dump($c->getProperty('thing'));

// fails in lexer
var_dump((new ReflectionClass("test"))->getProperty('thing'));
// Parse error: syntax error, unexpected T_OBJECT_OPERATOR in ...

The same problem goes for array indexes:

$ php -r 'function_call("argument")["array_lookup"]'

Parse error: syntax error, unexpected '[' in Command line code on line 1

Significance: Chaining

The ability to chain function calls, array lookups, property accesses, and so on is important to being able to write clean, concise code. Requiring the developer to needlessly create extra temporary variables merely to pass a value from one language construct to another encourages lengthy, messy code which is costly to change and difficult to follow.