Am 13.01.2009 um 22:58 schrieb Marcus Boerger:

5) A closure assigned to a property can be called directly rather
than just by a temporary variable:
$obj->property = function() {}
$obj->property();  // valid call

This will get us into trouble IMHO, as it would not behave too well with
 __get/__set and __call. I.e. if we have $foo->nosuchproperty() -
should we call __get or __call? So far variables implemented through
__get behave exactly like ones implemented through definition - but I
don't understand how to reconcile it with this.

Why would you call __get() here? Becasue I did that by mistake in my very
first mail? You clearly have a function call and thus you only go for
__call(). As of today you can already do:

function __call($name, $args) {
 if ($this->properties[$name] instanceof 'Closure') {
   return call_user_func_array($this->property[$name], $args);
 }
}

Now we already have callable properties - directly callable.

1. method
2. __call()
3. property
4. __get()

that would be a reasonable calling order, or:

1. method
2. property
3. __call()
4. __get()

In any case, a "real" method (existing one or __call() overload) should have precedence over a closure in a property.

Wouldn't that work?

- David

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to