The error was added in PHP7, and I have a problem with code such as:
(some complex expression)->my_property = 1
Note that I assign the field of the object, not the object itself (assigning to a temporary object does not make sense, I agree, but here it is not ).
This gives me the error "cannot use a temporary expression in the context of the record." When I rewrite this as:
$tmp = (some complex expression); $tmp->my_property = 1;
Everything is fine. The problem is that I have to have one expression (assignment is an expression), and since PHP does not support the comma operator, now I'm fried with two operators .
This is a huge difference for me, because I cannot pass all the code as an expression further. Everything is valid inside this "complex expression", so I would just like to disable this check in PHP.
Is it possible? How?
My code is written automatically (it is generated), and the result of the expression is a valid PHP object, the problem in PHP for some reason does not notice it. In addition, the second form works.
Update: This is an example of the complex expression mentioned above:
(($a = foo()) === 0 ? $a : bar())
source share