@@ -17,6 +17,7 @@ |
||
17 | 17 | * オブジェクトを注入する |
18 | 18 | * @param string プロパティ名 |
19 | 19 | * @param mixed オブジェクト |
20 | + * @param string $name |
|
20 | 21 | * @return Injector |
21 | 22 | */ |
22 | 23 | public function inject($name, $object) |
@@ -13,6 +13,7 @@ |
||
13 | 13 | { |
14 | 14 | /** |
15 | 15 | * constructor |
16 | + * @param \Exception $exception |
|
16 | 17 | */ |
17 | 18 | public function __construct($message, $code = 500, $exception = null) |
18 | 19 | { |
@@ -26,7 +26,7 @@ |
||
26 | 26 | $exception = $this; |
27 | 27 | } |
28 | 28 | |
29 | - Logger::error(get_class($exception) . " is thrown: " . $exception->getFile() . "(" . $exception->getLine() . ")"); |
|
29 | + Logger::error(get_class($exception)." is thrown: ".$exception->getFile()."(".$exception->getLine().")"); |
|
30 | 30 | if (!empty($message)) { |
31 | 31 | Logger::error($this->getMessage(), $this->getTraceAsString()); |
32 | 32 | } |
@@ -108,6 +108,7 @@ |
||
108 | 108 | /** |
109 | 109 | * SERVERパラメータ取得 |
110 | 110 | * @param string パラメータキー |
111 | + * @param string $key |
|
111 | 112 | */ |
112 | 113 | private function server($key) |
113 | 114 | { |
@@ -67,6 +67,7 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * Cache-Controlを設定 |
69 | 69 | * @param String Cache-Control |
70 | + * @param string $cacheControl |
|
70 | 71 | */ |
71 | 72 | public function setCacheControl($cacheControl) |
72 | 73 | { |
@@ -76,6 +77,7 @@ discard block |
||
76 | 77 | /** |
77 | 78 | * Pragmaを設定 |
78 | 79 | * @param String Pragma |
80 | + * @param string $pragma |
|
79 | 81 | */ |
80 | 82 | public function setPragma($pragma) |
81 | 83 | { |
@@ -86,6 +88,7 @@ discard block |
||
86 | 88 | * MimeTypeを設定 |
87 | 89 | * ファイルタイプにより指定 |
88 | 90 | * @param String ファイルタイプ |
91 | + * @param string $fileType |
|
89 | 92 | */ |
90 | 93 | public function setType($fileType) |
91 | 94 | { |
@@ -167,6 +170,7 @@ discard block |
||
167 | 170 | /** |
168 | 171 | * Content-Lengthを設定 |
169 | 172 | * @param Integer Content-Length |
173 | + * @param integer $contentLength |
|
170 | 174 | */ |
171 | 175 | public function setContentLength($contentLength) |
172 | 176 | { |
@@ -187,6 +191,7 @@ discard block |
||
187 | 191 | /** |
188 | 192 | * Content-Transfer-Encodingを設定 |
189 | 193 | * @param String エンコーディング方法 |
194 | + * @param string $contentTransferEncoding |
|
190 | 195 | */ |
191 | 196 | public function setContentTransferEncoding($contentTransferEncoding) |
192 | 197 | { |
@@ -196,6 +201,7 @@ discard block |
||
196 | 201 | /** |
197 | 202 | * Expiresを設定 |
198 | 203 | * @param Integer 有効期限 |
204 | + * @param integer $expires |
|
199 | 205 | */ |
200 | 206 | public function setExpires($expires) |
201 | 207 | { |
@@ -205,6 +211,7 @@ discard block |
||
205 | 211 | /** |
206 | 212 | * レスポンスボディを設定 |
207 | 213 | * @param String レスポンスボディ |
214 | + * @param string $body |
|
208 | 215 | */ |
209 | 216 | public function setBody($body) |
210 | 217 | { |
@@ -504,6 +511,7 @@ discard block |
||
504 | 511 | /** |
505 | 512 | * 指定したステータスコードのページに遷移 |
506 | 513 | * @param Integer ステータスコード |
514 | + * @param integer $statusCode |
|
507 | 515 | */ |
508 | 516 | public function move($statusCode) |
509 | 517 | { |
@@ -545,6 +553,7 @@ discard block |
||
545 | 553 | /** |
546 | 554 | * HTMLテンプレート |
547 | 555 | * @param String 表示内容 |
556 | + * @param string $content |
|
548 | 557 | * @return String HTML |
549 | 558 | */ |
550 | 559 | private function bodyTemplate($content) |
@@ -236,7 +236,7 @@ |
||
236 | 236 | { |
237 | 237 | // StatusCode |
238 | 238 | $headerMessage = 'HTTP/' . self::HTTP_VERSION . ' ' . |
239 | - $this->statusCode . ' ' . $this->status[$this->statusCode]; |
|
239 | + $this->statusCode . ' ' . $this->status[$this->statusCode]; |
|
240 | 240 | header($headerMessage); |
241 | 241 | |
242 | 242 | // Redirect |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | public function setStatusCode($statusCode) |
156 | 156 | { |
157 | 157 | if (!is_string($statusCode) && !is_int($statusCode)) { |
158 | - throw new ConnectionException("Invalid status code format: " . strval($statusCode)); |
|
158 | + throw new ConnectionException("Invalid status code format: ".strval($statusCode)); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | if (!array_key_exists($statusCode, $this->status)) { |
162 | - throw new ConnectionException("Unknown status code: " . $statusCode); |
|
162 | + throw new ConnectionException("Unknown status code: ".$statusCode); |
|
163 | 163 | } |
164 | 164 | $this->statusCode = $statusCode; |
165 | 165 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | public function setContentDisposition($filename) |
181 | 181 | { |
182 | 182 | if (file_exists($filename)) { |
183 | - $this->contentDisposition = 'attachement; filename="'. basename($filename) . '"'; |
|
183 | + $this->contentDisposition = 'attachement; filename="'.basename($filename).'"'; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -235,43 +235,43 @@ discard block |
||
235 | 235 | public function header() |
236 | 236 | { |
237 | 237 | // StatusCode |
238 | - $headerMessage = 'HTTP/' . self::HTTP_VERSION . ' ' . |
|
239 | - $this->statusCode . ' ' . $this->status[$this->statusCode]; |
|
238 | + $headerMessage = 'HTTP/'.self::HTTP_VERSION.' '. |
|
239 | + $this->statusCode.' '.$this->status[$this->statusCode]; |
|
240 | 240 | header($headerMessage); |
241 | 241 | |
242 | 242 | // Redirect |
243 | 243 | if (intval($this->statusCode) === 301) { |
244 | - header('Location: ' . $this->location); |
|
244 | + header('Location: '.$this->location); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // Content-Type |
248 | - header('Content-Type: ' . $this->mimeType . '; charset=' . $this->charset); |
|
248 | + header('Content-Type: '.$this->mimeType.'; charset='.$this->charset); |
|
249 | 249 | |
250 | 250 | // Content-Length |
251 | 251 | if ($this->contentLength === null) { |
252 | 252 | $this->contentLength = $this->bytelen($this->body); |
253 | 253 | } |
254 | - header('Content-Length: ' . $this->contentLength); |
|
254 | + header('Content-Length: '.$this->contentLength); |
|
255 | 255 | |
256 | 256 | // Content-Disposition |
257 | 257 | if ($this->contentDisposition !== null) { |
258 | - header('Content-Disposition: ' . $this->contentDisposition); |
|
258 | + header('Content-Disposition: '.$this->contentDisposition); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // Content-Transfer-Encoding |
262 | 262 | if ($this->contentTransferEncoding !== null) { |
263 | - header('Content-Transfer-Encoding: ' . $this->contentTransferEncoding); |
|
263 | + header('Content-Transfer-Encoding: '.$this->contentTransferEncoding); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | // Cache-Control |
267 | - header('Cache-Control: ' . $this->cacheControl); |
|
267 | + header('Cache-Control: '.$this->cacheControl); |
|
268 | 268 | |
269 | 269 | // Pragma |
270 | - header('Pragma: ' . $this->pragma); |
|
270 | + header('Pragma: '.$this->pragma); |
|
271 | 271 | |
272 | 272 | // Expires |
273 | 273 | if ($this->expires !== null) { |
274 | - header('Expires: ' . $this->expires); |
|
274 | + header('Expires: '.$this->expires); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | // X-Content-Type-Options |
@@ -279,20 +279,20 @@ discard block |
||
279 | 279 | |
280 | 280 | // Access-Control-Allow-Origin |
281 | 281 | if (!empty($this->accessControlAllowOrigin)) { |
282 | - header('Access-Control-Allow-Origin: ' . implode(',', $this->accessControlAllowOrigin)); |
|
282 | + header('Access-Control-Allow-Origin: '.implode(',', $this->accessControlAllowOrigin)); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | // X-Frame-Options |
286 | 286 | if ($this->xframeOptions !== null) { |
287 | - header('X-Frame-Options: ' . $this->xframeOptions); |
|
287 | + header('X-Frame-Options: '.$this->xframeOptions); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | // X-XSS-Protection |
291 | 291 | if ($this->xxssProtection !== null) { |
292 | - header('X-XSS-Protection: ' . $this->xxssProtection); |
|
292 | + header('X-XSS-Protection: '.$this->xxssProtection); |
|
293 | 293 | } |
294 | 294 | |
295 | - $this->logger->info("HTTP access occured: status code " . $this->statusCode); |
|
295 | + $this->logger->info("HTTP access occured: status code ".$this->statusCode); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | ob_clean(); // これまでの出力バッファをクリア |
511 | 511 | $statusCode = array_key_exists($statusCode, $this->status) ? $statusCode : 500; |
512 | 512 | $this->setStatusCode($statusCode); |
513 | - $bodyMessage = $statusCode . ' ' . $this->status[$statusCode]; |
|
513 | + $bodyMessage = $statusCode.' '.$this->status[$statusCode]; |
|
514 | 514 | $this->setBody($this->bodyTemplate($bodyMessage)); |
515 | 515 | $this->send(); |
516 | 516 | exit; |
@@ -49,6 +49,10 @@ |
||
49 | 49 | * @param string Cookieを有効にするドメイン |
50 | 50 | * @param boolean Secure属性を有効にする |
51 | 51 | * @param boolean HttpOnly属性を有効にする |
52 | + * @param string $path |
|
53 | + * @param string $domain |
|
54 | + * @param boolean $secure |
|
55 | + * @param boolean $httpOnly |
|
52 | 56 | */ |
53 | 57 | private function initialize($expire, $path, $domain, $secure, $httpOnly) |
54 | 58 | { |
@@ -27,6 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * クラスをロードする |
29 | 29 | * @param string|array クラス名 |
30 | + * @param string $className |
|
30 | 31 | * @return array<string> ロード済みクラスリスト |
31 | 32 | */ |
32 | 33 | public function load($className) |
@@ -38,6 +39,7 @@ discard block |
||
38 | 39 | * ファイルをインポートする |
39 | 40 | * @param string ファイルパス |
40 | 41 | * @param callable フィルタリング無名関数 trueを返すとインポート |
42 | + * @param string $filepath |
|
41 | 43 | * @return boolean インポート結果 |
42 | 44 | */ |
43 | 45 | public function import($filepath, callable $filter = null) |
@@ -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 | } |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | // appディレクトリを名前空間付きで全検索し、マッチするもの全てをincludeする |
117 | - $iterator = $this->getFileSearchIterator($rootDir . "/app"); |
|
117 | + $iterator = $this->getFileSearchIterator($rootDir."/app"); |
|
118 | 118 | $includeList = []; |
119 | 119 | foreach ($iterator as $filepath => $fileObject) { |
120 | - if (strpos($filepath, $className . ".php") !== false) { |
|
120 | + if (strpos($filepath, $className.".php") !== false) { |
|
121 | 121 | include_once $filepath; |
122 | 122 | $includeList[] = $filepath; |
123 | - $this->logger->debug($filepath . " load success. (search from " . $rootDir . "/app/)"); |
|
123 | + $this->logger->debug($filepath." load success. (search from ".$rootDir."/app/)"); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | if (!empty($includeList)) { |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | $classNameWithoutNamespace = $matches[1]; |
134 | 134 | // この処理が走るケースはapp配下のクラスがディレクトリ構成と名前空間が一致していない |
135 | 135 | // 場合以外ない(テスト用クラス除く)ので、app配下の検索を優先する |
136 | - $iterator = $this->getFileSearchIterator($rootDir . "/app"); |
|
136 | + $iterator = $this->getFileSearchIterator($rootDir."/app"); |
|
137 | 137 | foreach ($iterator as $filepath => $fileObject) { |
138 | - if (strpos($filepath, $classNameWithoutNamespace . ".php") !== false) { |
|
138 | + if (strpos($filepath, $classNameWithoutNamespace.".php") !== false) { |
|
139 | 139 | include_once $filepath; |
140 | 140 | $includeList[] = $filepath; |
141 | - $this->logger->debug($filepath . " load success. (full search)"); |
|
141 | + $this->logger->debug($filepath." load success. (full search)"); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | if (!empty($includeList)) { |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | // プロジェクトルート配下すべてのディレクトリを検索する |
149 | - $iterator = $this->getFileSearchIterator($rootDir . "/core"); |
|
149 | + $iterator = $this->getFileSearchIterator($rootDir."/core"); |
|
150 | 150 | foreach ($iterator as $filepath => $fileObject) { |
151 | - if (strpos($filepath, $classNameWithoutNamespace . ".php") !== false) { |
|
151 | + if (strpos($filepath, $classNameWithoutNamespace.".php") !== false) { |
|
152 | 152 | include_once $filepath; |
153 | 153 | $includeList[] = $filepath; |
154 | - $this->logger->debug($filepath . " load success. (full search, use in test)"); |
|
154 | + $this->logger->debug($filepath." load success. (full search, use in test)"); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | if (!empty($includeList)) { |
@@ -166,6 +166,7 @@ discard block |
||
166 | 166 | * @param array リクエストヘッダ |
167 | 167 | * @param array<string> リクエストパラメータ |
168 | 168 | * @param string 実行するRESTメソッド |
169 | + * @param string $method |
|
169 | 170 | * @return string レスポンス |
170 | 171 | */ |
171 | 172 | private function http($url, $headers, $params, $method) |
@@ -250,6 +251,8 @@ discard block |
||
250 | 251 | * @param array<string> オプション配列 |
251 | 252 | * @param string 配列キー |
252 | 253 | * @param string or Integer デフォルト値 |
254 | + * @param string $key |
|
255 | + * @param integer $default_value |
|
253 | 256 | * @return mixed オプション配列の値 |
254 | 257 | */ |
255 | 258 | private function getOptionParameter($options, $key, $default_value = null) |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $host = $this->proxy_host; |
147 | 147 | $host = preg_replace('/^http(:\/\/.+)$/', 'tcp${1}', $host); |
148 | 148 | $host = preg_replace('/^https(:\/\/.+)$/', 'ssl${1}', $host); |
149 | - $request["proxy"] = $host . ":" . strval($this->proxy_port); |
|
149 | + $request["proxy"] = $host.":".strval($this->proxy_port); |
|
150 | 150 | $request["request_fulluri"] = true; |
151 | 151 | } |
152 | 152 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function basicAuth(&$headers) |
158 | 158 | { |
159 | - $headers[] = "Authorization: Basic " . |
|
160 | - base64_encode($this->basic_auth_id . ":" . $this->basic_auth_password); |
|
159 | + $headers[] = "Authorization: Basic ". |
|
160 | + base64_encode($this->basic_auth_id.":".$this->basic_auth_password); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | // GETの場合はstream_context_createでクエリを渡しても有効にならないため |
176 | 176 | // URLにクエリストリングを付けることで対処 |
177 | 177 | if ($method === "GET") { |
178 | - $url .= "?" . $params; |
|
178 | + $url .= "?".$params; |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | if (empty($headers) && ($method === "POST" || $method === "PUT")) { |
182 | 182 | $contentLength = !is_string($params) ? 0 : strlen($params); |
183 | 183 | $headers = [ |
184 | 184 | "Content-Type: application/x-www-form-urlencoded", |
185 | - "Content-Length: " . $contentLength |
|
185 | + "Content-Length: ".$contentLength |
|
186 | 186 | ]; |
187 | 187 | } |
188 | 188 | $request = [ |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | $hasHeader = @get_headers($url); |
209 | 209 | if ($hasHeader === false) { // ヘッダを持たない場合、存在しないURL |
210 | 210 | $this->status_code = 404; |
211 | - $this->logger->error("URL not found: " . $url); |
|
211 | + $this->logger->error("URL not found: ".$url); |
|
212 | 212 | } else { // ヘッダを持つ場合はタイムアウトが発生 |
213 | 213 | $this->status_code = 408; |
214 | - $this->logger->error("Request timeout: " . $url); |
|
214 | + $this->logger->error("Request timeout: ".$url); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | return null; |
@@ -108,6 +108,7 @@ |
||
108 | 108 | * CoreHelper#asyncで使用するコードを返却する |
109 | 109 | * @param string URL |
110 | 110 | * @param string CSSクラス名 |
111 | + * @param string $url |
|
111 | 112 | * @return string コード |
112 | 113 | */ |
113 | 114 | public function asyncHelperCode($url, $id) |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | $isProjectRoot = false; |
24 | 24 | |
25 | 25 | while (!$isProjectRoot) { |
26 | - if (file_exists($targetPath . DIRECTORY_SEPARATOR . $this->getProjectFileName())) { |
|
26 | + if (file_exists($targetPath.DIRECTORY_SEPARATOR.$this->getProjectFileName())) { |
|
27 | 27 | $isProjectRoot = true; |
28 | 28 | } else { |
29 | 29 | if (preg_match("/(.*)\//", $targetPath, $matches)) { |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if (preg_match("/^namespace\s(.*);$/", $line, $matches)) { |
57 | 57 | $namespace = $matches[1]; |
58 | 58 | if (substr($namespace, 0) !== '\\') { |
59 | - $namespace = '\\' . $namespace; |
|
59 | + $namespace = '\\'.$namespace; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | return $namespace; |
@@ -195,6 +195,7 @@ discard block |
||
195 | 195 | * テンプレートを描画する |
196 | 196 | * @param string テンプレートファイル |
197 | 197 | * @param mixed 展開するパラメータ |
198 | + * @param string $template |
|
198 | 199 | */ |
199 | 200 | private function outputHTML($template, $params) |
200 | 201 | { |
@@ -207,6 +208,7 @@ discard block |
||
207 | 208 | * テンプレート記法を変換する |
208 | 209 | * @param string 変換前出力内容 |
209 | 210 | * @param string mimeType |
211 | + * @param string $content |
|
210 | 212 | * @return bool 変換されたらtrue |
211 | 213 | */ |
212 | 214 | private function replaceTemplateMark(&$content, $mimeType) |
@@ -245,6 +247,7 @@ discard block |
||
245 | 247 | /** |
246 | 248 | * すべてのformタグにCSRF対策トークンを追加する |
247 | 249 | * @param string HTML文字列の参照 |
250 | + * @param string $csrfToken |
|
248 | 251 | */ |
249 | 252 | private function addToken(&$content, $csrfToken) |
250 | 253 | { |
@@ -284,10 +284,10 @@ |
||
284 | 284 | } |
285 | 285 | // 実体参照化をもとに戻す。 |
286 | 286 | $map = array('>' => '>', |
287 | - '<' => '<', |
|
288 | - '%20' => ' ', |
|
289 | - '%24' => '$', |
|
290 | - '%5C' => '\\'); |
|
287 | + '<' => '<', |
|
288 | + '%20' => ' ', |
|
289 | + '%24' => '$', |
|
290 | + '%5C' => '\\'); |
|
291 | 291 | |
292 | 292 | // HTMLタグを補完する |
293 | 293 | $content = <<< HTML |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function __construct(Container $container) |
59 | 59 | { |
60 | 60 | $this->container = $container; |
61 | - $this->session = $container->session; |
|
61 | + $this->session = $container->session; |
|
62 | 62 | $this->timestamp = 0; |
63 | 63 | $this->logger = $container->logger; |
64 | 64 | } |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | $params = ["model" => $params["model"], "helper" => $params["helper"]]; |
73 | 73 | $dirname = $this->camel2snake($this->container->router->pageName); |
74 | 74 | |
75 | - $templateFile = new File($this->container->applicationInfo->applicationRoot . "/app/views/" . $dirname . "/" . $this->container->filename); |
|
76 | - $sharedFile = new File($this->container->applicationInfo->applicationRoot . "/app/views/" . $this->container->applicationInfo->sharedDir . "/" . $this->container->filename); |
|
75 | + $templateFile = new File($this->container->applicationInfo->applicationRoot."/app/views/".$dirname."/".$this->container->filename); |
|
76 | + $sharedFile = new File($this->container->applicationInfo->applicationRoot."/app/views/".$this->container->applicationInfo->sharedDir."/".$this->container->filename); |
|
77 | 77 | |
78 | 78 | $file = $templateFile->exists() ? $templateFile : ($sharedFile->exists() ? $sharedFile : null); |
79 | 79 | if ($file === null) { |
80 | - $errorMessage = "Invalid template file path: " . $templateFile->getFilePath() . " or " . $sharedFile->getFilePath(); |
|
80 | + $errorMessage = "Invalid template file path: ".$templateFile->getFilePath()." or ".$sharedFile->getFilePath(); |
|
81 | 81 | throw new ResourceNotFoundException($errorMessage); |
82 | 82 | } |
83 | 83 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | $this->replaceTemplateMark($content, $mimeType); |
94 | 94 | |
95 | 95 | // テンプレートファイルをコンパイルし一時ファイルを作成 |
96 | - $tmpFile = new File($this->getTemporaryDirectory() . "/" . $this->getRandomstring(30)); |
|
96 | + $tmpFile = new File($this->getTemporaryDirectory()."/".$this->getRandomstring(30)); |
|
97 | 97 | $writer = new FileWriter($tmpFile); |
98 | 98 | $writer->write($content); |
99 | 99 | $writer->close(); |
100 | - $this->logger->debug("Write temporary template file: " . $tmpFile->getFilePath()); |
|
101 | - $this->logger->debug("Compiled template file size: " . $tmpFile->length()); |
|
100 | + $this->logger->debug("Write temporary template file: ".$tmpFile->getFilePath()); |
|
101 | + $this->logger->debug("Compiled template file size: ".$tmpFile->length()); |
|
102 | 102 | |
103 | 103 | $params["__params__"] = $params; |
104 | 104 | $params["__mimeType__"] = $mimeType; |
@@ -128,18 +128,18 @@ discard block |
||
128 | 128 | // CSRFチェックが実行される前に非同期でリクエストがあった場合を考慮して |
129 | 129 | // CSRFトークンは削除しない |
130 | 130 | if (preg_match('/<form.*?>.*?<\/form>/is', $content)) { |
131 | - $csrfToken = sha1($this->session->id() . microtime()); |
|
131 | + $csrfToken = sha1($this->session->id().microtime()); |
|
132 | 132 | $this->session->set($this->getCsrfTokenKey(), $csrfToken); |
133 | 133 | $this->addToken($content, $csrfToken); |
134 | 134 | } |
135 | 135 | |
136 | 136 | // テンプレートファイルをコンパイルし一時ファイルを作成 |
137 | - $tmpFile = new File($this->getTemporaryDirectory() . "/" . $this->getRandomstring(30)); |
|
137 | + $tmpFile = new File($this->getTemporaryDirectory()."/".$this->getRandomstring(30)); |
|
138 | 138 | $writer = new FileWriter($tmpFile); |
139 | 139 | $writer->write($content); |
140 | 140 | $writer->close(); |
141 | - $this->logger->debug("Write temporary template file: " . $tmpFile->getFilePath()); |
|
142 | - $this->logger->debug("Compiled template file size: " . $tmpFile->length()); |
|
141 | + $this->logger->debug("Write temporary template file: ".$tmpFile->getFilePath()); |
|
142 | + $this->logger->debug("Compiled template file size: ".$tmpFile->length()); |
|
143 | 143 | |
144 | 144 | $params["__params__"] = $params; |
145 | 145 | $params["__mimeType__"] = $mimeType; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function cache($filename, $data, $expire) |
181 | 181 | { |
182 | - $cacheDir = $this->container->applicationInfo->applicationRoot . "/app/views/" . $this->container->applicationInfo->cacheDir; |
|
182 | + $cacheDir = $this->container->applicationInfo->applicationRoot."/app/views/".$this->container->applicationInfo->cacheDir; |
|
183 | 183 | $factory = new CacheDriverFactory(); |
184 | 184 | $config = new Container(false); |
185 | 185 | $config->cacheDir = $cacheDir; |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | $cache = $factory->create("WebStream\Cache\Driver\TemporaryFile", $config); |
188 | 188 | $cache->inject('logger', $this->logger); |
189 | 189 | |
190 | - $file = new File($cacheDir . "/" . $filename . ".cache"); |
|
190 | + $file = new File($cacheDir."/".$filename.".cache"); |
|
191 | 191 | if (!$file->exists() || $this->timestamp > $file->lastModified()) { |
192 | 192 | if ($cache->add($filename, $data, $expire)) { |
193 | - $this->logger->debug("Write template cache file: " . $file->getFilePath()); |
|
193 | + $this->logger->debug("Write template cache file: ".$file->getFilePath()); |
|
194 | 194 | } else { |
195 | - throw new IOException("File write failure: " . $file->getFilePath()); |
|
195 | + throw new IOException("File write failure: ".$file->getFilePath()); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
@@ -219,29 +219,29 @@ discard block |
||
219 | 219 | { |
220 | 220 | $originContentHash = md5($content); |
221 | 221 | |
222 | - $content = preg_replace_callback('/(%.{\$' . $this->getHelperVariableName() . '\->async\(.+?\)})/', function ($matches) { |
|
222 | + $content = preg_replace_callback('/(%.{\$'.$this->getHelperVariableName().'\->async\(.+?\)})/', function($matches) { |
|
223 | 223 | $asyncId = $this->getAsyncDomId(); |
224 | - $context = preg_replace_callback('/\$' . $this->getHelperVariableName() . '->async\((.+?)\)/', function ($matches2) use ($asyncId) { |
|
225 | - return '$' . $this->getHelperVariableName() . '->async(' . $matches2[1] . ',\'' . $asyncId . '\')'; |
|
224 | + $context = preg_replace_callback('/\$'.$this->getHelperVariableName().'->async\((.+?)\)/', function($matches2) use ($asyncId) { |
|
225 | + return '$'.$this->getHelperVariableName().'->async('.$matches2[1].',\''.$asyncId.'\')'; |
|
226 | 226 | }, $matches[1]); |
227 | 227 | |
228 | 228 | return "<div id='$asyncId'>$context</div>"; |
229 | 229 | }, $content); |
230 | 230 | |
231 | - $content = preg_replace('/' . self::TEMPLATE_MARK_PHP . '\{(.*?)\}/', '<?php echo $1; ?>', $content); |
|
232 | - $content = preg_replace_callback('/' . self::TEMPLATE_MARK_TEMPLATE . '\{(.*?)\}/', function ($matches) { |
|
231 | + $content = preg_replace('/'.self::TEMPLATE_MARK_PHP.'\{(.*?)\}/', '<?php echo $1; ?>', $content); |
|
232 | + $content = preg_replace_callback('/'.self::TEMPLATE_MARK_TEMPLATE.'\{(.*?)\}/', function($matches) { |
|
233 | 233 | if (substr($matches[1], 0, 1) === '$') { |
234 | - return self::TEMPLATE_MARK_TEMPLATE . '{<?php echo ' . $matches[1] . ';?>}'; |
|
234 | + return self::TEMPLATE_MARK_TEMPLATE.'{<?php echo '.$matches[1].';?>}'; |
|
235 | 235 | } else { |
236 | - return '<?php $this->draw(\'' . $matches[1] . '\', $__params__, $__mimeType__); ?>'; |
|
236 | + return '<?php $this->draw(\''.$matches[1].'\', $__params__, $__mimeType__); ?>'; |
|
237 | 237 | } |
238 | 238 | }, $content); |
239 | 239 | |
240 | 240 | if ($mimeType === "xml") { |
241 | - $content = preg_replace('/' . self::TEMPLATE_MARK_XML . '\{(.*?)\}/', '<?php echo safetyOutXML($1); ?>', $content); |
|
241 | + $content = preg_replace('/'.self::TEMPLATE_MARK_XML.'\{(.*?)\}/', '<?php echo safetyOutXML($1); ?>', $content); |
|
242 | 242 | } elseif ($mimeType === "html") { |
243 | - $content = preg_replace('/' . self::TEMPLATE_MARK_HTML . '\{(.*?)\}/', '<?php echo safetyOut($1); ?>', $content); |
|
244 | - $content = preg_replace('/' . self::TEMPLATE_MARK_JAVASCRIPT . '\{(.*?)\}/', '<?php echo safetyOutJavaScript($1); ?>', $content); |
|
243 | + $content = preg_replace('/'.self::TEMPLATE_MARK_HTML.'\{(.*?)\}/', '<?php echo safetyOut($1); ?>', $content); |
|
244 | + $content = preg_replace('/'.self::TEMPLATE_MARK_JAVASCRIPT.'\{(.*?)\}/', '<?php echo safetyOutJavaScript($1); ?>', $content); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | $replacedContentHash = md5($content); |