Completed
Push — feature/0.7.0 ( 96c6b1...1ee46b )
by Ryuichi
05:07
created
WebStream/Template/Basic.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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->size());
100
+        $this->logger->debug("Write temporary template file: ".$tmpFile->getFilePath());
101
+        $this->logger->debug("Compiled template file size: ".$tmpFile->size());
102 102
 
103 103
         $params["__params__"] = $params;
104 104
         $params["__mimeType__"] = $mimeType;
@@ -128,18 +128,18 @@  discard block
 block discarded – undo
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->size());
141
+        $this->logger->debug("Write temporary template file: ".$tmpFile->getFilePath());
142
+        $this->logger->debug("Compiled template file size: ".$tmpFile->size());
143 143
 
144 144
         $params["__params__"] = $params;
145 145
         $params["__mimeType__"] = $mimeType;
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
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
         $cache = new Cache($cacheDir);
184 184
         $cache->inject('logger', $this->logger);
185
-        $file = new File($cacheDir . "/" . $filename . ".cache");
185
+        $file = new File($cacheDir."/".$filename.".cache");
186 186
         if (!$file->exists() || $this->timestamp > $file->lastModified()) {
187 187
             if ($cache->save($filename, $data, $expire)) {
188
-                $this->logger->debug("Write template cache file: " . $file->getFilePath());
188
+                $this->logger->debug("Write template cache file: ".$file->getFilePath());
189 189
             } else {
190
-                throw new IOException("File write failure: " . $file->getFilePath());
190
+                throw new IOException("File write failure: ".$file->getFilePath());
191 191
             }
192 192
         }
193 193
     }
@@ -214,29 +214,29 @@  discard block
 block discarded – undo
