Go to the documentation of this file.00001 <?php
00010 class nReflection extends ReflectionClass {
00011
00017 public function __construct($elt='object') {
00018 if (is_object($elt))
00019 $this->rebuild(get_class($elt));
00020 else if ($elt)
00021 $this->rebuild($elt);
00022 }
00023
00030 public function rebuild($name) {
00031 try {
00032 parent::__construct($name);
00033 return true;
00034 } catch(Exception $e) {
00035 return false;
00036 }
00037 }
00038
00045 public function newInstanceCfg(config $cfg) {
00046 return parent::newInstance($cfg);
00047 }
00048
00055 public function isSubclassOf($className) {
00056 return parent::isSubclassOf(new nReflection($className));
00057 }
00058
00064 public function getPublicProperties() {
00065 $publicProps = array();
00066
00067 $props = $this->getProperties();
00068 foreach($props as $p) {
00069 if ($p->isPublic())
00070 $publicProps[] = $p->getName();
00071 }
00072
00073 return $publicProps;
00074 }
00075
00084 public static function getParentsClass($className) {
00085 return class_parents($className);
00086 }
00087
00097 public static function callMethod($object, $function, $args=array()) {
00098 $ref = new nReflection($object);
00099 if ($ref->hasMethod($function)
00100 && ($meth = $ref->getMethod($function))
00101 && $meth->isPublic()) {
00102 if (!is_array($args)) {
00103 if (!empty($args))
00104 $args = array($args);
00105 else
00106 $args = array();
00107 }
00108 return $meth->invokeArgs($object, $args);
00109 }
00110 throw new nException('Method not callable');
00111 }
00112
00113 }