Jochem Maas wrote:
I have discovered behaviour which I imagine is not intended, name referencing $this in a static method that is called from a from the method of an instantiated. (see test code below.)
error_reporting(E_ALL & E_STRICT);
I'm sure you mean E_ALL | E_STRICT here ...
Class A { function test() { print_r( __CLASS__ );echo "\n"; print_r( __METHOD__ );echo "\n"; print_r( $this );echo "\n"; } }
Class B { function test() { A::test(); } }
This behaviour is intentional for methods that are not defined as static. Also, as inherited methods are called using the parent:: syntax, this is the only way to call overridden methods without losing $this from scope along the way.
-- Ard
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php