Re: Call non-static method staticly raise E_STRICT, but why call a static method instancely won't
| From: | David Muir | Date: | Tue, 26 Apr 2011 02:31:25 +0000 |
| Subject: | Re: Call non-static method staticly raise E_STRICT, but why call a static method instancely won't | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52011@lists.php.net to get a copy of this message | ||
On 26/04/11 09:37, Ben Schmidt wrote:
>> Back in PHP4 it was the only way to "simulate" an static call, but
>> nowadays it really don't make sense at all.
>>
>> class Foo {
>> static function toString(Bar $bar) {
>> return 'Foo::toString($bar)';
>> }
>> function toString() {
>> return '$this->toString()';
>> }
>> }
>>
>> $foo = new Foo();
>> echo $foo->toString(); // instance
>> echo Foo::toString(); // class
>>
>> PHP will complain about the 2nd method (can't redefine function) but
>> for me
>> are 2 completely different methods.
>> I belive the current Object Model could be improved. isn't?
>
> I agree. Backward compatibility is the only reason to keep this. It's a
> pretty compelling reason, though. It's hard to know how to phase it out
> "non-invasively", too.
>
> Ben.
>
>
Why not just deprecate it, and throw a E_STRICT warning? That's how
we're dealing with all other future BC breaks.
David