Example #1
0
 public function load()
 {
     $files = $this->_getFiles();
     $manifestRegistry = ZendL_Tool_Rpc_Manifest_Registry::getInstance();
     $providerRegistry = ZendL_Tool_Rpc_Provider_Registry::getInstance();
     $classesLoadedBefore = get_declared_classes();
     $oldLevel = error_reporting(E_ALL | ~E_STRICT);
     // remove strict so that other packages wont throw warnings
     foreach ($files as $file) {
         require_once $file;
     }
     error_reporting($oldLevel);
     // restore old error level
     $classesLoadedAfter = get_declared_classes();
     $loadedClasses = array_diff($classesLoadedAfter, $classesLoadedBefore);
     foreach ($loadedClasses as $loadedClass) {
         $reflectionClass = new ReflectionClass($loadedClass);
         if ($reflectionClass->implementsInterface('ZendL_Tool_Rpc_Manifest_Interface') && !$reflectionClass->isAbstract()) {
             $manifestRegistry->addManifest($reflectionClass->newInstance());
         }
         if ($reflectionClass->implementsInterface('ZendL_Tool_Rpc_Provider_Interface') && !$reflectionClass->isAbstract()) {
             $providerRegistry->addProvider($reflectionClass->newInstance());
         }
     }
 }
Example #2
0
 /**
  * @return object
  */
 protected function createEntity()
 {
     if (!$this->entityClassReflection) {
         $this->entityClassReflection = new \ReflectionClass($this->entityClassName);
     }
     return $this->entityClassReflection->newInstance();
 }
 public function display($url)
 {
     $data = (object) json_decode(file_get_contents('php://input'), true);
     $reflection = new ReflectionClass($data->_type);
     if ($reflection->isSubclassOf('DataSource')) {
         $object = $reflection->newInstance();
         $object->parameters()->{'root-element'} = 'data';
         foreach ($data->_parameters as $key => $value) {
             $object->parameters()->{$key} = $value;
         }
         $result = $object->render(new Register());
         header('content-type: text/xml');
         echo $result->saveXML();
         exit;
     }
     if ($reflection->isSubclassOf('Event')) {
         $object = $reflection->newInstance();
         $object->parameters()->{'root-element'} = 'data';
         foreach ($data->_parameters as $key => $value) {
             $object->parameters()->{$key} = $value;
         }
         $result = $object->trigger(new Register(), (array) $data->_data);
         header('content-type: text/xml');
         echo $result->saveXML();
         exit;
     }
 }
Example #4
0
 public static function getModuleInstanceByTypeAndName($sType, $sName)
 {
     if (!$sName) {
         throw new Exception("Exception in Module::getModuleInstanceByTypeAndName(): module name is empty");
     }
     $sClassName = self::getClassNameByTypeAndName($sType, $sName);
     if (!self::isModuleEnabled($sType, $sName)) {
         throw new Exception("Exception in Module::getModuleInstanceByTypeAndName(): tried to instanciate disabled module {$sType}.{$sName}");
     }
     $aArgs = array_slice(func_get_args(), 2);
     $oClass = new ReflectionClass($sClassName);
     if ($sClassName::isSingleton()) {
         if (!isset(self::$SINGLETONS[$sClassName])) {
             try {
                 self::$SINGLETONS[$sClassName] = $oClass->newInstanceArgs($aArgs);
             } catch (ReflectionException $ex) {
                 self::$SINGLETONS[$sClassName] = $oClass->newInstance();
             }
         }
         return self::$SINGLETONS[$sClassName];
     }
     try {
         return $oClass->newInstanceArgs($aArgs);
         //Does not work in PHP < 5.1.3
     } catch (ReflectionException $ex) {
         return $oClass->newInstance();
         //Does not work in PHP < 5.1.3
     }
 }
