Given a class A with a member function f(), the following apparently reasonable code:
( new A() )->f();
Fails with a syntax error: “unexpected T_OBJECT_OPERATOR”.
Is there an explanation for this?
Edit: As Mageek guessed, I’m trying to make sense of this behaviour; I already know how to work around it.
This is only available as of PHP 5.4. Until then you have to assign the instance to a variable and use that.
See: http://www.php.net/manual/en/migration54.new-features.php