Re: Suggested change: change priority of new and ->
| From: | Andrea Faulds | Date: | Sun, 18 Feb 2018 23:47:23 +0000 |
| Subject: | Re: Suggested change: change priority of new and -> | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101887@lists.php.net to get a copy of this message | ||
Hi,
I'm not… quite sure if it changes anything, but it seems worth pointing out PHP has two syntaxes for
new. You can do new DateTime(), but you can /also/ do new DateTime without the brackets.
So, while you can't do new DateTime()->format(DATE_ATOM), you *can* do (new DateTime)->format(DATE_ATOM). This is just as short. It's only for constructor calls requiring arguments that we get the problem.
It also makes me wonder if it's not dereferenceable because then `new DateTime()` would be ambiguous: is it constructing a DateTime, or is it invoking a newly-constructed DateTime as a function? Be aware that __invoke can be implemented by a class to make its objects callable.
Thanks!
--
Andrea Faulds
https://ajf.me/