function test($class)
{
    echo "====>{$class}\n";
    try {
        $ref = new ReflectionClass($class);
    } catch (ReflectionException $e) {
        var_dump($e->getMessage());
        return;
        // only here
    }
    echo "====>newInstance()\n";
    try {
        var_dump($ref->newInstance());
    } catch (ReflectionException $e) {
        var_dump($e->getMessage());
    }
    echo "====>newInstance(25)\n";
    try {
        var_dump($ref->newInstance(25));
    } catch (ReflectionException $e) {
        var_dump($e->getMessage());
    }
    echo "====>newInstance(25, 42)\n";
    try {
        var_dump($ref->newInstance(25, 42));
    } catch (ReflectionException $e) {
        var_dump($e->getMessage());
    }
    echo "\n";
}
Example #6
0
 /**
  * Create validator
  *
  * @param $validator
  * @return \Phalcon\Validation\ValidatorInterface
  * @throws \Engine\Exception
  */
 public function createValidator($validator)
 {
     if ($validator instanceof ValidatorInterface) {
         return $validator;
     } elseif (is_array($validator)) {
         $origName = ucfirst($validator['validator']);
         if ($class = $this->getValidatorClassName($origName)) {
             if (empty($validator['options'])) {
                 $validator = new $class();
             } else {
                 $r = new \ReflectionClass($class);
                 if ($r->hasMethod('__construct')) {
                     $validator = $r->newInstance($validator['options']);
                 } else {
                     $validator = $r->newInstance();
                 }
             }
         }
     } elseif (is_string($validator)) {
         $origName = ucfirst($validator);
         if ($class = $this->getValidatorClassName($origName)) {
             $validator = new $class();
         }
     } else {
         throw new \Engine\Exception("Validator '{$validator}' not exists");
     }
     return $validator;
 }
Example #7
0
 /**
  * @param array|null $args
  *
  * @return object
  */
 function invoke(array $args = null)
 {
     if ($args !== null) {
         return $this->reflectionClass->newInstanceArgs($args);
     }
     return $this->reflectionClass->newInstance();
 }
Example #8
0
 public function testGetSingle()
 {
     $singletags = ['br', 'clear', 'col', 'hr', 'xkcd'];
     $method = $this->reflectionClass->getMethod('getSingle');
     $this->parser = $this->reflectionClass->newInstance();
     $this->assertEquals($singletags, $method->invoke($this->parser));
 }
 /**
  *
  * @param string $class
  * @return BaseController
  */
 protected function instantiateController($class)
 {
     $reflection = new \ReflectionClass($class);
     if ($reflection->isSubclassOf('Tracker\\Controller\\BaseController')) {
         return $reflection->newInstance($this->app);
     }
     return $reflection->newInstance();
 }
Example #10
0
 /**
  * Метод формирует экземпляр класса на основе строки.
  * После будет применён фильтр, если он есть.
  * 
  * @return object
  */
 private function getInst(array $row)
 {
     if ($this->constructorParams) {
         $args = $this->constructorParams;
         $args[] = $row;
         return $this->RC->newInstanceArgs($args);
     } else {
         return $this->RC->newInstance($row);
     }
 }
 /**
  * @see \RecursiveIterator:getChildren();
  */
 public function getChildren()
 {
     if ($this->current() instanceof self) {
         return $this->current();
     }
     if (empty($this->ref)) {
         $this->ref = new \ReflectionClass($this);
     }
     return $this->ref->newInstance($this->current() . '/');
 }
Example #12
0
 /**
  * Creates a new instance for the class
  */
 public static function createInstance($className, $args = [])
 {
     $reflection = new \ReflectionClass($className);
     if ($reflection->implementsInterface('App\\Interfaces\\SingletonInterface')) {
         if (isset(self::$singletones[$className])) {
             return self::$singletones[$className];
         } else {
             $instance = $args ? $reflection->newInstanceArgs($args) : $reflection->newInstance();
             self::$singletones[$className] = $instance;
         }
     } else {
         $instance = $args ? $reflection->newInstanceArgs($args) : $reflection->newInstance();
     }
     return $instance;
 }
 /**
  * @param mixed   $id
  * @param boolean $forceInstance Whether returns an empty instance when no result
  *
  * @return StaticEntity|null
  */
 public function get($id, $forceInstance = false)
 {
     if (array_key_exists($id, $this->instances)) {
         return $this->instances[$id];
     } elseif (!($data = $this->getData($id))) {
         return $forceInstance ? $this->reflection->newInstance() : null;
     }
     $this->instances[$id] = $this->reflection->newInstance();
     foreach ($data as $property => $value) {
         $reflectionProperty = $this->reflection->getProperty($property);
         $reflectionProperty->setAccessible(true);
         $reflectionProperty->setValue($this->instances[$id], $value);
     }
     return $this->instances[$id];
 }
