@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | /** |
88 | 88 | * インスタンスを返却する |
89 | - * @return WebStream\Module\Logger ロガーインスタンス |
|
89 | + * @return Logger ロガーインスタンス |
|
90 | 90 | */ |
91 | 91 | public static function getInstance() |
92 | 92 | { |
@@ -193,6 +193,7 @@ discard block |
||
193 | 193 | * @param string ログレベル文字列 |
194 | 194 | * @param string 出力文字列 |
195 | 195 | * @param array<mixed> 埋め込み値リスト |
196 | + * @param string $msg |
|
196 | 197 | */ |
197 | 198 | public function write($level, $msg, $context = null) |
198 | 199 | { |
@@ -288,6 +289,8 @@ discard block |
||
288 | 289 | * ローテートを実行する |
289 | 290 | * @param integer 作成日時のUnixTime |
290 | 291 | * @param integer 現在日時のUnixTime |
292 | + * @param integer $from |
|
293 | + * @param integer $to |
|
291 | 294 | */ |
292 | 295 | private function runRotate($from, $to) |
293 | 296 | { |
@@ -7,7 +7,6 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | use WebStream\Module\Security; |
10 | -use WebStream\DI\ServiceLocator; |
|
11 | 10 | use WebStream\Log\Logger; |
12 | 11 | |
13 | 12 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | date_default_timezone_set('Asia/Tokyo'); |
165 | 165 | $msec = sprintf("%2d", floatval(microtime()) * 100); |
166 | 166 | |
167 | - return strftime("%Y-%m-%d %H:%M:%S") . "," . $msec; |
|
167 | + return strftime("%Y-%m-%d %H:%M:%S").",".$msec; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | $msg .= "\n"; |
185 | - $msg .= "\t#" . trim($stacktraceLine); |
|
185 | + $msg .= "\t#".trim($stacktraceLine); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $msg; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $content = fread($handle, $size); |
249 | 249 | fclose($handle); |
250 | 250 | if (!preg_match('/^\d{10}$/', $content)) { |
251 | - throw new LoggerException("Invalid log state file contents: " . $content); |
|
251 | + throw new LoggerException("Invalid log state file contents: ".$content); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | return intval($content); |
@@ -183,6 +183,7 @@ |
||
183 | 183 | /** |
184 | 184 | * ログローテートサイクルを時間に変換 |
185 | 185 | * @param string ローテートサイクル |
186 | + * @param string $cycle |
|
186 | 187 | * @return int ローテート時間 |
187 | 188 | */ |
188 | 189 | private function cycle2value($cycle) |
@@ -43,12 +43,12 @@ |
||
43 | 43 | public function load($configPath) |
44 | 44 | { |
45 | 45 | $this->loadConfigFile($configPath) |
46 | - ->loadLogLevel() |
|
47 | - ->loadLogFilePath() |
|
48 | - ->loadRotateCycle() |
|
49 | - ->loadRotateSize() |
|
50 | - ->loadApplicationName() |
|
51 | - ->loadFormat(); |
|
46 | + ->loadLogLevel() |
|
47 | + ->loadLogFilePath() |
|
48 | + ->loadRotateCycle() |
|
49 | + ->loadRotateSize() |
|
50 | + ->loadApplicationName() |
|
51 | + ->loadFormat(); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $configMap = $this->parseConfig($configPath); |
71 | 71 | if ($configMap === null) { |
72 | - throw new LoggerException("Log config file does not exist: " . $configPath); |
|
72 | + throw new LoggerException("Log config file does not exist: ".$configPath); |
|
73 | 73 | } |
74 | 74 | $this->configMap = $configMap; |
75 | 75 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | $logLevel = $this->toLogLevelValue($this->configMap["level"]); |
90 | 90 | if ($logLevel === 0) { |
91 | - throw new LoggerException("Invalid log level: " . $this->configMap["level"]); |
|
91 | + throw new LoggerException("Invalid log level: ".$this->configMap["level"]); |
|
92 | 92 | } |
93 | 93 | $this->logContainer->logLevel = $logLevel; |
94 | 94 | |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | throw new LoggerException("Log path must be defined."); |
106 | 106 | } |
107 | 107 | |
108 | - $path = $this->getApplicationRoot() . "/" . $this->configMap["path"]; |
|
108 | + $path = $this->getApplicationRoot()."/".$this->configMap["path"]; |
|
109 | 109 | if (!file_exists(dirname($path))) { |
110 | - throw new LoggerException("Log directory does not exist: " . dirname($path)); |
|
110 | + throw new LoggerException("Log directory does not exist: ".dirname($path)); |
|
111 | 111 | } |
112 | 112 | $this->logContainer->logPath = $path; |
113 | 113 | |
114 | - $this->logContainer->statusPath = preg_replace_callback('/(.*)\..+/', function ($matches) { |
|
114 | + $this->logContainer->statusPath = preg_replace_callback('/(.*)\..+/', function($matches) { |
|
115 | 115 | return "$matches[1].status"; |
116 | 116 | }, $this->logContainer->logPath); |
117 | 117 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $rotateCycle = $this->cycle2value($this->configMap["rotate_cycle"]); |
129 | 129 | // 妥当なローテートサイクルか |
130 | 130 | if ($rotateCycle === 0) { |
131 | - throw new LoggerException("Invalid log rotate cycle: " . $this->configMap["rotate_cycle"]); |
|
131 | + throw new LoggerException("Invalid log rotate cycle: ".$this->configMap["rotate_cycle"]); |
|
132 | 132 | } |
133 | 133 | $this->logContainer->rotateCycle = $rotateCycle; |
134 | 134 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $rotateSize = intval($this->configMap["rotate_size"]); |
147 | 147 | // ローテートサイズが不正の場合(正の整数以外の値が設定された場合) |
148 | 148 | if ($rotateSize <= 0) { |
149 | - throw new LoggerException("Invalid log rotate size: " . $this->configMap["rotate_size"]); |
|
149 | + throw new LoggerException("Invalid log rotate size: ".$this->configMap["rotate_size"]); |
|
150 | 150 | } |
151 | 151 | $this->logContainer->rotateSize = $rotateSize; |
152 | 152 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * フォーマット済みメッセージを返却する |
36 | 36 | * @param string メッセージ |
37 | 37 | * @param string ログレベル |
38 | - * @return フォーマット済みメッセージ |
|
38 | + * @return string |
|
39 | 39 | */ |
40 | 40 | public function getFormattedMessage($message, $logLevel) |
41 | 41 | { |
@@ -50,7 +50,7 @@ |
||
50 | 50 | // メッセージ |
51 | 51 | $formattedMessage = preg_replace('/%m/', $message, $formattedMessage); |
52 | 52 | |
53 | - return $formattedMessage . "\n"; |
|
53 | + return $formattedMessage."\n"; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -4,7 +4,6 @@ |
||
4 | 4 | require_once dirname(__FILE__) . '/Utility/FileUtils.php'; |
5 | 5 | require_once dirname(__FILE__) . '/../DI/Injector.php'; |
6 | 6 | |
7 | -use WebStream\Module\Utility\ApplicationUtils; |
|
8 | 7 | use WebStream\Module\Utility\FileUtils; |
9 | 8 | use WebStream\DI\Injector; |
10 | 9 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace WebStream\Module; |
3 | 3 | |
4 | -require_once dirname(__FILE__) . '/Utility/FileUtils.php'; |
|
5 | -require_once dirname(__FILE__) . '/../DI/Injector.php'; |
|
4 | +require_once dirname(__FILE__).'/Utility/FileUtils.php'; |
|
5 | +require_once dirname(__FILE__).'/../DI/Injector.php'; |
|
6 | 6 | |
7 | 7 | use WebStream\Module\Utility\ApplicationUtils; |
8 | 8 | use WebStream\Module\Utility\FileUtils; |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function import($filepath, callable $filter = null) |
51 | 51 | { |
52 | - $includeFile = $this->applicationRoot . "/" . $filepath; |
|
52 | + $includeFile = $this->applicationRoot."/".$filepath; |
|
53 | 53 | if (is_file($includeFile)) { |
54 | 54 | $ext = pathinfo($includeFile, PATHINFO_EXTENSION); |
55 | 55 | if ($ext === 'php') { |
56 | 56 | if ($filter === null || (is_callable($filter) && $filter($includeFile) === true)) { |
57 | 57 | include_once $includeFile; |
58 | - $this->logger->debug($includeFile . " import success."); |
|
58 | + $this->logger->debug($includeFile." import success."); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function importAll($dirPath, callable $filter = null) |
75 | 75 | { |
76 | - $includeDir = realpath($this->applicationRoot . "/" . $dirPath); |
|
76 | + $includeDir = realpath($this->applicationRoot."/".$dirPath); |
|
77 | 77 | if (is_dir($includeDir)) { |
78 | 78 | $iterator = $this->getFileSearchIterator($includeDir); |
79 | 79 | $isSuccess = true; |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | if ($ext === 'php') { |
87 | 87 | if ($filter === null || (is_callable($filter) && $filter($filepath) === true)) { |
88 | 88 | include_once $filepath; |
89 | - $this->logger->debug($filepath . " import success."); |
|
89 | + $this->logger->debug($filepath." import success."); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } else { |
93 | - $this->logger->warn($filepath . " import failure."); |
|
93 | + $this->logger->warn($filepath." import failure."); |
|
94 | 94 | $isSuccess = false; |
95 | 95 | } |
96 | 96 | } |
@@ -116,22 +116,22 @@ discard block |
||
116 | 116 | // まずcoreディレクトリを検索 |
117 | 117 | // coreディレクトリは名前空間とディレクトリパスが |
118 | 118 | // 紐づいているのでそのまま連結して読ませる |
119 | - $includeFile = $rootDir . "/core/" . $className . ".php"; |
|
119 | + $includeFile = $rootDir."/core/".$className.".php"; |
|
120 | 120 | if (is_file($includeFile)) { |
121 | 121 | include_once $includeFile; |
122 | - $this->logger->debug($includeFile . " load success. (search from " . $rootDir . "/core/)"); |
|
122 | + $this->logger->debug($includeFile." load success. (search from ".$rootDir."/core/)"); |
|
123 | 123 | |
124 | 124 | return [$includeFile]; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // さらに見つからなかったらappディレクトリを名前空間付きで全検索し、マッチするもの全てをincludeする |
128 | - $iterator = $this->getFileSearchIterator($rootDir . "/app"); |
|
128 | + $iterator = $this->getFileSearchIterator($rootDir."/app"); |
|
129 | 129 | $includeList = []; |
130 | 130 | foreach ($iterator as $filepath => $fileObject) { |
131 | - if (strpos($filepath, $className . ".php") !== false) { |
|
131 | + if (strpos($filepath, $className.".php") !== false) { |
|
132 | 132 | include_once $filepath; |
133 | 133 | $includeList[] = $filepath; |
134 | - $this->logger->debug($filepath . " load success. (search from " . $rootDir . "/app/)"); |
|
134 | + $this->logger->debug($filepath." load success. (search from ".$rootDir."/app/)"); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | if (!empty($includeList)) { |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | $classNameWithoutNamespace = $matches[1]; |
145 | 145 | // この処理が走るケースはapp配下のクラスがディレクトリ構成と名前空間が一致していない |
146 | 146 | // 場合以外ない(テスト用クラス除く)ので、app配下の検索を優先する |
147 | - $iterator = $this->getFileSearchIterator($rootDir . "/app"); |
|
147 | + $iterator = $this->getFileSearchIterator($rootDir."/app"); |
|
148 | 148 | foreach ($iterator as $filepath => $fileObject) { |
149 | - if (strpos($filepath, $classNameWithoutNamespace . ".php") !== false) { |
|
149 | + if (strpos($filepath, $classNameWithoutNamespace.".php") !== false) { |
|
150 | 150 | include_once $filepath; |
151 | 151 | $includeList[] = $filepath; |
152 | - $this->logger->debug($filepath . " load success. (full search)"); |
|
152 | + $this->logger->debug($filepath." load success. (full search)"); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | if (!empty($includeList)) { |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | // ここに到達するのはテスト用クラスのみ |
160 | - $iterator = $this->getFileSearchIterator($rootDir . "/core"); |
|
160 | + $iterator = $this->getFileSearchIterator($rootDir."/core"); |
|
161 | 161 | foreach ($iterator as $filepath => $fileObject) { |
162 | - if (strpos($filepath, $classNameWithoutNamespace . ".php") !== false) { |
|
162 | + if (strpos($filepath, $classNameWithoutNamespace.".php") !== false) { |
|
163 | 163 | include_once $filepath; |
164 | 164 | $includeList[] = $filepath; |
165 | - $this->logger->debug($filepath . " load success. (full search, use in test)"); |
|
165 | + $this->logger->debug($filepath." load success. (full search, use in test)"); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | if (!empty($includeList)) { |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | // 静的ファイルへのパスがルーティングルールに定義された場合 |
83 | 83 | // パス定義された時点で弾く |
84 | 84 | if (preg_match('/\/(img|js|css|file)(?:$|\/)/', $path)) { |
85 | - throw new RouterException("Include the prohibit routing path: " . $path); |
|
85 | + throw new RouterException("Include the prohibit routing path: ".$path); |
|
86 | 86 | } |
87 | 87 | // 許可したルーティングパス定義に合っていなければ弾く |
88 | 88 | if (!preg_match('/^\/{1}(?:$|:?[a-zA-Z]{1}[a-zA-Z0-9-_\/\.:]{0,}$)/', $path)) { |
89 | - throw new RouterException("Invalid path defintion: " . $path); |
|
89 | + throw new RouterException("Invalid path defintion: ".$path); |
|
90 | 90 | } |
91 | 91 | // ルールとURLがマッチした場合に動的にチェックを掛ける |
92 | 92 | // パスがマッチしたときにアクション名をチェックし、その時点で弾く |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // NG例:my__blog, my_blog_ |
97 | 97 | if (!preg_match('/^(?:([a-z]{1}(?:_(?=[a-z])|[a-z0-9])+))#(?:([a-z]{1}(?:_(?=[a-z])|[a-z0-9])+))$/', $ca, $matches)) { |
98 | 98 | // ルーティング定義(Controller#Action)が正しくない場合 |
99 | - throw new RouterException("Invalid controller#action definition: " . $ca); |
|
99 | + throw new RouterException("Invalid controller#action definition: ".$ca); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | if (($this->request->pathInfo !== $path) && |
130 | 130 | count(explode('/', $path)) === count(explode('/', $this->request->pathInfo))) { |
131 | 131 | // プレースホルダと実URLをひもづける |
132 | - $pathPattern = "/^\/" . implode("\/", $tokens) . "$/"; |
|
132 | + $pathPattern = "/^\/".implode("\/", $tokens)."$/"; |
|
133 | 133 | if (preg_match($pathPattern, $this->request->pathInfo, $matches)) { |
134 | 134 | for ($j = 1; $j < count($matches); $j++) { |
135 | 135 | $key = $keyList[$j - 1]; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $this->setController($matches[1]); |
147 | 147 | $this->setAction($matches[2]); |
148 | 148 | $this->routingContainer->params = $placeholderedParams; |
149 | - $this->logger->info("Routed path: " . $matches[1] . "#" . $matches[2]); |
|
149 | + $this->logger->info("Routed path: ".$matches[1]."#".$matches[2]); |
|
150 | 150 | |
151 | 151 | // ルーティングルールがマッチした場合は抜ける |
152 | 152 | return true; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function resolveStaticFilePath() |
163 | 163 | { |
164 | - $staticFile = $this->applicationInfo->applicationRoot . "/app/views/" . $this->applicationInfo->publicDir . $this->request->pathInfo; |
|
164 | + $staticFile = $this->applicationInfo->applicationRoot."/app/views/".$this->applicationInfo->publicDir.$this->request->pathInfo; |
|
165 | 165 | |
166 | 166 | if (is_file($staticFile)) { |
167 | 167 | $this->routingContainer->staticFile = $staticFile; |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | $less = new \lessc(); |
171 | 171 | $dirpath = dirname($staticFile); |
172 | 172 | $filenameWitoutExt = pathinfo($staticFile, PATHINFO_FILENAME); |
173 | - $lessFilepath = $dirpath . "/" . $filenameWitoutExt . ".less"; |
|
173 | + $lessFilepath = $dirpath."/".$filenameWitoutExt.".less"; |
|
174 | 174 | // lessファイルも見つからない場合はエラー |
175 | 175 | if (!file_exists($lessFilepath)) { |
176 | - $this->logger->error("The file of css has been specified, but not found even file of less:" . $lessFilepath); |
|
176 | + $this->logger->error("The file of css has been specified, but not found even file of less:".$lessFilepath); |
|
177 | 177 | |
178 | 178 | return; |
179 | 179 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | if (is_file($staticFile)) { |
182 | 182 | $this->routingContainer->staticFile = $staticFile; |
183 | 183 | } else { |
184 | - $this->logger->error("Failed to file create, cause parmission denied: " . $dirpath); |
|
184 | + $this->logger->error("Failed to file create, cause parmission denied: ".$dirpath); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | { |
196 | 196 | if (isset($controller)) { |
197 | 197 | $this->routingContainer->pageName = $this->snake2ucamel($controller); |
198 | - $this->routingContainer->controller = $this->snake2ucamel($controller) . "Controller"; |
|
198 | + $this->routingContainer->controller = $this->snake2ucamel($controller)."Controller"; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | $sapi = php_sapi_name(); |
34 | 34 | if (array_key_exists($sapi, $this->sapis) && $this->sapis[$sapi] === 'http') { |
35 | - echo $text . "<br>"; |
|
35 | + echo $text."<br>"; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | $sapi = php_sapi_name(); |
34 | 34 | if (array_key_exists($sapi, $this->sapis) && $this->sapis[$sapi] === 'console') { |
35 | - echo $text . PHP_EOL; |
|
35 | + echo $text.PHP_EOL; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |