Re: __invoke() weirdness
| From: | Ionut Gabriel Stan | Date: | Mon, 29 Dec 2008 00:18:14 +0000 |
| Subject: | Re: __invoke() weirdness | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42392@lists.php.net to get a copy of this message | ||
PHP written in a JavaScript style is already possible with PHP 5.3. I started a little
thread about this on a forum but didn't get that much feedback:
http://www.sitepoint.com/forums/showthread.php?t=565576
It's not really what we're used to in JavaScript but it's very close.
On 12/25/2008 07:11, Lars Strojny wrote:
Hi David, Am Dienstag, den 23.12.2008, 17:02 +0100 schrieb David Zülke: [...]This gives a fatal "Call to undefined method DateTime::getAtom()"This is the same as the following: $obj = new stdClass(); $obj->method = function() {$d = new DateTime(); $d->getAtom = Curry::create(array($d, 'format'), DATE_ATOM); echo $d->getAtom();return "foo";}; $obj->method(); The first "method" is a property, the call to "method" is - well - a method call. Because PHP separates methods and properties in the class entry structure - and because we have magic methods like __set, __get and __call, there is no efficient and logical way how to search for properties with closure instances when a method is not found. We discussed that before and decided to let closures go out into the wild and think about adding a solution for prototype alike inheritance later. cu, Lars