@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->setStatusCode(Template::STATUS_OK); |
128 | 128 | break; |
129 | 129 | default: |
130 | - $this->setStatusCode('HTTP/1.0 ' . ($status ?: 200)); |
|
130 | + $this->setStatusCode('HTTP/1.0 '.($status ?: 200)); |
|
131 | 131 | break; |
132 | 132 | } |
133 | 133 | return $this; |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | */ |
141 | 141 | private function setResponseHeaders($contentType = 'text/html', array $cookies = array()): void |
142 | 142 | { |
143 | - ResponseHelper::setHeader('X-Powered-By: ' . Config::getParam('poweredBy', 'PSFS')); |
|
143 | + ResponseHelper::setHeader('X-Powered-By: '.Config::getParam('poweredBy', 'PSFS')); |
|
144 | 144 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
145 | 145 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
146 | 146 | ResponseHelper::setCookieHeaders($cookies); |
147 | - ResponseHelper::setHeader('Content-type: ' . $contentType); |
|
147 | + ResponseHelper::setHeader('Content-type: '.$contentType); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | |
@@ -162,16 +162,16 @@ discard block |
||
162 | 162 | Logger::log('Start output response'); |
163 | 163 | ob_start(); |
164 | 164 | $this->setResponseHeaders($contentType, $cookies); |
165 | - header('Content-length: ' . strlen($output)); |
|
166 | - header('CRC: ' . crc32($output)); |
|
165 | + header('Content-length: '.strlen($output)); |
|
166 | + header('CRC: '.crc32($output)); |
|
167 | 167 | |
168 | 168 | $needCache = Cache::needCache(); |
169 | 169 | $cache = Cache::getInstance(); |
170 | 170 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
171 | 171 | if (null !== $cacheDataName && false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
172 | 172 | Logger::log('Saving output response into cache'); |
173 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
174 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', headers_list(), Cache::JSON); |
|
173 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
174 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', headers_list(), Cache::JSON); |
|
175 | 175 | } elseif (Request::getInstance()->getMethod() !== 'GET') { |
176 | 176 | $cache->flushCache(); |
177 | 177 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | ob_end_clean(); |
182 | 182 | Logger::log('End output response'); |
183 | 183 | $this->closeRender(); |
184 | - } else { |
|
184 | + }else { |
|
185 | 185 | return $output; |
186 | 186 | } |
187 | 187 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | { |
194 | 194 | Logger::log('Close template render'); |
195 | 195 | EventHelper::handleEvents(EventHelper::EVENT_END_REQUEST); |
196 | - Logger::log('End request: ' . Request::requestUri(), LOG_INFO); |
|
196 | + Logger::log('End request: '.Request::requestUri(), LOG_INFO); |
|
197 | 197 | exit; |
198 | 198 | } |
199 | 199 | |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | ///////////////////////////////////////////////////////////// |
232 | 232 | // Date in the past sets the value to already have been expired. |
233 | 233 | header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); |
234 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
234 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
235 | 235 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
236 | 236 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
237 | 237 | header('Pragma: no-cache'); |
238 | 238 | header('Expires: 0'); |
239 | 239 | header('Content-Transfer-Encoding: binary'); |
240 | - header('Content-type: ' . $content); |
|
241 | - header('Content-length: ' . strlen($data)); |
|
242 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
240 | + header('Content-type: '.$content); |
|
241 | + header('Content-length: '.strlen($data)); |
|
242 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
243 | 243 | header('Access-Control-Expose-Headers: Filename'); |
244 | - header('Filename: ' . $filename); |
|
244 | + header('Filename: '.$filename); |
|
245 | 245 | echo $data; |
246 | 246 | ob_flush(); |
247 | 247 | ob_end_clean(); |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | |
14 | 14 | public static function handleEvents(string $eventName, mixed $context = null): void |
15 | 15 | { |
16 | - if(array_key_exists($eventName, self::$events)) { |
|
17 | - foreach(self::$events[$eventName] as $eventClass) { |
|
16 | + if (array_key_exists($eventName, self::$events)) { |
|
17 | + foreach (self::$events[$eventName] as $eventClass) { |
|
18 | 18 | $return = (new $eventClass)($context); |
19 | 19 | Logger::log("$eventClass event handled with return $return"); |
20 | 20 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public static function addEvent(string $eventName, string $eventClass): void |
25 | 25 | { |
26 | - if(!array_key_exists($eventName, self::$events)) { |
|
26 | + if (!array_key_exists($eventName, self::$events)) { |
|
27 | 27 | self::$events[$eventName] = []; |
28 | 28 | } |
29 | 29 | self::$events[$eventName][] = $eventClass; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public static function setHeader(string $header): void { |
23 | 23 | list($key, $value) = explode(':', $header); |
24 | 24 | if (!in_array($key, self::$headers_sent)) { |
25 | - if(!self::isTest()) { |
|
25 | + if (!self::isTest()) { |
|
26 | 26 | header($header); |
27 | 27 | } |
28 | 28 | self::$headers_sent[$key] = $value; |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | Logger::log('Adding debug headers to render response'); |
95 | 95 | $vars["__DEBUG__"]["includes"] = get_included_files(); |
96 | 96 | $vars["__DEBUG__"]["trace"] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
97 | - self::setHeader('X-PSFS-DEBUG-TS: ' . Dispatcher::getInstance()->getTs() . ' s'); |
|
98 | - self::setHeader('X-PSFS-DEBUG-MEM: ' . Dispatcher::getInstance()->getMem('MBytes') . ' MBytes'); |
|
99 | - self::setHeader('X-PSFS-DEBUG-FILES: ' . count(get_included_files()) . ' files opened'); |
|
97 | + self::setHeader('X-PSFS-DEBUG-TS: '.Dispatcher::getInstance()->getTs().' s'); |
|
98 | + self::setHeader('X-PSFS-DEBUG-MEM: '.Dispatcher::getInstance()->getMem('MBytes').' MBytes'); |
|
99 | + self::setHeader('X-PSFS-DEBUG-FILES: '.count(get_included_files()).' files opened'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | return $vars; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return int|string |
109 | 109 | * @throws GeneratorException |
110 | 110 | */ |
111 | - public static function httpNotFound(Exception $exception = NULL, bool $isJson = false): int|string |
|
111 | + public static function httpNotFound(Exception $exception = NULL, bool $isJson = false): int | string |
|
112 | 112 | { |
113 | 113 | if (self::isTest()) { |
114 | 114 | return 404; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $notFoundRoute = Config::getParam('route.404'); |
128 | 128 | if (null !== $notFoundRoute) { |
129 | 129 | Request::getInstance()->redirect(Router::getInstance()->getRoute($notFoundRoute, true)); |
130 | - } else { |
|
130 | + }else { |
|
131 | 131 | return $template->render('error.html.twig', array( |
132 | 132 | 'exception' => $exception, |
133 | 133 | 'trace' => $exception->getTraceAsString(), |
@@ -12,10 +12,10 @@ |
||
12 | 12 | { |
13 | 13 | $uri = Request::requestUri(); |
14 | 14 | Security::getInstance()->setSessionKey('lastRequest', array( |
15 | - 'url' => Request::getInstance()->getRootUrl() . $uri, |
|
15 | + 'url' => Request::getInstance()->getRootUrl().$uri, |
|
16 | 16 | 'ts' => microtime(true), |
17 | 17 | 'eta' => microtime(true) - PSFS_START_TS, |
18 | - 'mem' => memory_get_usage() / 1024 / 1024, |
|
18 | + 'mem' => memory_get_usage()/1024/1024, |
|
19 | 19 | )); |
20 | 20 | Security::getInstance()->updateSession(); |
21 | 21 | return EventInterface::EVENT_SUCCESS; |