@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | public function run(array $build = [], $namespace = 'app', $suffix = false) |
43 | 43 | { |
44 | 44 | // 锁定 |
45 | - $lockfile = $this->basePath . 'build.lock'; |
|
45 | + $lockfile = $this->basePath.'build.lock'; |
|
46 | 46 | |
47 | 47 | if (is_writable($lockfile)) { |
48 | 48 | return; |
49 | 49 | } elseif (!touch($lockfile)) { |
50 | - throw new Exception('应用目录[' . $this->basePath . ']不可写,目录无法自动生成!<BR>请手动生成项目目录~', 10006); |
|
50 | + throw new Exception('应用目录['.$this->basePath.']不可写,目录无法自动生成!<BR>请手动生成项目目录~', 10006); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | foreach ($build as $module => $list) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | protected function buildDir($list) |
77 | 77 | { |
78 | 78 | foreach ($list as $dir) { |
79 | - $this->checkDirBuild($this->basePath . $dir); |
|
79 | + $this->checkDirBuild($this->basePath.$dir); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | protected function buildFile($list) |
90 | 90 | { |
91 | 91 | foreach ($list as $file) { |
92 | - if (!is_dir($this->basePath . dirname($file))) { |
|
92 | + if (!is_dir($this->basePath.dirname($file))) { |
|
93 | 93 | // 创建目录 |
94 | - mkdir($this->basePath . dirname($file), 0755, true); |
|
94 | + mkdir($this->basePath.dirname($file), 0755, true); |
|
95 | 95 | } |
96 | 96 | |
97 | - if (!is_file($this->basePath . $file)) { |
|
98 | - file_put_contents($this->basePath . $file, 'php' == pathinfo($file, PATHINFO_EXTENSION) ? "<?php\n" : ''); |
|
97 | + if (!is_file($this->basePath.$file)) { |
|
98 | + file_put_contents($this->basePath.$file, 'php' == pathinfo($file, PATHINFO_EXTENSION) ? "<?php\n" : ''); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | { |
114 | 114 | $module = $module ? $module : ''; |
115 | 115 | |
116 | - if (!is_dir($this->basePath . $module)) { |
|
116 | + if (!is_dir($this->basePath.$module)) { |
|
117 | 117 | // 创建模块目录 |
118 | - mkdir($this->basePath . $module); |
|
118 | + mkdir($this->basePath.$module); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (basename($this->app->getRuntimePath()) != $module) { |
@@ -135,26 +135,26 @@ discard block |
||
135 | 135 | |
136 | 136 | // 创建子目录和文件 |
137 | 137 | foreach ($list as $path => $file) { |
138 | - $modulePath = $this->basePath . $module . DIRECTORY_SEPARATOR; |
|
138 | + $modulePath = $this->basePath.$module.DIRECTORY_SEPARATOR; |
|
139 | 139 | if ('__dir__' == $path) { |
140 | 140 | // 生成子目录 |
141 | 141 | foreach ($file as $dir) { |
142 | - $this->checkDirBuild($modulePath . $dir); |
|
142 | + $this->checkDirBuild($modulePath.$dir); |
|
143 | 143 | } |
144 | 144 | } elseif ('__file__' == $path) { |
145 | 145 | // 生成(空白)文件 |
146 | 146 | foreach ($file as $name) { |
147 | - if (!is_file($modulePath . $name)) { |
|
148 | - file_put_contents($modulePath . $name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? "<?php\n" : ''); |
|
147 | + if (!is_file($modulePath.$name)) { |
|
148 | + file_put_contents($modulePath.$name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? "<?php\n" : ''); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | } else { |
152 | 152 | // 生成相关MVC文件 |
153 | 153 | foreach ($file as $val) { |
154 | 154 | $val = trim($val); |
155 | - $filename = $modulePath . $path . DIRECTORY_SEPARATOR . $val . ($suffix ? ucfirst($path) : '') . '.php'; |
|
156 | - $space = $namespace . '\\' . ($module ? $module . '\\' : '') . $path; |
|
157 | - $class = $val . ($suffix ? ucfirst($path) : ''); |
|
155 | + $filename = $modulePath.$path.DIRECTORY_SEPARATOR.$val.($suffix ? ucfirst($path) : '').'.php'; |
|
156 | + $space = $namespace.'\\'.($module ? $module.'\\' : '').$path; |
|
157 | + $class = $val.($suffix ? ucfirst($path) : ''); |
|
158 | 158 | switch ($path) { |
159 | 159 | case 'controller': // 控制器 |
160 | 160 | $content = "<?php\nnamespace {$space};\n\nclass {$class}\n{\n\n}"; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $content = "<?php\nnamespace {$space};\n\nuse think\Model;\n\nclass {$class} extends Model\n{\n\n}"; |
164 | 164 | break; |
165 | 165 | case 'view': // 视图 |
166 | - $filename = $modulePath . $path . DIRECTORY_SEPARATOR . $val . '.html'; |
|
166 | + $filename = $modulePath.$path.DIRECTORY_SEPARATOR.$val.'.html'; |
|
167 | 167 | $this->checkDirBuild(dirname($filename)); |
168 | 168 | $content = ''; |
169 | 169 | break; |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | public function buildRoute($suffix = false, $layer = '') |
191 | 191 | { |
192 | 192 | $namespace = $this->app->getNameSpace(); |
193 | - $content = '<?php ' . PHP_EOL . '//根据 Annotation 自动生成的路由规则'; |
|
193 | + $content = '<?php '.PHP_EOL.'//根据 Annotation 自动生成的路由规则'; |
|
194 | 194 | |
195 | 195 | if (!$layer) { |
196 | 196 | $layer = $this->app->config('app.url_controller_layer'); |
197 | 197 | } |
198 | 198 | |
199 | 199 | if ($this->app->config('app.app_multi_module')) { |
200 | - $modules = glob($this->basePath . '*', GLOB_ONLYDIR); |
|
200 | + $modules = glob($this->basePath.'*', GLOB_ONLYDIR); |
|
201 | 201 | |
202 | 202 | foreach ($modules as $module) { |
203 | 203 | $module = basename($module); |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | |
209 | - $path = $this->basePath . $module . DIRECTORY_SEPARATOR . $layer . DIRECTORY_SEPARATOR; |
|
209 | + $path = $this->basePath.$module.DIRECTORY_SEPARATOR.$layer.DIRECTORY_SEPARATOR; |
|
210 | 210 | $content .= $this->buildDirRoute($path, $namespace, $module, $suffix, $layer); |
211 | 211 | } |
212 | 212 | } else { |
213 | - $path = $this->basePath . $layer . DIRECTORY_SEPARATOR; |
|
213 | + $path = $this->basePath.$layer.DIRECTORY_SEPARATOR; |
|
214 | 214 | $content .= $this->buildDirRoute($path, $namespace, '', $suffix, $layer); |
215 | 215 | } |
216 | 216 | |
217 | - $filename = $this->app->getRuntimePath() . 'build_route.php'; |
|
217 | + $filename = $this->app->getRuntimePath().'build_route.php'; |
|
218 | 218 | file_put_contents($filename, $content); |
219 | 219 | |
220 | 220 | return $filename; |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | protected function buildDirRoute($path, $namespace, $module, $suffix, $layer) |
234 | 234 | { |
235 | 235 | $content = ''; |
236 | - $controllers = glob($path . '*.php'); |
|
236 | + $controllers = glob($path.'*.php'); |
|
237 | 237 | |
238 | 238 | foreach ($controllers as $controller) { |
239 | 239 | $controller = basename($controller, '.php'); |
240 | 240 | |
241 | - $class = new \ReflectionClass($namespace . '\\' . ($module ? $module . '\\' : '') . $layer . '\\' . $controller); |
|
241 | + $class = new \ReflectionClass($namespace.'\\'.($module ? $module.'\\' : '').$layer.'\\'.$controller); |
|
242 | 242 | |
243 | 243 | if (strpos($layer, '\\')) { |
244 | 244 | // 多级控制器 |
245 | 245 | $level = str_replace(DIRECTORY_SEPARATOR, '.', substr($layer, 11)); |
246 | - $controller = $level . '.' . $controller; |
|
246 | + $controller = $level.'.'.$controller; |
|
247 | 247 | $length = strlen(strstr($layer, '\\', true)); |
248 | 248 | } else { |
249 | 249 | $length = strlen($layer); |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | $content .= $this->getControllerRoute($class, $module, $controller); |
257 | 257 | } |
258 | 258 | |
259 | - $subDir = glob($path . '*', GLOB_ONLYDIR); |
|
259 | + $subDir = glob($path.'*', GLOB_ONLYDIR); |
|
260 | 260 | |
261 | 261 | foreach ($subDir as $dir) { |
262 | - $content .= $this->buildDirRoute($dir . DIRECTORY_SEPARATOR, $namespace, $module, $suffix, $layer . '\\' . basename($dir)); |
|
262 | + $content .= $this->buildDirRoute($dir.DIRECTORY_SEPARATOR, $namespace, $module, $suffix, $layer.'\\'.basename($dir)); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | return $content; |
@@ -280,14 +280,14 @@ discard block |
||
280 | 280 | |
281 | 281 | if (false !== strpos($comment, '@route(')) { |
282 | 282 | $comment = $this->parseRouteComment($comment); |
283 | - $route = ($module ? $module . '/' : '') . $controller; |
|
284 | - $comment = preg_replace('/route\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::resource(\1,\'' . $route . '\')', $comment); |
|
285 | - $content .= PHP_EOL . $comment; |
|
283 | + $route = ($module ? $module.'/' : '').$controller; |
|
284 | + $comment = preg_replace('/route\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::resource(\1,\''.$route.'\')', $comment); |
|
285 | + $content .= PHP_EOL.$comment; |
|
286 | 286 | } elseif (false !== strpos($comment, '@alias(')) { |
287 | 287 | $comment = $this->parseRouteComment($comment, '@alias('); |
288 | - $route = ($module ? $module . '/' : '') . $controller; |
|
289 | - $comment = preg_replace('/alias\(\s?([\'\"][\-\_\/\w]+[\'\"])\s?\)/is', 'Route::alias(\1,\'' . $route . '\')', $comment); |
|
290 | - $content .= PHP_EOL . $comment; |
|
288 | + $route = ($module ? $module.'/' : '').$controller; |
|
289 | + $comment = preg_replace('/alias\(\s?([\'\"][\-\_\/\w]+[\'\"])\s?\)/is', 'Route::alias(\1,\''.$route.'\')', $comment); |
|
290 | + $content .= PHP_EOL.$comment; |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | foreach ($methods as $method) { |
296 | 296 | $comment = $this->getMethodRouteComment($module, $controller, $method); |
297 | 297 | if ($comment) { |
298 | - $content .= PHP_EOL . $comment; |
|
298 | + $content .= PHP_EOL.$comment; |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -313,18 +313,18 @@ discard block |
||
313 | 313 | { |
314 | 314 | $comment = substr($comment, 3, -2); |
315 | 315 | $comment = explode(PHP_EOL, substr(strstr(trim($comment), $tag), 1)); |
316 | - $comment = array_map(function ($item) {return trim(trim($item), ' \t*');}, $comment); |
|
316 | + $comment = array_map(function($item) {return trim(trim($item), ' \t*'); }, $comment); |
|
317 | 317 | |
318 | 318 | if (count($comment) > 1) { |
319 | 319 | $key = array_search('', $comment); |
320 | 320 | $comment = array_slice($comment, 0, false === $key ? 1 : $key); |
321 | 321 | } |
322 | 322 | |
323 | - $comment = implode(PHP_EOL . "\t", $comment) . ';'; |
|
323 | + $comment = implode(PHP_EOL."\t", $comment).';'; |
|
324 | 324 | |
325 | 325 | if (strpos($comment, '{')) { |
326 | - $comment = preg_replace_callback('/\{\s?.*?\s?\}/s', function ($matches) { |
|
327 | - return false !== strpos($matches[0], '"') ? '[' . substr(var_export(json_decode($matches[0], true), true), 7, -1) . ']' : $matches[0]; |
|
326 | + $comment = preg_replace_callback('/\{\s?.*?\s?\}/s', function($matches) { |
|
327 | + return false !== strpos($matches[0], '"') ? '['.substr(var_export(json_decode($matches[0], true), true), 7, -1).']' : $matches[0]; |
|
328 | 328 | }, $comment); |
329 | 329 | } |
330 | 330 | return $comment; |
@@ -350,9 +350,9 @@ discard block |
||
350 | 350 | $action = substr($action, 0, -strlen($suffix)); |
351 | 351 | } |
352 | 352 | |
353 | - $route = ($module ? $module . '/' : '') . $controller . '/' . $action; |
|
354 | - $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\,?\s?[\'\"]?(\w+?)[\'\"]?\s?\)/is', 'Route::\2(\1,\'' . $route . '\')', $comment); |
|
355 | - $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::rule(\1,\'' . $route . '\')', $comment); |
|
353 | + $route = ($module ? $module.'/' : '').$controller.'/'.$action; |
|
354 | + $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\,?\s?[\'\"]?(\w+?)[\'\"]?\s?\)/is', 'Route::\2(\1,\''.$route.'\')', $comment); |
|
355 | + $comment = preg_replace('/route\s?\(\s?([\'\"][\-\_\/\:\<\>\?\$\[\]\w]+[\'\"])\s?\)/is', 'Route::rule(\1,\''.$route.'\')', $comment); |
|
356 | 356 | |
357 | 357 | return $comment; |
358 | 358 | } |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | */ |
369 | 369 | protected function buildHello($module, $namespace, $suffix = false) |
370 | 370 | { |
371 | - $filename = $this->basePath . ($module ? $module . DIRECTORY_SEPARATOR : '') . 'controller' . DIRECTORY_SEPARATOR . 'Index' . ($suffix ? 'Controller' : '') . '.php'; |
|
371 | + $filename = $this->basePath.($module ? $module.DIRECTORY_SEPARATOR : '').'controller'.DIRECTORY_SEPARATOR.'Index'.($suffix ? 'Controller' : '').'.php'; |
|
372 | 372 | if (!is_file($filename)) { |
373 | - $content = file_get_contents($this->app->getThinkPath() . 'tpl' . DIRECTORY_SEPARATOR . 'default_index.tpl'); |
|
374 | - $content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [$namespace, $module ? $module . '\\' : '', 'controller', $suffix ? 'Controller' : ''], $content); |
|
373 | + $content = file_get_contents($this->app->getThinkPath().'tpl'.DIRECTORY_SEPARATOR.'default_index.tpl'); |
|
374 | + $content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [$namespace, $module ? $module.'\\' : '', 'controller', $suffix ? 'Controller' : ''], $content); |
|
375 | 375 | $this->checkDirBuild(dirname($filename)); |
376 | 376 | |
377 | 377 | file_put_contents($filename, $content); |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | */ |
387 | 387 | protected function buildCommon($module) |
388 | 388 | { |
389 | - $filename = $this->app->getConfigPath() . ($module ? $module . DIRECTORY_SEPARATOR : '') . 'app.php'; |
|
389 | + $filename = $this->app->getConfigPath().($module ? $module.DIRECTORY_SEPARATOR : '').'app.php'; |
|
390 | 390 | $this->checkDirBuild(dirname($filename)); |
391 | 391 | |
392 | 392 | if (!is_file($filename)) { |
393 | 393 | file_put_contents($filename, "<?php\n//配置文件\nreturn [\n\n];"); |
394 | 394 | } |
395 | 395 | |
396 | - $filename = $this->basePath . ($module ? $module . DIRECTORY_SEPARATOR : '') . 'common.php'; |
|
396 | + $filename = $this->basePath.($module ? $module.DIRECTORY_SEPARATOR : '').'common.php'; |
|
397 | 397 | |
398 | 398 | if (!is_file($filename)) { |
399 | 399 | file_put_contents($filename, "<?php\n"); |
@@ -120,7 +120,7 @@ |
||
120 | 120 | if (is_string($msg) && !empty($context)) { |
121 | 121 | $replace = []; |
122 | 122 | foreach ($context as $key => $val) { |
123 | - $replace['{' . $key . '}'] = $val; |
|
123 | + $replace['{'.$key.'}'] = $val; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $msg = strtr($msg, $replace); |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | |
189 | 189 | if (!empty($config['type'])) { |
190 | 190 | // 读取session驱动 |
191 | - $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']); |
|
191 | + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\'.ucwords($config['type']); |
|
192 | 192 | |
193 | 193 | // 检查驱动类 |
194 | 194 | if (!class_exists($class) || !session_set_save_handler(new $class($config))) { |
195 | - throw new ClassNotFoundException('error session handler:' . $class, $class); |
|
195 | + throw new ClassNotFoundException('error session handler:'.$class, $class); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | if (!empty($config['type']) && isset($config['use_lock']) && $config['use_lock']) { |
303 | 303 | // 读取session驱动 |
304 | - $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']); |
|
304 | + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\'.ucwords($config['type']); |
|
305 | 305 | |
306 | 306 | // 检查驱动类及类中是否存在 lock 和 unlock 函数 |
307 | 307 | if (class_exists($class) && method_exists($class, 'lock') && method_exists($class, 'unlock')) { |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | |
66 | 66 | $path = realpath(dirname($scriptName)); |
67 | 67 | |
68 | - if (!is_file($path . DIRECTORY_SEPARATOR . 'think')) { |
|
68 | + if (!is_file($path.DIRECTORY_SEPARATOR.'think')) { |
|
69 | 69 | $path = dirname($path); |
70 | 70 | } |
71 | 71 | |
72 | - return $path . DIRECTORY_SEPARATOR; |
|
72 | + return $path.DIRECTORY_SEPARATOR; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // 注册自动加载机制 |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | |
81 | 81 | $rootPath = self::getRootPath(); |
82 | 82 | |
83 | - self::$composerPath = $rootPath . 'vendor' . DIRECTORY_SEPARATOR . 'composer' . DIRECTORY_SEPARATOR; |
|
83 | + self::$composerPath = $rootPath.'vendor'.DIRECTORY_SEPARATOR.'composer'.DIRECTORY_SEPARATOR; |
|
84 | 84 | |
85 | 85 | // Composer自动加载支持 |
86 | 86 | if (is_dir(self::$composerPath)) { |
87 | - if (is_file(self::$composerPath . 'autoload_static.php')) { |
|
88 | - require self::$composerPath . 'autoload_static.php'; |
|
87 | + if (is_file(self::$composerPath.'autoload_static.php')) { |
|
88 | + require self::$composerPath.'autoload_static.php'; |
|
89 | 89 | |
90 | 90 | $declaredClass = get_declared_classes(); |
91 | 91 | $composerClass = array_pop($declaredClass); |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | // 注册命名空间定义 |
104 | 104 | self::addNamespace([ |
105 | 105 | 'think' => __DIR__, |
106 | - 'traits' => dirname(__DIR__) . DIRECTORY_SEPARATOR . 'traits', |
|
106 | + 'traits' => dirname(__DIR__).DIRECTORY_SEPARATOR.'traits', |
|
107 | 107 | ]); |
108 | 108 | |
109 | 109 | // 加载类库映射文件 |
110 | - if (is_file($rootPath . 'runtime' . DIRECTORY_SEPARATOR . 'classmap.php')) { |
|
111 | - self::addClassMap(__include_file($rootPath . 'runtime' . DIRECTORY_SEPARATOR . 'classmap.php')); |
|
110 | + if (is_file($rootPath.'runtime'.DIRECTORY_SEPARATOR.'classmap.php')) { |
|
111 | + self::addClassMap(__include_file($rootPath.'runtime'.DIRECTORY_SEPARATOR.'classmap.php')); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | // 自动加载extend目录 |
115 | - self::addAutoLoadDir($rootPath . 'extend'); |
|
115 | + self::addAutoLoadDir($rootPath.'extend'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // 自动加载 |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // 查找 PSR-4 |
151 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php'; |
|
151 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).'.php'; |
|
152 | 152 | |
153 | 153 | $first = $class[0]; |
154 | 154 | if (isset(self::$prefixLengthsPsr4[$first])) { |
155 | 155 | foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) { |
156 | 156 | if (0 === strpos($class, $prefix)) { |
157 | 157 | foreach (self::$prefixDirsPsr4[$prefix] as $dir) { |
158 | - if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { |
|
158 | + if (is_file($file = $dir.DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $length))) { |
|
159 | 159 | return $file; |
160 | 160 | } |
161 | 161 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | // 查找 PSR-4 fallback dirs |
167 | 167 | foreach (self::$fallbackDirsPsr4 as $dir) { |
168 | - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
168 | + if (is_file($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
169 | 169 | return $file; |
170 | 170 | } |
171 | 171 | } |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
178 | 178 | } else { |
179 | 179 | // PEAR-like class name |
180 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . '.php'; |
|
180 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).'.php'; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | if (isset(self::$prefixesPsr0[$first])) { |
184 | 184 | foreach (self::$prefixesPsr0[$first] as $prefix => $dirs) { |
185 | 185 | if (0 === strpos($class, $prefix)) { |
186 | 186 | foreach ($dirs as $dir) { |
187 | - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
187 | + if (is_file($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
188 | 188 | return $file; |
189 | 189 | } |
190 | 190 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | // 查找 PSR-0 fallback dirs |
196 | 196 | foreach (self::$fallbackDirsPsr0 as $dir) { |
197 | - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
197 | + if (is_file($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
198 | 198 | return $file; |
199 | 199 | } |
200 | 200 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | { |
218 | 218 | if (is_array($namespace)) { |
219 | 219 | foreach ($namespace as $prefix => $paths) { |
220 | - self::addPsr4($prefix . '\\', rtrim($paths, DIRECTORY_SEPARATOR), true); |
|
220 | + self::addPsr4($prefix.'\\', rtrim($paths, DIRECTORY_SEPARATOR), true); |
|
221 | 221 | } |
222 | 222 | } else { |
223 | - self::addPsr4($namespace . '\\', rtrim($path, DIRECTORY_SEPARATOR), true); |
|
223 | + self::addPsr4($namespace.'\\', rtrim($path, DIRECTORY_SEPARATOR), true); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
@@ -322,29 +322,29 @@ discard block |
||
322 | 322 | // 注册composer自动加载 |
323 | 323 | public static function registerComposerLoader($composerPath) |
324 | 324 | { |
325 | - if (is_file($composerPath . 'autoload_namespaces.php')) { |
|
326 | - $map = require $composerPath . 'autoload_namespaces.php'; |
|
325 | + if (is_file($composerPath.'autoload_namespaces.php')) { |
|
326 | + $map = require $composerPath.'autoload_namespaces.php'; |
|
327 | 327 | foreach ($map as $namespace => $path) { |
328 | 328 | self::addPsr0($namespace, $path); |
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - if (is_file($composerPath . 'autoload_psr4.php')) { |
|
333 | - $map = require $composerPath . 'autoload_psr4.php'; |
|
332 | + if (is_file($composerPath.'autoload_psr4.php')) { |
|
333 | + $map = require $composerPath.'autoload_psr4.php'; |
|
334 | 334 | foreach ($map as $namespace => $path) { |
335 | 335 | self::addPsr4($namespace, $path); |
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | - if (is_file($composerPath . 'autoload_classmap.php')) { |
|
340 | - $classMap = require $composerPath . 'autoload_classmap.php'; |
|
339 | + if (is_file($composerPath.'autoload_classmap.php')) { |
|
340 | + $classMap = require $composerPath.'autoload_classmap.php'; |
|
341 | 341 | if ($classMap) { |
342 | 342 | self::addClassMap($classMap); |
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - if (is_file($composerPath . 'autoload_files.php')) { |
|
347 | - self::$files = require $composerPath . 'autoload_files.php'; |
|
346 | + if (is_file($composerPath.'autoload_files.php')) { |
|
347 | + self::$files = require $composerPath.'autoload_files.php'; |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | public static function parseName($name, $type = 0, $ucfirst = true) |
373 | 373 | { |
374 | 374 | if ($type) { |
375 | - $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) { |
|
375 | + $name = preg_replace_callback('/_([a-zA-Z])/', function($match) { |
|
376 | 376 | return strtoupper($match[1]); |
377 | 377 | }, $name); |
378 | 378 | return $ucfirst ? ucfirst($name) : lcfirst($name); |
@@ -390,12 +390,12 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public static function factory($name, $namespace = '', ...$args) |
392 | 392 | { |
393 | - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); |
|
393 | + $class = false !== strpos($name, '\\') ? $name : $namespace.ucwords($name); |
|
394 | 394 | |
395 | 395 | if (class_exists($class)) { |
396 | 396 | return Container::getInstance()->invokeClass($class, $args); |
397 | 397 | } else { |
398 | - throw new ClassNotFoundException('class not exists:' . $class, $class); |
|
398 | + throw new ClassNotFoundException('class not exists:'.$class, $class); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | |
347 | 347 | return call_user_func_array($function, $args); |
348 | 348 | } catch (ReflectionException $e) { |
349 | - throw new Exception('function not exists: ' . $function . '()'); |
|
349 | + throw new Exception('function not exists: '.$function.'()'); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | $method[0] = get_class($method[0]); |
377 | 377 | } |
378 | 378 | |
379 | - throw new Exception('method not exists: ' . (is_array($method) ? $method[0] . '::' . $method[1] : $method) . '()'); |
|
379 | + throw new Exception('method not exists: '.(is_array($method) ? $method[0].'::'.$method[1] : $method).'()'); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | return $reflect->newInstanceArgs($args); |
440 | 440 | |
441 | 441 | } catch (ReflectionException $e) { |
442 | - throw new ClassNotFoundException('class not exists: ' . $class, $class); |
|
442 | + throw new ClassNotFoundException('class not exists: '.$class, $class); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } elseif ($param->isDefaultValueAvailable()) { |
478 | 478 | $args[] = $param->getDefaultValue(); |
479 | 479 | } else { |
480 | - throw new InvalidArgumentException('method param miss:' . $name); |
|
480 | + throw new InvalidArgumentException('method param miss:'.$name); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 |
@@ -72,8 +72,7 @@ discard block |
||
72 | 72 | // 前置操作方法 即将废弃 |
73 | 73 | foreach ((array) $this->beforeActionList as $method => $options) { |
74 | 74 | is_numeric($method) ? |
75 | - $this->beforeAction($options) : |
|
76 | - $this->beforeAction($method, $options); |
|
75 | + $this->beforeAction($options) : $this->beforeAction($method, $options); |
|
77 | 76 | } |
78 | 77 | } |
79 | 78 | |
@@ -89,11 +88,11 @@ discard block |
||
89 | 88 | $only = $except = null; |
90 | 89 | |
91 | 90 | if (isset($val['only'])) { |
92 | - $only = array_map(function ($item) { |
|
91 | + $only = array_map(function($item) { |
|
93 | 92 | return strtolower($item); |
94 | 93 | }, $val['only']); |
95 | 94 | } elseif (isset($val['except'])) { |
96 | - $except = array_map(function ($item) { |
|
95 | + $except = array_map(function($item) { |
|
97 | 96 | return strtolower($item); |
98 | 97 | }, $val['except']); |
99 | 98 | } |
@@ -124,7 +123,7 @@ discard block |
||
124 | 123 | $options['only'] = explode(',', $options['only']); |
125 | 124 | } |
126 | 125 | |
127 | - $only = array_map(function ($val) { |
|
126 | + $only = array_map(function($val) { |
|
128 | 127 | return strtolower($val); |
129 | 128 | }, $options['only']); |
130 | 129 | |
@@ -136,7 +135,7 @@ discard block |
||
136 | 135 | $options['except'] = explode(',', $options['except']); |
137 | 136 | } |
138 | 137 | |
139 | - $except = array_map(function ($val) { |
|
138 | + $except = array_map(function($val) { |
|
140 | 139 | return strtolower($val); |
141 | 140 | }, $options['except']); |
142 | 141 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $this->config = array_merge($this->config, (array) $config); |
45 | 45 | |
46 | 46 | if (empty($this->config['view_path'])) { |
47 | - $this->config['view_path'] = $app->getModulePath() . 'view' . DIRECTORY_SEPARATOR; |
|
47 | + $this->config['view_path'] = $app->getModulePath().'view'.DIRECTORY_SEPARATOR; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $this->template = new Template($app, $this->config); |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | |
84 | 84 | // 模板不存在 抛出异常 |
85 | 85 | if (!is_file($template)) { |
86 | - throw new TemplateNotFoundException('template not exists:' . $template, $template); |
|
86 | + throw new TemplateNotFoundException('template not exists:'.$template, $template); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // 记录视图信息 |
90 | 90 | $this->app |
91 | - ->log('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]'); |
|
91 | + ->log('[ VIEW ] '.$template.' [ '.var_export(array_keys($data), true).' ]'); |
|
92 | 92 | |
93 | 93 | $this->template->fetch($template, $data, $config); |
94 | 94 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | if ($this->config['view_base']) { |
127 | 127 | // 基础视图目录 |
128 | 128 | $module = isset($module) ? $module : $request->module(); |
129 | - $path = $this->config['view_base'] . ($module ? $module . DIRECTORY_SEPARATOR : ''); |
|
129 | + $path = $this->config['view_base'].($module ? $module.DIRECTORY_SEPARATOR : ''); |
|
130 | 130 | } else { |
131 | - $path = isset($module) ? $this->app->getAppPath() . $module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR : $this->config['view_path']; |
|
131 | + $path = isset($module) ? $this->app->getAppPath().$module.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR : $this->config['view_path']; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $depr = $this->config['view_depr']; |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | if ($controller) { |
141 | 141 | if ('' == $template) { |
142 | 142 | // 如果模板文件名为空 按照默认规则定位 |
143 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $this->getActionTemplate($request); |
|
143 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$this->getActionTemplate($request); |
|
144 | 144 | } elseif (false === strpos($template, $depr)) { |
145 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
145 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | } else { |
149 | 149 | $template = str_replace(['/', ':'], $depr, substr($template, 1)); |
150 | 150 | } |
151 | 151 | |
152 | - return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); |
|
152 | + return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | protected function getActionTemplate($request) |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | |
74 | 74 | // 模板不存在 抛出异常 |
75 | 75 | if (!is_file($template)) { |
76 | - throw new TemplateNotFoundException('template not exists:' . $template, $template); |
|
76 | + throw new TemplateNotFoundException('template not exists:'.$template, $template); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $this->template = $template; |
80 | 80 | |
81 | 81 | // 记录视图信息 |
82 | 82 | $this->app |
83 | - ->log('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]'); |
|
83 | + ->log('[ VIEW ] '.$template.' [ '.var_export(array_keys($data), true).' ]'); |
|
84 | 84 | |
85 | 85 | extract($data, EXTR_OVERWRITE); |
86 | 86 | include $this->template; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $this->content = $content; |
99 | 99 | |
100 | 100 | extract($data, EXTR_OVERWRITE); |
101 | - eval('?>' . $this->content); |
|
101 | + eval('?>'.$this->content); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | private function parseTemplate($template) |
111 | 111 | { |
112 | 112 | if (empty($this->config['view_path'])) { |
113 | - $this->config['view_path'] = $this->app->getModulePath() . 'view' . DIRECTORY_SEPARATOR; |
|
113 | + $this->config['view_path'] = $this->app->getModulePath().'view'.DIRECTORY_SEPARATOR; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $request = $this->app['request']; |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | if ($this->config['view_base']) { |
125 | 125 | // 基础视图目录 |
126 | 126 | $module = isset($module) ? $module : $request->module(); |
127 | - $path = $this->config['view_base'] . ($module ? $module . DIRECTORY_SEPARATOR : ''); |
|
127 | + $path = $this->config['view_base'].($module ? $module.DIRECTORY_SEPARATOR : ''); |
|
128 | 128 | } else { |
129 | - $path = isset($module) ? $this->app->getAppPath() . $module . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR : $this->config['view_path']; |
|
129 | + $path = isset($module) ? $this->app->getAppPath().$module.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR : $this->config['view_path']; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $depr = $this->config['view_depr']; |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | if ($controller) { |
139 | 139 | if ('' == $template) { |
140 | 140 | // 如果模板文件名为空 按照默认规则定位 |
141 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $this->getActionTemplate($request); |
|
141 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$this->getActionTemplate($request); |
|
142 | 142 | } elseif (false === strpos($template, $depr)) { |
143 | - $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; |
|
143 | + $template = str_replace('.', DIRECTORY_SEPARATOR, $controller).$depr.$template; |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | } else { |
147 | 147 | $template = str_replace(['/', ':'], $depr, substr($template, 1)); |
148 | 148 | } |
149 | 149 | |
150 | - return $path . ltrim($template, '/') . '.' . ltrim($this->config['view_suffix'], '.'); |
|
150 | + return $path.ltrim($template, '/').'.'.ltrim($this->config['view_suffix'], '.'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | protected function getActionTemplate($request) |
@@ -202,7 +202,7 @@ |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | $call = [$class, $method]; |
205 | - $class = $class . '->' . $method; |
|
205 | + $class = $class.'->'.$method; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | $result = $this->app->invoke($call, [$params]); |