Ejemplo n.º 1
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testNull()
 {
     $input = array('a' => 0, 'b' => 'test', array(1, 2, null));
     $output = Utils\Formatter::format($input);
 }
Ejemplo n.º 2
0
$loader->addPsr4('Xiaoju\\Beatles\\Utils\\', FRAMEPATH . 'libraries');
$loader->addPsr4('Xiaoju\\Beatles\\Utils\\', FRAMEPATH . 'config');
$errNo = 0;
$errMsg = '';
$__uid = 0;
try {
    //生成全局的logid
    \Xiaoju\Beatles\Utils\Logger::create($logConfig['intLevel'], $logConfig['strLogFile'], $logConfig['intMaxFileSize']);
    \Xiaoju\Beatles\Utils\Logger::setLogId(Xiaoju\Beatles\Utils\Logger::getLogId());
    $params = array('get' => $_GET, 'post' => $_POST);
    register_shutdown_function('logFinish', $params);
    $routerConfig = $appNameSpace . '\\Config\\Route';
    if (class_exists($routerConfig) && is_array($routerConfig::$routes)) {
        $routerConfig = $routerConfig::$routes;
    } else {
        $routerConfig = array();
    }
    $router = new \Xiaoju\Beatles\Framework\Base\Router($_SERVER['REQUEST_URI'], $routerConfig);
    $router->setRoute();
    $router->run($params);
} catch (\InvalidArgumentException $ex) {
    $errNo = -1;
    $errMsg = strlen($ex->getMessage()) ? $ex->getMessage() : 'system error';
    \Xiaoju\Beatles\Utils\Logger::fatal($errMsg, $errNo, array('in' => json_encode($params), 'out' => ob_get_contents()));
    echo \Xiaoju\Beatles\Utils\Formatter::format(array('errno' => $errNo, 'errmsg' => $errMsg));
} catch (\Exception $ex) {
    $errNo = $ex->getCode();
    $errMsg = $ex->getMessage();
    \Xiaoju\Beatles\Utils\Logger::warning($errMsg, $errNo, array('in' => json_encode($params), 'out' => ob_get_contents()));
    echo \Xiaoju\Beatles\Utils\Formatter::format(array('errno' => $errNo, 'errmsg' => $errMsg));
}