Example #14
0
 public function Deserialize($Root)
 {
     $result = null;
     $counter = 0;
     foreach ($Root as $member) {
         $instance = new ReflectionClass($member->getName());
         $ins = $instance->newInstance();
         foreach ($member as $child) {
             $rp = $instance->getMethod("set_" . $child->getName());
             if (count($child->children()) == 0) {
                 $rp->invoke($ins, $child);
             } else {
                 $rp->invoke($ins, $this->Deserialize($child->children()));
                 echo $child;
             }
         }
         if (count($Root) == 1) {
             return $ins;
         } else {
             $result[$counter] = $ins;
             $counter++;
         }
         if ($counter == count($Root)) {
             return $result;
         }
     }
 }
Example #15
0
 /**
  * Instantiates objects by class and id, respecting pattern implemented by given class
  * 
  * @param string $class Class name
  * @param $id
  * @return unknown_type
  */
 public static function instantiate($class, $id = null)
 {
     if (!strlen($class)) {
         require_once 'Oops/Exception.php';
         throw new Oops_Exception("Empty class name given");
     }
     if (!Oops_Loader::find($class)) {
         require_once 'Oops/Exception.php';
         throw new Oops_Exception("Class '{$class}' not found");
     }
     $reflectionClass = new ReflectionClass($class);
     if ($reflectionClass->implementsInterface('Oops_Pattern_Identifiable_Factored_Interface')) {
         /**
          * Object can be instantiated using corresponding factory
          */
         $factoryCallback = call_user_func($class, 'getFactoryCallback');
         $result = call_user_func($factoryCallback, $id);
     } elseif ($reflectionClass->implementsInterface('Oops_Pattern_Identifiable_Singleton_Interface')) {
         /**
          * This object can be instantiated using $class::getInstance($id)
          */
         $result = call_user_func(array($class, 'getInstance'), $id);
     } elseif ($reflectionClass->implementsInterface('Oops_Pattern_Singleton_Interface')) {
         /**
          * This object is the single available instance of this class, so it can be instantiated using $class::getInstance()
          */
         $result = call_user_func(array($class, 'getInstance'));
     } else {
         /**
          * This type of object should be constructed with given $id
          */
         $result = $reflectionClass->newInstance($id);
     }
     return $result;
 }
Example #16
0
 protected function setUp()
 {
     $this->wrapper = m::mock('Raideer\\TwitchApi\\Wrapper');
     $this->wrapper->shouldReceive('registerResource')->with('Raideer\\TwitchApi\\Resources\\Resource');
     $resourceReflection = new \ReflectionClass($this->resourceName);
     $this->resource = $resourceReflection->newInstance($this->wrapper);
 }
 /**
  * @return ControllerResponse
  * @throws Page404Exception
  * @throws RuntimeMvcException
  */
 public function execute()
 {
     $class = $this->getControllerClass();
     try {
         $reflectionClass = new \ReflectionClass($class);
         if ($reflectionClass->implementsInterface(ControllerInterface::class)) {
             /** @var ControllerInterface $controller */
             $controller = $reflectionClass->newInstance();
             $controller->setReflectionClass($reflectionClass);
             $this->getResponse()->setControllerInstance($controller);
             $controller->setDi($this->container);
             $reflectionMethod = new \ReflectionMethod($class, $this->getActionCamelize());
             $controller->setReflectionAction($reflectionMethod);
             $controller->setNamespace($this->getNamespace());
             $controller->setName($this->getController());
             $controller->setAction($this->getAction());
             $controller->setParams($this->getParams());
             $controller->beforeExecute();
             $this->response->setControllerContent($reflectionMethod->invokeArgs($controller, $this->getParams()));
             $controller->afterExecute();
             $this->container->get('event')->dispatch(MvcEvent::ON_AFTER_RUN, new MvcEvent($controller));
         } else {
             throw new RuntimeMvcException('Controller found but it should implemented interface [:name]', ['name' => ControllerInterface::class]);
         }
     } catch (\ReflectionException $exception) {
         $this->container->get('event')->dispatch(MvcEvent::ON_PAGE_404, new MvcEvent($this));
         $this->container->get('event')->dispatch(MvcEvent::ON_ACTION_ERROR, new MvcEvent($exception));
         throw new Page404Exception($exception->getMessage());
     } catch (\Exception $exception) {
         $this->container->get('event')->dispatch(MvcEvent::ON_ACTION_ERROR, new MvcEvent($exception));
         throw new RuntimeMvcException($exception->getMessage());
     }
     return $this->response;
 }
