Assign return value of function to property or replace parse error with nice fatal error

php.internals

Khawer .

10 years ago
It would be better if we can assign return value of function to property. If not at least we should generate a nice error message. Currently when we try to assign return value of function to property we get the following error: Parse error: syntax error, unexpected '(', expecting ',' or ';' in index.php on line 4 We should replace this error with the following error: Fatal error: You must assign a static value to property in index.php on line 4. OR Fatal error: Dynamic values cannot be assigned to property in index.php on line 4.

Nikita Popov

10 years ago
On Mon, Jul 11, 2016 at 9:39 PM, Khawer . <khaweronline@gmail.com> wrote:
> It would be better if we can assign return value of function to property. > > If not at least we should generate a nice error message. > > Currently when we try to assign return value of function to property we get > the following error: > Parse error: syntax error, unexpected '(', expecting ',' or ';' in > index.php on line 4 > > We should replace this error with the following error: > Fatal error: You must assign a static value to property in index.php on > line 4. > OR > Fatal error: Dynamic values cannot be assigned to property in index.php on > line 4. >
Since PHP 7 the error message is: Fatal error: Constant expression contains invalid operations Nikita