@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param string $name |
| 57 | 57 | * @return string|null |
| 58 | 58 | */ |
| 59 | - public static function get(string $filename):?string; |
|
| 59 | + public static function get(string $filename): ?string; |
|
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param boolean $full |
| 78 | 78 | * @return \Iterator |
| 79 | 79 | */ |
| 80 | - public static function readFiles(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : \Iterator; |
|
| 80 | + public static function readFiles(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY) : \Iterator; |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * 读目录下文件夹 |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param boolean $full |
| 89 | 89 | * @return \Iterator |
| 90 | 90 | */ |
| 91 | - public static function readDirs(string $path, bool $recursive=false, ?string $regex=null, bool $full=false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; |
|
| 91 | + public static function readDirs(string $path, bool $recursive = false, ?string $regex = null, bool $full = false, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; |
|
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * 读目录,包括文件,文件夹 |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param boolean $full |
| 100 | 100 | * @return \Iterator |
| 101 | 101 | */ |
| 102 | - public static function read(string $path, bool $recursive=false, ?string $regex=null, bool $full=true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; |
|
| 102 | + public static function read(string $path, bool $recursive = false, ?string $regex = null, bool $full = true, int $mode = RecursiveIteratorIterator::LEAVES_ONLY): \Iterator; |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * 截断部分目录 |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param boolean $move |
| 120 | 120 | * @return boolean |
| 121 | 121 | */ |
| 122 | - public static function copyDir(string $path, string $toPath, ?string $regex=null, bool $move = false):bool; |
|
| 122 | + public static function copyDir(string $path, string $toPath, ?string $regex = null, bool $move = false):bool; |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * 移动文件夹 |
@@ -129,5 +129,5 @@ discard block |
||
| 129 | 129 | * @param string|null $regex |
| 130 | 130 | * @return boolean |
| 131 | 131 | */ |
| 132 | - public static function moveDir(string $path, string $toPath, ?string $regex=null):bool; |
|
| 132 | + public static function moveDir(string $path, string $toPath, ?string $regex = null):bool; |
|
| 133 | 133 | } |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @var array |
| 16 | 16 | */ |
| 17 | - protected $value=[]; |
|
| 17 | + protected $value = []; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * 渲染堆栈 |
| 21 | 21 | * |
| 22 | 22 | * @var array |
| 23 | 23 | */ |
| 24 | - protected static $renderStack=[]; |
|
| 24 | + protected static $renderStack = []; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * 模板名 |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @var array |
| 52 | 52 | */ |
| 53 | - protected $hooks=[]; |
|
| 53 | + protected $hooks = []; |
|
| 54 | 54 | |
| 55 | - public function get(string $name=null, $default=null) |
|
| 55 | + public function get(string $name = null, $default = null) |
|
| 56 | 56 | { |
| 57 | 57 | } |
| 58 | 58 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | public function setParent(TemplateInterface $template) |
| 80 | 80 | { |
| 81 | - $this->parent=$template; |
|
| 81 | + $this->parent = $template; |
|
| 82 | 82 | return $this; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | protected function popRenderStack() |
| 131 | 131 | { |
| 132 | 132 | array_pop(static::$renderStack); |
| 133 | - $content=trim(ob_get_clean()); |
|
| 133 | + $content = trim(ob_get_clean()); |
|
| 134 | 134 | return $content; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -181,7 +181,7 @@ |
||
| 181 | 181 | $object = $class->getMethod('instance')->invoke(null); |
| 182 | 182 | $context->setResponse($object); |
| 183 | 183 | $class->getMethod('proccess')->invokeArgs($object, [ |
| 184 | - new Runnable([$object,'onRequest']), |
|
| 184 | + new Runnable([$object, 'onRequest']), |
|
| 185 | 185 | $this->getRequest($context), |
| 186 | 186 | $this->matcher->getAttribute('buffer', true), |
| 187 | 187 | $context->isDebug(), |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function add(?string $module = null, string $name, RouteMatcher $router) |
| 59 | 59 | { |
| 60 | - $module = $module ?: $this->default; |
|
| 60 | + $module = $module ?: $this->default; |
|
| 61 | 61 | if (\array_key_exists($module, $this->routes)) { |
| 62 | 62 | $this->routes[$module]->add($name, $router); |
| 63 | 63 | } else { |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param Request $request |
| 90 | 90 | * @return MatchResult|null |
| 91 | 91 | */ |
| 92 | - public function match(Request $request):?MatchResult |
|
| 92 | + public function match(Request $request): ?MatchResult |
|
| 93 | 93 | { |
| 94 | 94 | foreach ($this->routes as $module => $collection) { |
| 95 | 95 | foreach ($collection as $name => $matcher) { |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | * @param string $name |
| 109 | 109 | * @return RouteMatcher|null |
| 110 | 110 | */ |
| 111 | - public function find(?string $module = null, string $name):?RouteMatcher |
|
| 111 | + public function find(?string $module = null, string $name): ?RouteMatcher |
|
| 112 | 112 | { |
| 113 | - $module = $module ?: $this->default; |
|
| 113 | + $module = $module ?: $this->default; |
|
| 114 | 114 | if (\array_key_exists($module, $this->routes)) { |
| 115 | 115 | return $this->routes[$module]->get($name); |
| 116 | 116 | } |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | $rpos = \strrpos($name, ':'); |
| 56 | 56 | if ($rpos > 0) { |
| 57 | 57 | $module = substr($name, 0, $rpos); |
| 58 | - $name = \substr($name, $rpos+1); |
|
| 59 | - $moduleFull = $this->getFullName($module); |
|
| 58 | + $name = \substr($name, $rpos + 1); |
|
| 59 | + $moduleFull = $this->getFullName($module); |
|
| 60 | 60 | return [$moduleFull, $name]; |
| 61 | 61 | } |
| 62 | 62 | if ($rpos === 0) { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if (\array_key_exists($version, $this->knownsFullName[$name])) { |
| 78 | 78 | return $this->knownsFullName[$name][$version]; |
| 79 | 79 | } |
| 80 | - return $hasVersion?$name.':'.$version:end($this->knownsFullName[$name]); |
|
| 80 | + return $hasVersion ? $name.':'.$version : end($this->knownsFullName[$name]); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | protected function getLikeName(string $name):string |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | public function getRoute(string $groupName): GroupRoutes |
| 86 | 86 | { |
| 87 | - $group = $groupName === 'default' ? '': '-'. $groupName; |
|
| 88 | - $routeConfig = $this->getConfigFrom('route'.$group, ['group' => $group,]); |
|
| 89 | - $routes = new GroupRoutes($groupName); |
|
| 87 | + $group = $groupName === 'default' ? '' : '-'.$groupName; |
|
| 88 | + $routeConfig = $this->getConfigFrom('route'.$group, ['group' => $group, ]); |
|
| 89 | + $routes = new GroupRoutes($groupName); |
|
| 90 | 90 | if (\is_array($routeConfig)) { |
| 91 | 91 | // debug()->debug('load route {group} from {module}',['group'=>$groupName, 'module' => $this->getFullName()]); |
| 92 | 92 | $prefix = $this->config->get('route.prefix', ''); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | */ |
| 142 | 142 | public function getFullName() |
| 143 | 143 | { |
| 144 | - return $this->name .':'. $this->version; |
|
| 144 | + return $this->name.':'.$this->version; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -42,9 +42,9 @@ |
||
| 42 | 42 | $extension !== 'module') { |
| 43 | 43 | return null; |
| 44 | 44 | } |
| 45 | - $zip=new ZipArchive; |
|
| 45 | + $zip = new ZipArchive; |
|
| 46 | 46 | if ($zip->open($path, ZipArchive::CHECKCONS)) { |
| 47 | - $unzipPath = $unpackPath.'/'. pathinfo($path, PATHINFO_FILENAME) .'-'.substr(md5_file($path), 0, 8); |
|
| 47 | + $unzipPath = $unpackPath.'/'.pathinfo($path, PATHINFO_FILENAME).'-'.substr(md5_file($path), 0, 8); |
|
| 48 | 48 | $zip->extractTo($unzipPath); |
| 49 | 49 | $zip->close(); |
| 50 | 50 | return Config::resolve($unzipPath.'/module'); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | public function registerModule() |
| 141 | 141 | { |
| 142 | 142 | $scan = $this->getContext()->getConfig()->get('app.module.scan-path', []); |
| 143 | - $cache = $this->getContext()->getApplication()->getDataPath() .'/module-cache'; |
|
| 143 | + $cache = $this->getContext()->getApplication()->getDataPath().'/module-cache'; |
|
| 144 | 144 | FileSystem::makes($cache); |
| 145 | 145 | // 扫描加载 |
| 146 | 146 | foreach (Builder::scan($scan, $cache) as $module) { |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @param string $name |
| 191 | 191 | * @return Module|null |
| 192 | 192 | */ |
| 193 | - public function find(string $name):?Module |
|
| 193 | + public function find(string $name): ?Module |
|
| 194 | 194 | { |
| 195 | 195 | $fullName = $this->finder->getFullName($name); |
| 196 | 196 | return $this->module[$fullName] ?? null; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function loadFromModule(Manager $manager) |
| 52 | 52 | { |
| 53 | - $groups = $this->applicaton->getConfig()->get('app.active', ['default']); |
|
| 53 | + $groups = $this->applicaton->getConfig()->get('app.active', ['default']); |
|
| 54 | 54 | foreach ($groups as $group) { |
| 55 | 55 | $manager->loadRoute($group, $this); |
| 56 | 56 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param Request $request |
| 79 | 79 | * @return MatchResult|null |
| 80 | 80 | */ |
| 81 | - public function match(Request $request):?MatchResult |
|
| 81 | + public function match(Request $request): ?MatchResult |
|
| 82 | 82 | { |
| 83 | 83 | foreach ($this->routes as $group => $routes) { |
| 84 | 84 | if (($result = $routes->match($request)) !== null) { |