Example #18
0
 protected static function getEntityManager($options)
 {
     $config = new \Doctrine\ORM\Configuration();
     // Handling for class names specified as platform types.
     if ($options['conn']['platform']) {
         $class_obj = new \ReflectionClass($options['conn']['platform']);
         $options['conn']['platform'] = $class_obj->newInstance();
     }
     // Special handling for the utf8mb4 type.
     if ($options['conn']['driver'] == 'pdo_mysql' && $options['conn']['charset'] == 'utf8mb4') {
         $options['conn']['platform'] = new \DF\Doctrine\Platform\MysqlUnicode();
     }
     $metadata_driver = $config->newDefaultAnnotationDriver($options['modelPath']);
     $config->setMetadataDriverImpl($metadata_driver);
     $cache = new \DF\Doctrine\Cache();
     // $cache->setNamespace('doctrine_');
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $config->setResultCacheImpl($cache);
     $config->setProxyDir($options['proxyPath']);
     $config->setProxyNamespace($options['proxyNamespace']);
     if (isset($options['conn']['debug']) && $options['conn']['debug']) {
         $config->setSQLLogger(new \DF\Doctrine\Logger\EchoSQL());
     }
     $config->addFilter('softdelete', '\\DF\\Doctrine\\Filter\\SoftDelete');
     $config->addCustomNumericFunction('RAND', '\\DF\\Doctrine\\Functions\\Rand');
     $evm = new \Doctrine\Common\EventManager();
     $em = \Doctrine\ORM\EntityManager::create($options['conn'], $config, $evm);
     $em->getFilters()->enable("softdelete");
     // Try the connection before rendering the page.
     $em->getConnection()->connect();
     return $em;
 }
Example #19
0
 /**
  * @dataProvider getClass
  */
 public function testGetterAndSetter($class, $constructorParameterList)
 {
     $reflexionClass = new \ReflectionClass($class);
     if ($reflexionClass->getConstructor()) {
         $instance = $reflexionClass->newInstanceArgs($constructorParameterList);
     } else {
         $instance = $reflexionClass->newInstance();
     }
     $propertyList = $reflexionClass->getProperties();
     foreach ($propertyList as $property) {
         $name = ucfirst($property->getName());
         $property->setAccessible(true);
         $getter = 'get' . $name;
         $setter = 'set' . $name;
         if ($reflexionClass->hasMethod($setter)) {
             $type = $this->guessParamType($reflexionClass->getMethod($setter));
             if (isset($this->valueList[$type])) {
                 $value = $this->valueList[$type];
                 $instance->{$setter}($value[0]);
                 // test setter
                 $this->assertEquals($property->getValue($instance), $value[0]);
                 if ($reflexionClass->hasMethod($getter)) {
                     $property->setValue($instance, $value[1]);
                     // test getter
                     $this->assertEquals($instance->{$getter}(), $value[1]);
                 }
             }
         }
     }
 }
Example #20
0
 public function dispatch(\Ctv\Route\Route $router, $response)
 {
     $controllerName = ucwords($router->getParams('controller'));
     $namespace = ucwords($router->getParams('App')) . '\\Controller\\' . $controllerName;
     if (\Ctv\Autoloader\App::validate($namespace)) {
         $reflection = new \ReflectionClass($namespace);
         if ($reflection->hasMethod($router->getParams('action'))) {
             $method = $reflection->getMethod($router->getParams('action'));
             $controller = $reflection->newInstance($router, $response);
             if ($args = $router->getParams('args')) {
                 $method->invokeArgs($controller, $args);
             } else {
                 $method->invoke($controller);
             }
             $this->__callOutPut($controller);
             //$this->close();
         } else {
             echo outformat($namespace, 'trace');
             echo outformat($router, 'trace');
             echo $router;
             die('Method not exists' . $namespace);
         }
     } else {
         echo $namespace . 'error 404';
     }
     die;
 }
 public function create(ProviderModel $provider)
 {
     $eventDispatcher = $this->getEventDispatcher();
     $event = new CreateProviderEvent($provider);
     $eventDispatcher->dispatch(EVENT_XNAVIGATION_CREATE_PROVIDER, $event);
     if ($event->getProvider()) {
         return $event->getProvider();
     }
     $row = $provider->row();
     $type = $provider->type;
     $className = $this->getProviderClassName($type);
     $class = new \ReflectionClass($className);
     $subscriber = $class->newInstance();
     $rgxp = '~^' . preg_quote($type, '~') . '_(.*)$~';
     foreach ($row as $key => $value) {
         if ($value && preg_match($rgxp, $key, $matches)) {
             $property = $matches[1];
             $property = explode('_', $property);
             $property = array_map('ucfirst', $property);
             $property = implode('', $property);
             $setterName = 'set' . $property;
             if ($class->hasMethod($setterName)) {
                 $setter = $class->getMethod($setterName);
                 $setter->invoke($subscriber, $value);
             }
         }
     }
     return $subscriber;
 }
Example #22
0
 /**
  * Set captcha adapter
  * 
  * @param string|array|Zend_Captcha_Adapter $captcha
  * @param array $options
  */
 public function setCaptcha($captcha, $options = array())
 {
     if ($captcha instanceof Zend_Captcha_Adapter) {
         $instance = $captcha;
     } else {
         if (is_array($captcha)) {
             if (array_key_exists('captcha', $captcha)) {
                 $name = $captcha['captcha'];
                 unset($captcha['captcha']);
             } else {
                 $name = array_shift($captcha);
             }
             $options = array_merge($options, $captcha);
         } else {
             $name = $captcha;
         }
         $name = $this->getPluginLoader(self::CAPTCHA)->load($name);
         if (empty($options)) {
             $instance = new $name();
         } else {
             $r = new ReflectionClass($name);
             if ($r->hasMethod('__construct')) {
                 $instance = $r->newInstanceArgs(array($options));
             } else {
                 $instance = $r->newInstance();
             }
         }
     }
     $this->_captcha = $instance;
     $this->_captcha->setName($this->getName());
     return $this;
 }
Example #23
0
 /**
  * 创建该类型的实例,并从指定对象或数组上复制属性
  * @param object|array $src 原始对象或数组
  * @return object
  */
 static function create($src)
 {
     $class = new ReflectionClass(get_called_class());
     $target = $class->newInstance();
     ObjectUtil::copyProperties($src, $target);
     return $target;
 }
Example #24
0
 /**
  * Constructor
  *
  * @param string|object $base_class Class name of the base class, or an instance
  * @param array $constructor_args (Optional) Arguments to pass to the constructor of the base class
  * @param array $constants (Optional) Constants to override
  */
 public function __construct($base_class, array $constructor_args = array(), array $constants = array())
 {
     // @codeCoverageIgnoreStart
     if (PHP_VERSION_ID < 50300) {
         trigger_error(get_class() . ': This class requires PHP version 5.3 or higher.', E_USER_ERROR);
     }
     // @codeCoverageIgnoreEnd
     if (is_object($base_class) && count($constructor_args)) {
         throw new Mollie_Testing_Exception('Unused constructor arguments for passed instance of "' . get_class($base_class) . '".');
     }
     // If it's an instance, just accept it
     if (is_object($base_class)) {
         $this->_base_class = $base_class;
     } elseif (!class_exists($base_class)) {
         throw new Mollie_Testing_Exception("Base class '{$base_class}' does not exist.");
     } else {
         $ref = new ReflectionClass($base_class);
         if ($ref->isAbstract()) {
             $ref = new ReflectionClass($this->createDerivedClass($base_class));
         }
         if ($ref->getConstructor() && count($constructor_args) < $ref->getConstructor()->getNumberOfRequiredParameters()) {
             throw new Mollie_Testing_Exception($ref->getConstructor()->getNumberOfRequiredParameters() . " constructor arguments required for '{$base_class}::__construct(...)'.");
         }
         $this->_base_class = sizeof($constructor_args) ? $ref->newInstanceArgs($constructor_args) : $ref->newInstance();
     }
 }
Example #25
0
 /**
  * @see Lumine_Validator_AbstractValidator::execute()
  */
 public function execute(Lumine_Base $obj)
 {
     $value = $this->getFieldValue($obj);
     $reflection = new ReflectionClass($obj->metadata()->getClassname());
     /* @var $objeto Lumine_Base */
     $objeto = $reflection->newInstance();
     $objeto->{$this->getField()} = $obj->{$this->getField()};
     $objeto->find();
     $pks = $objeto->metadata()->getPrimaryKeys();
     $result = true;
     while ($objeto->fetch()) {
         foreach ($pks as $def) {
             if ($objeto->{$def}['name'] != $obj->{$def}['name']) {
                 $result = false;
                 break;
             }
         }
         if (!$result) {
             break;
         }
     }
     $objeto->destroy();
     unset($objeto, $reflection);
     return $result;
 }
Example #26
0
/**
 *  Whatever Data is returned by Hanlder, should be an array will be rendered as array on response
 * 
 * @param AbstractUser $user
 * @param array $controllerInfo
 * @param String $handlerName
 */
