@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | /** |
36 | 36 | * コンストラクタ |
37 | - * @param Request リクエストオブジェクト |
|
37 | + * @param Request Container |
|
38 | 38 | */ |
39 | 39 | public function __construct(array $rules, Container $request) |
40 | 40 | { |
@@ -190,6 +190,7 @@ discard block |
||
190 | 190 | /** |
191 | 191 | * コントローラを設定する |
192 | 192 | * @param string コントローラ文字列 |
193 | + * @param string $controller |
|
193 | 194 | */ |
194 | 195 | private function setController($controller) |
195 | 196 | { |
@@ -202,6 +203,7 @@ discard block |
||
202 | 203 | /** |
203 | 204 | * アクションを設定する |
204 | 205 | * @param string アクション文字列 |
206 | + * @param string $action |
|
205 | 207 | */ |
206 | 208 | private function setAction($action) |
207 | 209 | { |
@@ -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 |
@@ -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) |
@@ -26,7 +26,7 @@ |
||
26 | 26 | /** |
27 | 27 | * コンテナを作成する |
28 | 28 | * @param boolean テスト環境フラグ |
29 | - * @return object コンテナ |
|
29 | + * @return Container コンテナ |
|
30 | 30 | */ |
31 | 31 | public function getContainer() |
32 | 32 | { |
@@ -63,7 +63,7 @@ |
||
63 | 63 | $config = \Spyc::YAMLLoad($container->applicationInfo->applicationRoot . $container->applicationInfo->routeConfigPath); |
64 | 64 | $router = new Router($config, $container->request); |
65 | 65 | $router->inject('logger', $container->logger) |
66 | - ->inject('applicationInfo', $container->applicationInfo); |
|
66 | + ->inject('applicationInfo', $container->applicationInfo); |
|
67 | 67 | $router->resolve(); |
68 | 68 | |
69 | 69 | return $router->getRoutingResult(); |
@@ -33,34 +33,34 @@ discard block |
||
33 | 33 | $container = new Container(); |
34 | 34 | |
35 | 35 | // LoggerAdapter |
36 | - $container->logger = function () { |
|
36 | + $container->logger = function() { |
|
37 | 37 | return new LoggerAdapter(Logger::getInstance()); |
38 | 38 | }; |
39 | 39 | // Request |
40 | - $container->request = function () use (&$container) { |
|
40 | + $container->request = function() use (&$container) { |
|
41 | 41 | $request = new Request(); |
42 | 42 | $request->inject('logger', $container->logger); |
43 | 43 | |
44 | 44 | return $request->getContainer(); |
45 | 45 | }; |
46 | 46 | // Response |
47 | - $container->response = function () use (&$container) { |
|
47 | + $container->response = function() use (&$container) { |
|
48 | 48 | $response = new Response(); |
49 | 49 | $response->inject('logger', $container->logger); |
50 | 50 | |
51 | 51 | return $response; |
52 | 52 | }; |
53 | 53 | // Session |
54 | - $container->session = function () use (&$container) { |
|
54 | + $container->session = function() use (&$container) { |
|
55 | 55 | $session = new Session(); |
56 | 56 | $session->inject('logger', $container->logger); |
57 | 57 | |
58 | 58 | return $session; |
59 | 59 | }; |
60 | 60 | // Router |
61 | - $container->router = function () use (&$container) { |
|
61 | + $container->router = function() use (&$container) { |
|
62 | 62 | // Router |
63 | - $config = \Spyc::YAMLLoad($container->applicationInfo->applicationRoot . $container->applicationInfo->routeConfigPath); |
|
63 | + $config = \Spyc::YAMLLoad($container->applicationInfo->applicationRoot.$container->applicationInfo->routeConfigPath); |
|
64 | 64 | $router = new Router($config, $container->request); |
65 | 65 | $router->inject('logger', $container->logger) |
66 | 66 | ->inject('applicationInfo', $container->applicationInfo); |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | return $router->getRoutingResult(); |
70 | 70 | }; |
71 | 71 | // CoreDelegator |
72 | - $container->coreDelegator = function () use (&$container) { |
|
72 | + $container->coreDelegator = function() use (&$container) { |
|
73 | 73 | return new CoreDelegator($container); |
74 | 74 | }; |
75 | 75 | // AnnotationDelegator |
76 | - $container->annotationDelegator = function () use (&$container) { |
|
76 | + $container->annotationDelegator = function() use (&$container) { |
|
77 | 77 | return new AnnotationDelegator($container); |
78 | 78 | }; |
79 | 79 | // twig |
80 | - $container->twig = function () { |
|
80 | + $container->twig = function() { |
|
81 | 81 | Twig_Autoloader::register(); |
82 | 82 | }; |
83 | 83 | // Application Info |
@@ -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 | { |
@@ -22,6 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * コンストラクタ |
24 | 24 | * @param string キャッシュの保存ディレクトリパス |
25 | + * @param string $savePath |
|
25 | 26 | */ |
26 | 27 | public function __construct($savePath = null) |
27 | 28 | { |
@@ -34,6 +35,7 @@ discard block |
||
34 | 35 | /** |
35 | 36 | * キャッシュを取得する |
36 | 37 | * @param string キャッシュID |
38 | + * @param string $id |
|
37 | 39 | * @return string キャッシュデータ |
38 | 40 | */ |
39 | 41 | public function get($id) |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | { |
41 | 41 | $cache = $this->cache($id); |
42 | 42 | if ($cache !== null) { |
43 | - $path = $this->savePath . "/" . $id . '.cache'; |
|
43 | + $path = $this->savePath."/".$id.'.cache'; |
|
44 | 44 | $cachePath = realpath($path); |
45 | 45 | $this->logger->info("Get cache: ${cachePath}"); |
46 | 46 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | private function cache($id) |
76 | 76 | { |
77 | - $path = $this->savePath . "/" . $id . '.cache'; |
|
77 | + $path = $this->savePath."/".$id.'.cache'; |
|
78 | 78 | $cachePath = realpath($path); |
79 | 79 | if ($cachePath !== false && is_file($cachePath)) { |
80 | 80 | $data = $this->decode(file_get_contents($cachePath)); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | // キャッシュディレクトリが存在するか |
116 | 116 | if (is_dir($this->savePath)) { |
117 | - $cachePath = realpath($this->savePath) . '/' . basename($id) . '.cache'; |
|
117 | + $cachePath = realpath($this->savePath).'/'.basename($id).'.cache'; |
|
118 | 118 | // キャッシュファイルがない場合またはキャッシュファイルが存在するが、 |
119 | 119 | // 上書きする場合はキャッシュを新規作成する |
120 | 120 | if (!is_file($cachePath) || (is_file($cachePath) && $overwrite === true)) { |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | return true; |
128 | 128 | } else { // ファイル書き込みに失敗した場合 |
129 | - throw new IOException("Can't create cache: " . $cachePath); |
|
129 | + throw new IOException("Can't create cache: ".$cachePath); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } else { |
133 | - $this->logger->error("Invalid cache directory: " . $this->savePath); |
|
133 | + $this->logger->error("Invalid cache directory: ".$this->savePath); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | return false; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public function delete($id) |
144 | 144 | { |
145 | - $cachePath = realpath($this->savePath . "/" . $id . '.cache'); |
|
145 | + $cachePath = realpath($this->savePath."/".$id.'.cache'); |
|
146 | 146 | if ($cachePath) { |
147 | 147 | $this->logger->debug("Cache delete success: ${cachePath}"); |
148 | 148 |
@@ -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)) { |