/** * @param mixed $instance * @return mixed Same instance always returned */ public function loadInstance($instance) { $reflection = new \ReflectionClass($instance); while ($reflection) { if ($this->isAutoloadClass($reflection)) { $this->propertyConnector->connect($reflection, $instance); $this->methodConnector->connect($reflection, $instance); } $reflection = $reflection->getParentClass(); } return $instance; }
/** * @param MethodConnector $connector * @param string $type * @return mixed */ private function invokeConnect(MethodConnector $connector, $type) { $instance = new $type(); $connector->connect(new \ReflectionClass($type), $instance); return $instance; }