function rx_interceptor_json($user, $controllerInfo, $handlerName)
{
    $user->validate();
    include_once RUDRA . "/core/handler/AbstractHandler.php";
    $handlerInfo = ClassUtil::getHandler($handlerName);
    if ($handlerInfo != NULL) {
        global $temp;
        include_once $handlerInfo["filePath"];
        $className = $handlerInfo["className"];
        $tempClass = new ReflectionClass($className);
        if ($tempClass->isInstantiable()) {
            $temp = $tempClass->newInstance();
        }
        if ($temp != NULL) {
            try {
                if ($tempClass->hasMethod("invokeHandler")) {
                    $resp = call_method_by_class($tempClass, $temp, 'invokeHandler', array('user' => $user, 'data' => new RequestData(get_request_param("data"))), $handlerInfo["requestParams"]);
                    if (isset($resp)) {
                        echo json_encode($resp);
                    }
                }
            } catch (Exception $e) {
                echo json_encode(array("error" => $e));
            }
        }
    }
}
Example #27
0
 /**
  * Framework runner, create object from User Application Controller
  *
  * Instance call init() and isMapTrue(). If isMapTrue is True, it will return method name.
  */
 public static function execute()
 {
     $class_controller = Service::$active_controller;
     if ($class = new ReflectionClass($class_controller)) {
         $object = $class->newInstance();
         $object->init();
         $request_method = $object->getRequestMethod();
         $request_uri = $object->getRequestURI();
         if ($action = $object->isMapTrue($request_method, $request_uri)) {
             $data = $class->getMethod($action)->invoke($object);
             $object->reply($data);
         } else {
             $object->setRestResponse('406', 'application/xml');
             $data = "<application>\n";
             $data .= "<error>Not Acceptible. Action Method Not Found</error>\n";
             $data .= "</application>\n";
             $object->reply($data);
         }
     } else {
         $object->setRestResponse('400', 'application/xml');
         $data = "<application>\n";
         $data .= "<error>Bad Request</error>\n";
         $data .= "</application>\n";
         $object->reply($data);
     }
 }
 public function parse_string($template, $data = array(), $return = FALSE, $config = array())
 {
     if (!is_array($config)) {
         $config = array();
     }
     $config = array_merge($this->config, $config);
     $ci = $this->ci;
     $is_mx = false;
     if (!$return) {
         list($ci, $is_mx) = $this->detect_mx();
     }
     $parser_reflection = new ReflectionClass('Leafo\\ScssPhp\\Compiler');
     $parser = $parser_reflection->newInstance();
     $parser->setImportPaths($config['import_paths']);
     $parser->setNumberPrecision($config['number_precision']);
     $formatter = $config['formatter'];
     if (!in_array($formatter, $this->allowed_formatters)) {
         $formatter = 'expanded';
     }
     $formatter = 'Leafo\\ScssPhp\\Formatter\\' . ucfirst($formatter);
     $parser->setFormatter($formatter);
     $parser->setLineNumberStyle($config['line_number_style']);
     $template = $parser->compile($template);
     return $this->output($template, $return, $ci, $is_mx);
 }
 /**
  * Resolves the target of the route and returns a callable.
  *
  * @param mixed $target
  * @param array $construct_args
  *
  * @throws RuntimeException If the target is not callable
  *
  * @return callable
  */
 private static function getCallable($target, array $construct_args)
 {
     if (is_string($target)) {
         //is a class "classname::method"
         if (strpos($target, '::') === false) {
             $class = $target;
             $method = '__invoke';
         } else {
             list($class, $method) = explode('::', $target, 2);
         }
         if (!class_exists($class)) {
             throw new RuntimeException("The class {$class} does not exists");
         }
         $fn = new \ReflectionMethod($class, $method);
         if (!$fn->isStatic()) {
             $class = new \ReflectionClass($class);
             $instance = $class->hasMethod('__construct') ? $class->newInstanceArgs($construct_args) : $class->newInstance();
             $target = [$instance, $method];
         }
     }
     //if it's callable as is
     if (is_callable($target)) {
         return $target;
     }
     throw new RuntimeException('The route target is not callable');
 }
 /**
  * call back for mocking the object factory
  * @return object fixture objects ...
  * @author Robert Lemke <*****@*****.**>
  */
 public function objectManagerCallback()
 {
     $arguments = array_merge(func_get_args(), array($this->mockObjectManager));
     $objectName = array_shift($arguments);
     $class = new \ReflectionClass($objectName);
     return $class->getConstructor() !== null ? $class->newInstanceArgs($arguments) : $class->newInstance();
 }