Esempio n. 1
0
 public function callStaticMethod($class, $method, array $args = [])
 {
     $refl = new \reflectionClass($class);
     // Check that method is static AND public
     if ($refl->hasMethod($method) && $refl->getMethod($method)->isStatic() && $refl->getMethod($method)->isPublic()) {
         return call_user_func_array($class . '::' . $method, $args);
     }
     throw new \RuntimeException(sprintf('Invalid static method call for class %s and method %s', $class, $method));
 }
Esempio n. 2
0
 protected static function canInstanciateClass($class)
 {
     $reflection = new \reflectionClass($class);
     if ($reflection->hasMethod('__construct') === false) {
         return true;
     }
     $constructor = $reflection->getMethod('__construct');
     if ($constructor->isPublic() === false) {
         throw new provider\object\exceptions\privateConstructor('Could not instanciate an object from ' . $class . ' because ' . $class . '::__construct() is private');
     }
     if ($constructor->getNumberOfRequiredParameters() > 0) {
         throw new provider\object\exceptions\mandatoryArgument('Could not instanciate an object from ' . $class . ' because ' . $class . '::__construct() has at least one mandatory argument');
     }
     return true;
 }
Esempio n. 3
0
        while (($file = readdir($dh)) !== false) {
            if (!is_dir($dir . $file)) {
                if (!class_exists(substr($file, 0, -4))) {
                    require_once $dir . $file;
                }
            }
        }
        closedir($dh);
    }
}
//VERIFICAMOS TOKEN DE SEGURIDAD
$db = new db_core();
if ($_POST['lib'] != "user" && $_POST['lib'] != "simulacion" && !$db->isExists('session_log', 'token', $_SESSION['token_user'])) {
    die('ERROR HANDLER - ERROR DE SEGURIDAD: COD 02');
} else {
    // LEEMOS LA LIBRERIA QUE SE REQUIERE
    if (isset($_POST['lib']) && $_POST['method'] && class_exists($_POST['lib'])) {
        $clase = $_POST['lib'];
        $objeto = new $clase();
        $methodo = $_POST['method'];
        $clases = new reflectionClass($clase);
        if ($clases->hasMethod($methodo)) {
            $data = $_SERVER['HTTP_HOST'] == "localhost" || $_SERVER['HTTP_HOST'] == "127.0.0.1" ? json_decode(stripslashes($_POST['data'])) : json_decode($_POST['data']);
            $objeto->{$methodo}($data);
        } else {
            die("ERROR HANDLER - LLAMADA INVALIDA: COD 03");
        }
    } else {
        die("ERROR HANDLER - LLAMADA INVALIDA: COD 01");
    }
}