It's really annoying that you can't do any of these things (and it doesn't make any sense that you can't):
new A('foo')->bar();
(new A('foo'))->bar();
The only thing I could think of is to have a static function to return a new object
public static function get($a) {
return new self($a);
}
// ...
A::get('foo')->bar();
But that's just ugly. The reason why I need this is because in the context of the object definition I mostly pass the new object as parameter or as part of an array:
new B(array(
new A('foo')->bar()
new A('smt')->bar()->more()
));
bar() and more() of course return a reference to the object.