@@ -98,7 +98,7 @@ |
||
98 | 98 | return ob_get_clean(); |
99 | 99 | } |
100 | 100 | throw new NoTemplateFoundException( |
101 | - 'missing dest at ' . $this->getPath(), |
|
101 | + 'missing dest at '.$this->getPath(), |
|
102 | 102 | E_USER_ERROR, |
103 | 103 | $this->getPath(), |
104 | 104 | 1 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public function register() |
39 | 39 | { |
40 | - set_exception_handler([$this,'uncaughtException']); |
|
40 | + set_exception_handler([$this, 'uncaughtException']); |
|
41 | 41 | return $this; |
42 | 42 | } |
43 | 43 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | // 添加 * ? 匹配 |
37 | 37 | $url = str_replace(['\*', '\?'], ['[^/]*?', '[^/]'], $url); |
38 | 38 | // 编译页面参数 |
39 | - $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function ($match) use (&$parameters) { |
|
39 | + $url = preg_replace_callback('/\{(\w+)(?:\:([^}]+?))?\}/', function($match) use (&$parameters) { |
|
40 | 40 | $name = $match[1]; |
41 | 41 | $type = 'string'; |
42 | 42 | $extra = ''; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $url = static::parseIgnorableParameter($url, $matcher, $parameter, $mapper); |
71 | 71 | $url = static::replaceParameter($url, $matcher, $parameter, $mapper); |
72 | 72 | if (count($query) && $allowQuery) { |
73 | - return $url . '?' . http_build_query($query, 'v', '&', PHP_QUERY_RFC3986); |
|
73 | + return $url.'?'.http_build_query($query, 'v', '&', PHP_QUERY_RFC3986); |
|
74 | 74 | } |
75 | 75 | return $url; |
76 | 76 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | array $parameter, |
89 | 89 | array $mapper |
90 | 90 | ): string { |
91 | - return preg_replace_callback('/\[(.+?)\]/', function ($match) use ($matcher, $parameter, $mapper) { |
|
91 | + return preg_replace_callback('/\[(.+?)\]/', function($match) use ($matcher, $parameter, $mapper) { |
|
92 | 92 | if (preg_match('/\{(\w+).+?\}/', $match[1])) { |
93 | 93 | $count = 0; |
94 | 94 | $subUrl = static::replaceParameter($match[1], $matcher, $parameter, $mapper, true, $count); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | foreach ($parameter as $key => $value) { |
108 | 108 | if (is_numeric($key)) { |
109 | 109 | $mp = $matcher->getParameterByIndex($key); |
110 | - if ($mp !== null) { |
|
110 | + if ($mp !== null) { |
|
111 | 111 | unset($parameter[$key]); |
112 | 112 | $key = $mp->getIndexName(); |
113 | 113 | $parameter[$key] = $value; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ) { |
144 | 144 | return preg_replace_callback( |
145 | 145 | '/\{(\w+).+?\}/', |
146 | - function ($match) use ($matcher, $parameter, $mapper, $ignore, &$count) { |
|
146 | + function($match) use ($matcher, $parameter, $mapper, $ignore, &$count) { |
|
147 | 147 | if (array_key_exists($match[1], $mapper)) { |
148 | 148 | $count++; |
149 | 149 | return $mapper[$match[1]]->packValue($parameter[$match[1]]); |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | $methodStart = $splitLength ?: strpos($command, '::') ?: $dynmicsMethod; |
63 | 63 | $parameter = self::buildParameter($parameter); |
64 | 64 | if ($methodStart > 0) { |
65 | - $splitLength = $splitLength > 0 ? 1:2; |
|
65 | + $splitLength = $splitLength > 0 ? 1 : 2; |
|
66 | 66 | $methodName = substr($command, $methodStart + $splitLength); |
67 | 67 | $command = substr($command, 0, $methodStart); |
68 | 68 | list($className, $constructParameter) = self::splitParameter($command); |
69 | 69 | $constructParameter = self::buildParameter($constructParameter); |
70 | - $target = new MethodTarget($className, $dynmicsMethod? $constructParameter :null, $methodName, $parameter); |
|
70 | + $target = new MethodTarget($className, $dynmicsMethod ? $constructParameter : null, $methodName, $parameter); |
|
71 | 71 | } else { |
72 | 72 | $target = new FunctionTarget(self::buildName($command), $parameter); |
73 | 73 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | if (preg_match('/^[\w\\\\\/.]+$/', $name) !== 1) { |
100 | 100 | throw new InvalidNameException(sprintf('invalid name: %s ', $name)); |
101 | 101 | } |
102 | - return str_replace(['.','/'], '\\', $name); |
|
102 | + return str_replace(['.', '/'], '\\', $name); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | private static function splitParameter(string $command):array |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $parameter = substr($command, $paramStart + 1, strlen($command) - $paramStart - 2); |
111 | 111 | $command = substr($command, 0, $paramStart); |
112 | 112 | } |
113 | - return [$command,$parameter]; |
|
113 | + return [$command, $parameter]; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | private static function buildParameter(?string $parameter) |
@@ -11,21 +11,21 @@ discard block |
||
11 | 11 | * @param string $path |
12 | 12 | * @return string|null |
13 | 13 | */ |
14 | - public static function resolve(string $path):?string |
|
14 | + public static function resolve(string $path): ?string |
|
15 | 15 | { |
16 | 16 | if (file_exists($path) && is_file($path)) { |
17 | 17 | return $path; |
18 | 18 | } |
19 | 19 | $basepath = dirname($path).'/'.pathinfo($path, PATHINFO_FILENAME); |
20 | 20 | |
21 | - return static::resolveYaml($basepath) ?? static::resolveExtensions($basepath, ['json','php','ini']); |
|
21 | + return static::resolveYaml($basepath) ?? static::resolveExtensions($basepath, ['json', 'php', 'ini']); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * @param string $basepath |
26 | 26 | * @return string|null |
27 | 27 | */ |
28 | - protected static function resolveYaml(string $basepath):?string |
|
28 | + protected static function resolveYaml(string $basepath): ?string |
|
29 | 29 | { |
30 | 30 | if (file_exists($conf = $basepath.'.yml') || file_exists($conf = $basepath.'.yaml')) { |
31 | 31 | if (function_exists('yaml_parse') || class_exists('Spyc')) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | return null; |
36 | 36 | } |
37 | 37 | |
38 | - protected static function resolveExtensions(string $basepath, array $extensions):?string |
|
38 | + protected static function resolveExtensions(string $basepath, array $extensions): ?string |
|
39 | 39 | { |
40 | 40 | foreach ($extensions as $ext) { |
41 | 41 | $conf = $basepath.'.'.$ext; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | throw new FileLoggerException(__CLASS__.':'.sprintf('cannot create log file')); |
95 | 95 | } |
96 | 96 | $this->latest = $save.'/'.$this->getConfig('file-name'); |
97 | - register_shutdown_function([$this,'save']); |
|
97 | + register_shutdown_function([$this, 'save']); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | public function getDefaultConfig():array |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | protected function packLogFile() |
114 | 114 | { |
115 | 115 | $logFile = $this->latest; |
116 | - $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path') .'/'.date('Y-m-d').'.zip'); |
|
116 | + $path = preg_replace('/[\\\\]+/', '/', $this->getConfig('save-zip-path').'/'.date('Y-m-d').'.zip'); |
|
117 | 117 | $zip = $this->getZipArchive($path); |
118 | 118 | if ($zip !== null) { |
119 | - if ($zip->addFile($logFile, date('Y-m-d'). '-'. $zip->numFiles .'.log')) { |
|
119 | + if ($zip->addFile($logFile, date('Y-m-d').'-'.$zip->numFiles.'.log')) { |
|
120 | 120 | array_push($this->removeFiles, $logFile); |
121 | 121 | } |
122 | 122 | if (is_dir($this->getConfig('save-pack-path'))) { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $zip->close(); |
131 | 131 | } else { |
132 | 132 | if (is_file($logFile) && file_exists($logFile)) { |
133 | - rename($logFile, $this->getConfig('save-path') . '/' . date('Y-m-d'). '-'. substr(md5_file($logFile), 0, 8).'.log'); |
|
133 | + rename($logFile, $this->getConfig('save-path').'/'.date('Y-m-d').'-'.substr(md5_file($logFile), 0, 8).'.log'); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } elseif (null === $val) { |
236 | 236 | $val = 'null'; |
237 | 237 | } |
238 | - $replace['{' . $key . '}'] = $val; |
|
238 | + $replace['{'.$key.'}'] = $val; |
|
239 | 239 | } |
240 | 240 | return strtr($message, $replace); |
241 | 241 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | public function input(string $name, $data) |
58 | 58 | { |
59 | 59 | if (array_key_exists($name, $this->processor)) { |
60 | - if ($this->processor[$name] === ObjectMiddleware::SERIALIZE){ |
|
61 | - return $data === null? $data : serialize($data); |
|
60 | + if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
|
61 | + return $data === null ? $data : serialize($data); |
|
62 | 62 | } |
63 | - if ($this->processor[$name] === ObjectMiddleware::JSON){ |
|
63 | + if ($this->processor[$name] === ObjectMiddleware::JSON) { |
|
64 | 64 | return json_encode($data); |
65 | 65 | } |
66 | 66 | } |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | public function output(string $name, $data) |
78 | 78 | { |
79 | 79 | if (array_key_exists($name, $this->processor)) { |
80 | - if ($this->processor[$name] === ObjectMiddleware::SERIALIZE){ |
|
80 | + if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
|
81 | 81 | return unserialize($data) ?: null; |
82 | 82 | } |
83 | - if ($this->processor[$name] === ObjectMiddleware::JSON){ |
|
83 | + if ($this->processor[$name] === ObjectMiddleware::JSON) { |
|
84 | 84 | return json_decode($data); |
85 | 85 | } |
86 | 86 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | if ($doc = $property->getDocComment()) { |
114 | 114 | if (is_string($doc) && preg_match('/@var\s+(\w+)/i', $doc, $match)) { |
115 | 115 | $type = strtolower($match[1]); |
116 | - if (in_array($type, ['boolean', 'bool', 'integer', 'int' , 'float' , 'double', 'string'])) { |
|
116 | + if (in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string'])) { |
|
117 | 117 | return ObjectMiddleware::RAW; |
118 | 118 | } |
119 | 119 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | private function inputSerialize($data) |
197 | 197 | { |
198 | - return $data === null? $data : serialize($data); |
|
198 | + return $data === null ? $data : serialize($data); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | */ |
218 | 218 | private function inputJson($data) |
219 | 219 | { |
220 | - return $data === null? $data : json_encode($data); |
|
220 | + return $data === null ? $data : json_encode($data); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -132,7 +132,7 @@ |
||
132 | 132 | */ |
133 | 133 | public function charset(string $charset) |
134 | 134 | { |
135 | - $this->charset = 'CHARACTER SET ' . $charset; |
|
135 | + $this->charset = 'CHARACTER SET '.$charset; |
|
136 | 136 | return $this; |
137 | 137 | } |
138 | 138 |