From 1f2cafdead6a8cf8821abe970f2be9ed2c043629 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 10 Jan 2012 12:45:04 -0500 Subject: [PATCH] Added reflection class --- modules/welcome/controllers/welcome.php | 9 ++++ modules/welcome/models/welcome_model.php | 2 +- sys/common.php | 1 + sys/r.php | 64 ++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 sys/r.php diff --git a/modules/welcome/controllers/welcome.php b/modules/welcome/controllers/welcome.php index 9601cbe..2cbe222 100644 --- a/modules/welcome/controllers/welcome.php +++ b/modules/welcome/controllers/welcome.php @@ -23,4 +23,13 @@ class Welcome extends MM_Controller { $this->output->set_output($output); } + + function reflect() + { + $this->r = new R($this); + + $obj = $this->r->get_all(); + + $this->output->set_output($this->__toString('print_r', $obj)); + } } \ No newline at end of file diff --git a/modules/welcome/models/welcome_model.php b/modules/welcome/models/welcome_model.php index d3f4e40..b8b6b95 100644 --- a/modules/welcome/models/welcome_model.php +++ b/modules/welcome/models/welcome_model.php @@ -1,6 +1,6 @@ $name)) + { + //Add $this object to args + array_push($args, $this); + + //Call the dynamic function + return call_user_func_array($this->$name, $args); + } + } + + /** + * Retrieve as much information about the class as possible + */ + public function get_all() + { + $this->methods = $this->getMethods(); + $this->properties = $this->getProperties(); + $this->doc_comments = $this->getDocComment(); + $this->parent_class = $this->getParentClass(); + $this->static_properties = $this->getStaticProperties(); + $this->internal = (int)$this->isInternal(); + + return $this; + } + +} \ No newline at end of file