On 6/23/08, Stanislav Malyshev <[EMAIL PROTECTED]> wrote:
> Hi!
>
>
> > why would anyone need that?
> >
>
>  To use function that does use static without dependence on in which context
> if was called (or, explaining it other way, when your chain of inheritance
> serves multiple purposes):
>
>  class ActiveRecord {
>         static function getRow($condition) {
>                 $table = new Table(get_called_class());
>                 return $table->find($condition);
>         }
>  }
>
>  class Users extends ActiveRecord {
>  }
>
>  class DepartmentUsers extends Users {
>         static function find($user) {
>                 if(self::user_in_department($user)) {
>                         return parent::getRow("user=$user");
>                 }
>                 return false;
>         }
>  }
>
>  $user = DepartmentUsers::find("bob");
>
>  Now in this case if your way is implemented, ActiveRecord would try to find
> table for DepartmentUsers, which probably does not exist. You would have to
> name Users by name there to do what this code wants to do, which leads us
> back to "why we have parent:: at all" argument.

in my ActiveRecord, table for DepartmentUsers would actually exist ;)

> > "parent" is related to inheritance and it is logical, that it retains
> > call-chain.
> >
>
>  It is "logical" if you look at it with the narrow point of view of what you
> need for your particular application. However, there are other use cases.
> Automatic forwarding may become very awkward if you have multiple levels of
> inheritance not all of them used for the same thing.

I am just looking for consistency. I am expecting get_called_class()
to work as a static analog of get_class(this)

-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.com/

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

Reply via email to