|
@@ -6,7 +6,7 @@
|
|
|
require_once('uri.class.php');
|
|
|
require_once('events.interface.php');
|
|
|
class App extends Base implements Events {
|
|
|
- private static $apps = array();
|
|
|
+ private static $apps = [];
|
|
|
private $domains;
|
|
|
private $routers;
|
|
|
private $router;
|
|
@@ -14,16 +14,16 @@
|
|
|
public function __construct($name, Callable $fn = null){
|
|
|
$this->name = $name;
|
|
|
$this->router = new Router();
|
|
|
- $this->routers = array();
|
|
|
- $this->domains = array();
|
|
|
+ $this->routers = [];
|
|
|
+ $this->domains = [];
|
|
|
$this->_onerror = function($req, $res, $error){
|
|
|
- $o = json_encode(array(
|
|
|
+ $o = json_encode([
|
|
|
'message'=>$error->getMessage(),
|
|
|
'code'=>$error->getCode(),
|
|
|
'file'=>$error->getFile(),
|
|
|
'line'=>$error->getLine(),
|
|
|
'traceback'=>$error->getTrace()
|
|
|
- ));
|
|
|
+ ]);
|
|
|
if($res){
|
|
|
$res->code(404);
|
|
|
$res->header('Content-Type', 'application/json');
|
|
@@ -40,7 +40,7 @@
|
|
|
}
|
|
|
}
|
|
|
public function __destruct(){
|
|
|
- $this->routers = array();
|
|
|
+ $this->routers = [];
|
|
|
$index = array_search(static::$apps, $this);
|
|
|
if($index !== false){
|
|
|
array_splice(static::$apps, $index, 1);
|
|
@@ -146,26 +146,26 @@
|
|
|
App::shutdown();
|
|
|
});
|
|
|
set_error_handler(function($errno, $errstr, $errfile, $errline){
|
|
|
- App::shutdown_error(array(
|
|
|
+ App::shutdown_error([
|
|
|
'number'=> $errno,
|
|
|
'msg'=> $errstr,
|
|
|
'file'=> $errfile,
|
|
|
'line'=> $errline,
|
|
|
'backtrace'=> debug_backtrace(),
|
|
|
'included'=> get_included_files()
|
|
|
- ));
|
|
|
+ ]);
|
|
|
},E_ALL);
|
|
|
register_shutdown_function(function(){
|
|
|
$error = error_get_last();
|
|
|
if($error['type'] == 1){
|
|
|
- App::shutdown_error(array(
|
|
|
+ App::shutdown_error([
|
|
|
'number'=> $error['type'],
|
|
|
'msg'=> $error['message'],
|
|
|
'file'=> $error['file'],
|
|
|
'line'=> $error['line'],
|
|
|
- 'backtrace'=> array(),
|
|
|
+ 'backtrace'=> [],
|
|
|
'included'=> get_included_files()
|
|
|
- ));
|
|
|
+ ]);
|
|
|
}
|
|
|
});
|
|
|
?>
|