Re: late static binding php6
| From: | Mike Lively | Date: | Mon, 19 Nov 2007 06:44:03 +0000 |
| Subject: | Re: late static binding php6 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33315@lists.php.net to get a copy of this message | ||
Jochem Maas wrote:
> Stanislav Malyshev wrote:
>
>>> Rest assured that this is not the bad kind of 'more complex' I believe
>>>
>> I'm afraid I must disagree. The feature that was missing was to know the
>> true calling class name. That was implemented. You can build from it,
>> there's no need to add further complication to the language. You can
>> easily find out the calling class for static call, you can easily find
>> it's parent, provided one exists, you can easily call any method of this
>> class.
>>
>
> class A {
> static function find($id) {
> // lets try and find a 'something'
> }
> }
>
> class B extends A {}
>
> // I'd like a 'B' please bob.
> $b = B::find( 1 );
>
>
>
> are you saying that A::find() can tell that it was called as B::find() ?
>
No, your example would work. WHere it breaks down is if you want to
specialize B::find();
class B extends A {
static function find($id) {
/* do something special */
parent::find($id);
}
}
in that situation A::find(); would not be able to know it was being
called by B::find() because parent:: is considered an explicit class
name reference.