hi!
I have the first draft of PHP 5 reflection API ready. You can find it at:
http://www.gravitonic.com/software/php/reflection.txt
Comments and suggestions are appreciated.
First of all, why isn't InterfaceType base class for ClassType, since,
in fact, class is an interface, and every method of InterfaceType is
in fact present in the ClassType (except for the getParentInterface()
which is named getParentClass in ClassType, but could easily be named
getParent in both classes, or the getParentInterface() could be
"non-virtual" in the InterfaceType class...)
Second, why aren't some of the methods from ClassType available in the
InterfaceType, when they are clearly valid there. Some of them include:
class InterfaceType {
// ... that suggested stuff in RFC
// and my stuff below
// same as ClassType::getInterfaces()
// but not sure about this one.. didn't really understand if
// Interface can "implement", or extend more than one
// Interface... (and BTW, if they cant, they should ;)
function getInterfaces();
// same as ClassType::hasInterface($name)
// look the note in the previous method
function hasInterface($name);
// same as ClassType::getModifiers()
// the RFC states "currently only ABSTRACT" which doesn't apply
// to Interfaces, but might be usable later when/if more
// modifiers are added
function getModifiers();
// same as ClassType::isInstanceOf()
// but with a slightly different meaning. it would return if $obj is
// an instance of a Class that implements this Interface (and
// thus, can safely be looked at as an "instance" of this Interface)
function isInstanceOf($obj);
// same as ClassType::invokeMethod()
function invokeMethod($name, $obj, $params);
} // end InterfaceType
that's it for now..
- zombie - Tomica Jovanovic - tomica@mbox.co.yu
- As we anarchists say: There's no government like no government.
First of all, why isn't InterfaceType base class for ClassType, since,
in fact, class is an interface, and every method of InterfaceType is
in fact present in the ClassType (except for the getParentInterface()
which is named getParentClass in ClassType, but could easily be named
getParent in both classes, or the getParentInterface() could be
"non-virtual" in the InterfaceType class...)
True. I'll think about having ClassTypep inherit from InterfaceType.
Second, why aren't some of the methods from ClassType available in the
InterfaceType, when they are clearly valid there. Some of them include:class InterfaceType {
// same as ClassType::getInterfaces() // but not sure about this one.. didn't really understand if // Interface can "implement", or extend more than one // Interface... (and BTW, if they cant, they should ;) function getInterfaces();
Doesn't make sense. An interface can extend only one interface.
// same as ClassType::hasInterface($name) // look the note in the previous method function hasInterface($name);
See above.
// same as ClassType::getModifiers() // the RFC states "currently only ABSTRACT" which doesn't apply // to Interfaces, but might be usable later when/if more // modifiers are added function getModifiers();
Interfaces don't have any modifiers.
// same as ClassType::isInstanceOf() // but with a slightly different meaning. it would return if $obj is // an instance of a Class that implements this Interface (and // thus, can safely be looked at as an "instance" of this Interface) function isInstanceOf($obj);
I guess this would be nice.
-Andrei http://www.gravitonic.com/
If you find a job that you love, you'll
never work another day in your life.
- Mark Jackson