diff --git a/library/think/App.php b/library/think/App.php index 53c5ca15..5e04f2ef 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -91,19 +91,19 @@ class App break; case 'module': // 模块/控制器/操作 - $data = self::module(self::$dispatch['data'], $config); + $data = self::module(self::$dispatch['module'], $config); break; case 'controller': // 执行控制器操作 $data = Loader::action(self::$dispatch['controller'], self::$dispatch['params']); break; - case 'callable': + case 'method': // 执行回调方法 - $data = self::invokeMethod(self::$dispatch['callable'], self::$dispatch['params']); + $data = self::invokeMethod(self::$dispatch['method'], self::$dispatch['params']); break; - case 'closure': + case 'function': // 规则闭包 - $data = self::invokeFunction(self::$dispatch['closure'], self::$dispatch['params']); + $data = self::invokeFunction(self::$dispatch['function'], self::$dispatch['params']); break; default: throw new Exception('dispatch type not support', 10008); @@ -115,9 +115,9 @@ class App } // 执行函数或者闭包方法 支持参数调用 - private static function invokeFunction($closure, $vars = []) + private static function invokeFunction($function, $vars = []) { - $reflect = new \ReflectionFunction($closure); + $reflect = new \ReflectionFunction($function); $args = self::bindParams($reflect, $vars); return $reflect->invokeArgs($args); } diff --git a/library/think/Route.php b/library/think/Route.php index c3069124..8591d82a 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -118,7 +118,7 @@ class Route $rule = substr($rule, 1, -1); $result = ['routes' => $route, 'option' => $option, 'pattern' => $pattern]; } elseif (is_array($route)) { - $result = ['route' => !empty($route[0])?$route[0]:'', 'option' => !empty($route[1])?$route[1]:'', 'pattern' => !empty($route[2])?$route[2]:'']; + $result = ['route' => !empty($route[0]) ? $route[0] : '', 'option' => !empty($route[1]) ? $route[1] : '', 'pattern' => !empty($route[2]) ? $route[2] : '']; } else { $result = ['route' => $route, 'option' => $option, 'pattern' => $pattern]; } @@ -297,7 +297,7 @@ class Route if (!empty($array[1])) { self::parseUrlParams($array[1]); } - $return = ['type' => 'callable', 'callable' => [self::$bind['class'], $array[0] ?: Config::get('default_action')], 'params' => []]; + $return = ['type' => 'method', 'method' => [self::$bind['class'], $array[0] ?: Config::get('default_action')], 'params' => []]; break; case 'namespace': // 绑定到命名空间 @@ -307,7 +307,7 @@ class Route if (!empty($array[2])) { self::parseUrlParams($array[2]); } - $return = ['type' => 'callable', 'callable' => [self::$bind['namespace'] . '\\' . $class, $method], 'params' => []]; + $return = ['type' => 'method', 'method' => [self::$bind['namespace'] . '\\' . $class, $method], 'params' => []]; break; case 'module': // 如果有模块/控制器绑定 针对路由到 模块/控制器 有效 @@ -424,7 +424,7 @@ class Route if (false !== $match = self::match($url, $rule, $pattern)) { if ($route instanceof \Closure) { // 执行闭包 - return ['type' => 'closure', 'closure' => $route, 'params' => $match]; + return ['type' => 'function', 'function' => $route, 'params' => $match]; } return self::parseRule($rule, $route, $url); } @@ -462,7 +462,7 @@ class Route if (!empty($result['var'])) { $_GET = array_merge($result['var'], $_GET); } - return ['type' => 'module', 'data' => $result['route']]; + return ['type' => 'module', 'module' => $result['route']]; } // 解析规范的路由地址 @@ -568,7 +568,7 @@ class Route $result = ['type' => 'redirect', 'url' => $url, 'status' => (is_array($route) && isset($route[1])) ? $route[1] : 301]; } elseif (0 === strpos($url, '\\')) { // 路由到回调 - $result = ['type' => 'callable', 'callable' => $route, 'params' => $matches]; + $result = ['type' => 'method', 'method' => $route, 'params' => $matches]; } elseif (0 === strpos($url, '@')) { // 路由到控制器 $result = ['type' => 'controller', 'controller' => substr($url, 1), 'params' => $matches]; @@ -586,7 +586,7 @@ class Route $var = array_merge($matches, $var); // 解析剩余的URL参数 self::parseUrlParams(implode('/', $paths), $var); - $result = ['type' => 'module', 'data' => $result['route']]; + $result = ['type' => 'module', 'module' => $result['route']]; } return $result; }