Re: Re: Static weirdness..

From: Date: Wed, 18 Feb 2004 17:14:04 +0000
Subject: Re: Re: Static weirdness..
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-7959@lists.php.net to get a copy of this message
> imho, this is the expected behavior. At least a notice should be raised. > I do not see a reason to define $this if a method is explicitly defined > as static (means it should not be called dynamically). Declare the > same funciton as public|private|protected and everything works fine. There is no reason I can possibly imagine why methods declared as static should be allowed to be called from a non-static context. Sure, in my own classes I know not to call a method I declared as static from an instance. But IMO the whole point of static is to create a restriction in then engine keeping from anyone calling that function in anything other than a static context. class foo { static function bar() { echo "Hello.\n"; } function foobar(); } $a = new foo; $b->bar(); This is a completely acceptable thing, and it is IMO completely wrong to even allow in the engine. foo::bar() should be the only accepted syntax for static functions. If I download a new class from some site, or otherwise use someone else's code, how do I know other than digging through the source on a method's context? If $this isn't set I can't do the check, and if then engine doesn't do it there isn't a way to tell the difference. -- -=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=- John Coggeshall http://www.coggeshall.org/ The PHP Developer's Handbook http://www.php-handbook.com/ -=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=-

« previous php.internals (#7959) next »