diff --git a/backend/lib/controller/frontcontroller.php b/backend/lib/controller/frontcontroller.php index 6557272..507e08a 100644 --- a/backend/lib/controller/frontcontroller.php +++ b/backend/lib/controller/frontcontroller.php @@ -28,18 +28,18 @@ final class FrontController { $response = new HttpResponse(); // create view instance - $rc = new ReflectionClass($request->get['format'] . 'View'); - if (!$rc->isSubclassOf('View')) { - throw new InvalidArgumentException('\'' . $rc->getName() . '\' is not a valid View'); + $view = $request->get['format'] . 'View'; + if (!is_subclass_of($view, 'View')) { + throw new InvalidArgumentException('\'' . $view . '\' is not a valid View'); } - $this->view = $rc->newInstanceArgs(array($request, $response)); + $this->view = new $view($request, $response); // create controller instance - $rc = new ReflectionClass($request->get['controller'] . 'Controller'); - if (!$rc->isSubclassOf('Controller')) { - throw new InvalidArgumentException('\'' . $rc->getName() . '\' is not a valid Controller'); + $controller = $request->get['controller'] . 'Controller'; + if (!is_subclass_of($controller, 'Controller')) { + throw new InvalidArgumentException('\'' . $controller . '\' is not a valid controller'); } - $this->controller = $rc->newInstanceArgs(array($this->view)); + $this->controller = new $controller($this->view); } public function run() { diff --git a/backend/lib/model/channel.php b/backend/lib/model/channel.php index fce59f5..9bb7127 100644 --- a/backend/lib/model/channel.php +++ b/backend/lib/model/channel.php @@ -157,12 +157,10 @@ abstract class Channel extends DatabaseObject implements ChannelInterface { * create new channel instance by given database query result */ final static protected function factory($object) { - $rc = new ReflectionClass($object['type']); - if (!$rc->isSubclassOf('Channel')) { - throw new InvalidArgumentException('\'' . $rc->getName() . '\' is not a valid channel type'); + if (!is_subclass_of($object['type'], 'Channel')) { + throw new InvalidArgumentException('\'' . $object['type'] . '\' is not a valid channel type'); } - - return $rc->newInstanceArgs(array($object)); + return new $object['type']($object); } /* diff --git a/backend/lib/model/database.php b/backend/lib/model/database.php index 4ca0b16..8780d94 100644 --- a/backend/lib/model/database.php +++ b/backend/lib/model/database.php @@ -158,7 +158,7 @@ interface DatabaseInterface { public function escapeString($string); public function escape($value); - + public function lastInsertId(); } @@ -194,12 +194,10 @@ abstract class Database implements DatabaseInterface { if (is_null(self::$connection)) { $config = Registry::get('config'); - $rc = new ReflectionClass($config['db']['backend']); - if (!$rc->isSubclassOf('Database')) { - throw new InvalidArgumentException('\'' . $rc->getName() . '\' is not a valid database backend'); + if (!is_subclass_of($config['db']['backend'], 'Database')) { + throw new InvalidArgumentException('\'' . $config['db']['backend'] . '\' is not a valid database backend'); } - - self::$connection = $rc->newInstanceArgs(array($config['db'])); + self::$connection = new $config['db']['backend']($config['db']); } return self::$connection; @@ -215,7 +213,7 @@ abstract class Database implements DatabaseInterface { else { $value = '\'' . $this->escapeString($value) . '\''; } - + return $value; } }