214 214
     {
215 215
         $originContentHash = md5($content);
216 216
 
217
-        $content = preg_replace_callback('/(%.{\$' . $this->getHelperVariableName() . '\->async\(.+?\)})/', function ($matches) {
217
+        $content = preg_replace_callback('/(%.{\$'.$this->getHelperVariableName().'\->async\(.+?\)})/', function($matches) {
218 218
             $asyncId = $this->getAsyncDomId();
219
-            $context = preg_replace_callback('/\$' . $this->getHelperVariableName() . '->async\((.+?)\)/', function ($matches2) use ($asyncId) {
220
-                return '$' . $this->getHelperVariableName() . '->async(' . $matches2[1] . ',\'' . $asyncId . '\')';
219
+            $context = preg_replace_callback('/\$'.$this->getHelperVariableName().'->async\((.+?)\)/', function($matches2) use ($asyncId) {
220
+                return '$'.$this->getHelperVariableName().'->async('.$matches2[1].',\''.$asyncId.'\')';
221 221
             }, $matches[1]);
222 222
 
223 223
             return "<div id='$asyncId'>$context</div>";
224 224
         }, $content);
225 225
 
226
-        $content = preg_replace('/' . self::TEMPLATE_MARK_PHP . '\{(.*?)\}/', '<?php echo $1; ?>', $content);
227
-        $content = preg_replace_callback('/' . self::TEMPLATE_MARK_TEMPLATE . '\{(.*?)\}/', function ($matches) {
226
+        $content = preg_replace('/'.self::TEMPLATE_MARK_PHP.'\{(.*?)\}/', '<?php echo $1; ?>', $content);
227
+        $content = preg_replace_callback('/'.self::TEMPLATE_MARK_TEMPLATE.'\{(.*?)\}/', function($matches) {
228 228
             if (substr($matches[1], 0, 1) === '$') {
229
-                return self::TEMPLATE_MARK_TEMPLATE . '{<?php echo ' . $matches[1] . ';?>}';
229
+                return self::TEMPLATE_MARK_TEMPLATE.'{<?php echo '.$matches[1].';?>}';
230 230
             } else {
231
-                return '<?php $this->draw(\'' . $matches[1] . '\', $__params__, $__mimeType__); ?>';
231
+                return '<?php $this->draw(\''.$matches[1].'\', $__params__, $__mimeType__); ?>';
232 232
             }
233 233
         }, $content);
234 234
 
235 235
         if ($mimeType === "xml") {
236
-            $content = preg_replace('/' . self::TEMPLATE_MARK_XML . '\{(.*?)\}/', '<?php echo safetyOutXML($1); ?>', $content);
236
+            $content = preg_replace('/'.self::TEMPLATE_MARK_XML.'\{(.*?)\}/', '<?php echo safetyOutXML($1); ?>', $content);
237 237
         } elseif ($mimeType === "html") {
238
-            $content = preg_replace('/' . self::TEMPLATE_MARK_HTML . '\{(.*?)\}/', '<?php echo safetyOut($1); ?>', $content);
239
-            $content = preg_replace('/' . self::TEMPLATE_MARK_JAVASCRIPT . '\{(.*?)\}/', '<?php echo safetyOutJavaScript($1); ?>', $content);
238
+            $content = preg_replace('/'.self::TEMPLATE_MARK_HTML.'\{(.*?)\}/', '<?php echo safetyOut($1); ?>', $content);
239
+            $content = preg_replace('/'.self::TEMPLATE_MARK_JAVASCRIPT.'\{(.*?)\}/', '<?php echo safetyOutJavaScript($1); ?>', $content);
240 240
         }
241 241
 
242 242
         $replacedContentHash = md5($content);
Please login to merge, or discard this patch.
WebStream/Cache/Driver/TemporaryFile.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     public function __construct(Container $cacheContainer)
34 34
     {
35 35
         $this->cacheContainer = $cacheContainer;
36
-        $this->cachePrefix = $this->cacheContainer->cachePrefix . '.' . $this->cacheContainer->classPrefix . '.';
36
+        $this->cachePrefix = $this->cacheContainer->cachePrefix.'.'.$this->cacheContainer->classPrefix.'.';
37 37
     }
38 38
 
39 39
     /**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         if (!$this->isAvailableCacheLibrary()) {
45 45
             return false;
46 46
         }
47
-        $key = $this->cachePrefix . $key;
47
+        $key = $this->cachePrefix.$key;
48 48
         $writer = null;
49 49
         $isAppend = !$overwrite;
50 50
 
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
         ]);
56 56
 
57 57
         try {
58
-            $file = new File($this->cacheContainer->cacheDir . '/' . $key . '.cache');
58
+            $file = new File($this->cacheContainer->cacheDir.'/'.$key.'.cache');
59 59
             $writer = $this->cacheContainer->ioContainer->fileWriter->getWriter($file, $isAppend);
60 60
             $writer->write($value);
61
-            $this->logger->info("Execute cache save: " . $key);
61
+            $this->logger->info("Execute cache save: ".$key);
62 62
             return true;
63 63
         } catch (IOException $e) {
64 64
             $this->logger->warn($e->getMessage());
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
         if (!$this->isAvailableCacheLibrary()) {
83 83
             return null;
84 84
         }
85
-        $key = $this->cachePrefix . $key;
85
+        $key = $this->cachePrefix.$key;
86 86
         $value = null;
87 87
         $reader = null;
88
-        $file = new File($this->cacheContainer->cacheDir . '/' . $key . '.cache');
88
+        $file = new File($this->cacheContainer->cacheDir.'/'.$key.'.cache');
89 89
 
90 90
         if ($file->isReadable()) {
91 91
             try {
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
                 $data = $this->decode($reader->read());
94 94
                 if ($data['ttl'] > 0) {
95 95
                     if (time() > $data['time'] + $data['ttl']) {
96
-                        $this->logger->info("Expired cache: " . $key);
96
+                        $this->logger->info("Expired cache: ".$key);
97 97
                         $file->delete();
98 98
                     }
99 99
                 } else {
100 100
                     $value = $data['data'];
101
-                    $this->logger->info("Execute cache read: " . $key);
101
+                    $this->logger->info("Execute cache read: ".$key);
102 102
                 }
103 103
             } catch (IOException $e) {
104 104
                 $this->logger->warn($e->getMessage());
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
         if (!$this->isAvailableCacheLibrary()) {
125 125
             return false;
126 126
         }
127
-        $key = $this->cachePrefix . $key;
127
+        $key = $this->cachePrefix.$key;
128 128
         $result = false;
129 129
 
130
-        $file = new File($this->cacheContainer->cacheDir . '/' . $key . '.cache');
130
+        $file = new File($this->cacheContainer->cacheDir.'/'.$key.'.cache');
131 131
         if ($file->isWritable()) {
132 132
             $result = $file->delete();
133 133
             if ($result) {
134
-                $this->logger->info("Execute cache cleared: " . $key);
134
+                $this->logger->info("Execute cache cleared: ".$key);
135 135
             } else {
136
-                $this->logger->warn("Failed to clear cache: " . $key);
136
+                $this->logger->warn("Failed to clear cache: ".$key);
137 137
             }
138 138
         } else {
139
-            $this->logger->warn("Failed to clear cache: " . $key);
139
+            $this->logger->warn("Failed to clear cache: ".$key);
140 140
         }
141 141
 
142 142
         return $result;
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
                         $file = new File($filepath);
162 162
                         if ($file->isWritable()) {
163 163
                             if ($file->delete()) {
164
-                                $this->logger->info("Execute cache cleared: " . $this->cachePrefix . "*");
164
+                                $this->logger->info("Execute cache cleared: ".$this->cachePrefix."*");
165 165
                             } else {
166
-                                $this->logger->warn("Failed to clear cache: " . $this->cachePrefix . "*");
166
+                                $this->logger->warn("Failed to clear cache: ".$this->cachePrefix."*");
167 167
                                 $result = false;
168 168
                             }
169 169
                         } else {
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                 }
177 177
             }
178 178
         } else {
179
-            $this->logger->warn("Can't read directory:" . $dir->getFilePath());
179
+            $this->logger->warn("Can't read directory:".$dir->getFilePath());
180 180
             $result = false;
181 181
         }
182 182
 
Please login to merge, or discard this patch.
WebStream/Log/LoggerConfigurationManager.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         } else {
47 47
             $configMap = $this->parseConfig($config);
48 48
             if ($configMap === null) {
49
-                throw new LoggerException("Log config file does not exist: " . $config);
49
+                throw new LoggerException("Log config file does not exist: ".$config);
50 50
             }
51 51
         }
52 52
 
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
         $this->ioContainer = new Container();
55 55
 
56 56
         $rootDir = $this->getApplicationRoot();
57
-        $this->ioContainer->file = function () use ($rootDir, $configMap) {
57
+        $this->ioContainer->file = function() use ($rootDir, $configMap) {
58 58
             if (!array_key_exists("path", $configMap)) {
59 59
                 throw new LoggerException("Log path must be defined.");
60 60
             }
61
-            return new File($rootDir . "/" . $configMap["path"]);
61
+            return new File($rootDir."/".$configMap["path"]);
62 62
         };
63
-        $this->ioContainer->fileWriter = function () use ($rootDir, $configMap) {
64
-            return new SimpleFileWriter($rootDir . "/" . $configMap["path"]);
63
+        $this->ioContainer->fileWriter = function() use ($rootDir, $configMap) {
64
+            return new SimpleFileWriter($rootDir."/".$configMap["path"]);
65 65
         };
66 66
 
67 67
         $this->configMap = $configMap;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         }
119 119
 
120 120
         $this->logContainer->logPath = $file->getFilePath();
121
-        $this->logContainer->statusPath = preg_replace_callback('/(.*)\..+/', function ($matches) {
121
+        $this->logContainer->statusPath = preg_replace_callback('/(.*)\..+/', function($matches) {
122 122
             return "$matches[1].status";
123 123
         }, $this->logContainer->logPath);
124 124
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             $rotateSize = intval($this->configMap["rotate_size"]);
149 149
             // ローテートサイズが不正の場合(正の整数以外の値が設定された場合)
150 150
             if ($rotateSize <= 0) {
151
-                throw new LoggerException("Invalid log rotate size: " . $this->configMap["rotate_size"]);
151
+                throw new LoggerException("Invalid log rotate size: ".$this->configMap["rotate_size"]);
152 152
             }
153 153
             $this->logContainer->rotateSize = $rotateSize;
154 154
         }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             case 'year':
211 211
                 return $year_to_h;
212 212
             default:
213
-                throw new LoggerException("Invalid log rotate cycle: " . $cycle);
213
+                throw new LoggerException("Invalid log rotate cycle: ".$cycle);
214 214
         }
215 215
     }
216 216
 }
Please login to merge, or discard this patch.