Hi!

$methodName)) instead, which is ugly and verbose. Since PHP 5.3 adds closure support, I think the syntax "$o->f()" should also check whether "f" is a closure, if it is, then call it.

That creates a myriad of problems due to the fact that if the class defines both __call and __get it is not clear what should happen.

As PHP is a dynamic language, it might be acceptable to dynamically change the "fixed template" nature of class, especially when programming
> PHP in prototype-based way by using class as "object" (which I think is

It might be, but in this particular language it isn't. PHP, unlike Javascript, is not a prototype-based language, and the classes are common between objects.

Yes I mean abstract static function here, sorry for my typo. Abstract static function is meaningful: You can force child class to implement it, and combining it with "Late Static Binding" one can implement "Template Method Pattern" in prototype-based way here:

It's kind of complicated to do because unlike the case with objects, a::g and c::g are different functions. So what happens if somebody tries to call a::g?
You can do that with interfaces though.
Also, the idea of having common base is usually that you expose the base class (a) as an API, and then implement it in certain ways which are hidden from the client, as he works with base type (a) only. However, in this case it obviously can not work, since a::g can't call anything, and for calling real name you have to know specific class name.

<?php
interface i {
    static function f();
}
class c implements i {
    public static function f() {
        echo 'c';
    }
}
function g(i $i) {
    var_dump($i);
}
g('c');
?>

This result is more or less expected since type hinting only works on variable types, and the argument 'c' is a string, but as a type, the interface i cannot hint the fact that class c "is a type of i".

I'm not sure what you are trying to do here, but this code can not work - you ask for an object of type i and you pass string. I could guess you meant to ask for a name of a class that would implement interface i - but that is not supported by the language currently, as class is not an object in PHP. You would have to run your own code to do that, e.g. using is_subclass_of().
--
Stanislav Malyshev, Zend Software Architect
s...@zend.com   http://www.zend.com/
(408)253-8829   MSN: s...@zend.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to