Inheritance and a class function: on what class was it called?

From: Date: Wed, 02 Oct 2002 17:29:19 +0000
Subject: Inheritance and a class function: on what class was it called?
Groups: php.general 
Request: Send a blank email to php-general+get-118620@lists.php.net to get a copy of this message
Assume you've got some class that has one or more classes inherited from it. The parent class has a function that is normally called using the :: operator (a class function). Assume also that the class function is never called from an object function. Is it possible to find if the class function was called on the parent class, or on the child class? example: Class A has a function foo(), callable by A::foo(). Class B extends A. If outside code makes the call B::foo(), can you tell from within foo() that the function was called on B and not A? I think this is impossible but I want to confirm that suspicion. It's important that the call B::foo() isn't made from inside any object function, so that there's no context for the $this variable; the get_class() function isn't applicable.

« previous php.general (#118620) next »