@@ -162,6 +162,9 @@ |
||
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | + /** |
|
166 | + * @param string $sessionId |
|
167 | + */ |
|
165 | 168 | public function destroy($sessionId) |
166 | 169 | { |
167 | 170 | $success = false; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | ini_set('session.cookie_domain', $domain); |
33 | 33 | |
34 | 34 | if ($session_lifetime != '' && is_integer($session_lifetime)) { |
35 | - ini_set('session.gc_maxlifetime', (int) $session_lifetime); |
|
35 | + ini_set('session.gc_maxlifetime', (int)$session_lifetime); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | if ($gc_probability != '' && is_integer($gc_probability)) { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | if ($interface !== 'file') { |
80 | 80 | try { |
81 | - $database = new Database();//App::getService('database')->fetchConnection(); |
|
81 | + $database = new Database(); //App::getService('database')->fetchConnection(); |
|
82 | 82 | $this->dbh = $database->fetchConnection('default'); |
83 | 83 | |
84 | 84 | session_set_save_handler( |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function destroy($sessionId) |
166 | 166 | { |
167 | 167 | $success = false; |
168 | - $query = "DELETE FROM ". $this->tableName |
|
168 | + $query = "DELETE FROM " . $this->tableName |
|
169 | 169 | . " WHERE id = ?"; |
170 | 170 | |
171 | 171 | $success = $this->dbh->prepare($query) |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | public function gc() |
182 | 182 | { |
183 | 183 | |
184 | - $query = "DELETE FROM ". $this->tableName |
|
184 | + $query = "DELETE FROM " . $this->tableName |
|
185 | 185 | . " WHERE session_expire < ?"; |
186 | 186 | |
187 | 187 | return $this->dbh->prepare($query) |
@@ -335,10 +335,10 @@ discard block |
||
335 | 335 | { |
336 | 336 | if (trim($_SERVER['REQUEST_URI']) === '/') { |
337 | 337 | $url = $this->baseURL() |
338 | - . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); |
|
338 | + . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); |
|
339 | 339 | } else { |
340 | 340 | $url = $this->baseURL($this->uri) |
341 | - . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); |
|
341 | + . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if (!empty($params)) { |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | if (is_null($this->baseURL)) { |
363 | 363 | $self = $_SERVER['PHP_SELF']; |
364 | 364 | $server = $_SERVER['HTTP_HOST'] |
365 | - . rtrim(str_replace(strstr($self, 'index.php'), '', $self), '/'); |
|
365 | + . rtrim(str_replace(strstr($self, 'index.php'), '', $self), '/'); |
|
366 | 366 | |
367 | 367 | if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') |
368 | 368 | || !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) |
@@ -129,11 +129,18 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | |
132 | + /** |
|
133 | + * @param string $uri |
|
134 | + */ |
|
132 | 135 | private function isURIClean($uri, $uriChunks) |
133 | 136 | { |
134 | 137 | if (!preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $uri) |
135 | 138 | || array_filter( |
136 | 139 | $uriChunks, |
140 | + |
|
141 | + /** |
|
142 | + * @param string $uriChunk |
|
143 | + */ |
|
137 | 144 | function ($uriChunk) { |
138 | 145 | if (strpos($uriChunk, '__') !== false) { |
139 | 146 | return true; |
@@ -148,6 +155,10 @@ discard block |
||
148 | 155 | } |
149 | 156 | |
150 | 157 | //@TODO add Security class. |
158 | + |
|
159 | + /** |
|
160 | + * @param string $data |
|
161 | + */ |
|
151 | 162 | private function normalize($data) |
152 | 163 | { |
153 | 164 | if (is_numeric($data)) { |
@@ -225,6 +236,9 @@ discard block |
||
225 | 236 | return $normalizedURI; |
226 | 237 | } |
227 | 238 | |
239 | + /** |
|
240 | + * @param string $uri |
|
241 | + */ |
|
228 | 242 | private function discoverRoute($uri) |
229 | 243 | { |
230 | 244 | $routes = $this->configuration->routes; |
@@ -259,6 +273,7 @@ discard block |
||
259 | 273 | * Normalize the $_SERVER vars for formatting the URI. |
260 | 274 | * |
261 | 275 | * @access public |
276 | + * @param string $uri |
|
262 | 277 | * @return string formatted/u/r/l |
263 | 278 | */ |
264 | 279 | private function uri($uri) |
@@ -312,6 +327,9 @@ discard block |
||
312 | 327 | return array_merge($return, array_values($uriChunks)); |
313 | 328 | } |
314 | 329 | |
330 | + /** |
|
331 | + * @param string $url |
|
332 | + */ |
|
315 | 333 | private function addQueryString($url, $key, $value) |
316 | 334 | { |
317 | 335 | $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); |
@@ -323,6 +341,9 @@ discard block |
||
323 | 341 | } |
324 | 342 | } |
325 | 343 | |
344 | + /** |
|
345 | + * @param string $url |
|
346 | + */ |
|
326 | 347 | private function removeQueryString($url, $key) |
327 | 348 | { |
328 | 349 | $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); |
@@ -394,7 +415,7 @@ discard block |
||
394 | 415 | * Set optional status header, and redirect to provided URL |
395 | 416 | * |
396 | 417 | * @access public |
397 | - * @return bool |
|
418 | + * @return false|null |
|
398 | 419 | */ |
399 | 420 | public function redirect($url = '/', $status = null) |
400 | 421 | { |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | if (!preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $uri) |
135 | 135 | || array_filter( |
136 | 136 | $uriChunks, |
137 | - function ($uriChunk) { |
|
137 | + function($uriChunk) { |
|
138 | 138 | if (strpos($uriChunk, '__') !== false) { |
139 | 139 | return true; |
140 | 140 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | $normalizedURI = ltrim(preg_replace('/\?.*/', '', $normalizedURI), '/'); |
220 | 220 | |
221 | - if (! empty($this->configuration->routes)) { |
|
221 | + if (!empty($this->configuration->routes)) { |
|
222 | 222 | $normalizedURI = $this->discoverRoute($normalizedURI); |
223 | 223 | } |
224 | 224 | |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | |
238 | 238 | $uri = $reroute; |
239 | 239 | |
240 | - if (! empty($params)) { |
|
240 | + if (!empty($params)) { |
|
241 | 241 | $pat = '/(\$\d+)/'; |
242 | 242 | $uri = preg_replace_callback( |
243 | 243 | $pat, |
244 | - function () use (&$params) { |
|
244 | + function() use (&$params) { |
|
245 | 245 | $first = $params[0]; |
246 | 246 | array_shift($params); |
247 | 247 | return $first; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | // iterate through all the entries |
169 | 169 | foreach ($this->flashdata as $variable => $data) { |
170 | 170 | // increment counter representing server requests |
171 | - $this->flashdata[$variable]['inc'] ++; |
|
171 | + $this->flashdata[$variable]['inc']++; |
|
172 | 172 | |
173 | 173 | // if we're past the first server request |
174 | 174 | if ($this->flashdata[$variable]['inc'] > 1) { |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | |
343 | 343 | if (is_numeric($data)) { |
344 | 344 | if ((intval($data) === (int)trim($data, '-')) && strlen((string)(int)$data) === strlen($data)) { |
345 | - $data = (int) $data; |
|
345 | + $data = (int)$data; |
|
346 | 346 | } elseif ($data === (string)(float)$data) { |
347 | - $data = (float) $data; |
|
347 | + $data = (float)$data; |
|
348 | 348 | } |
349 | 349 | } else { |
350 | 350 | // $data = $this->purifier->purify($data); |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | $container = $name . 'Container'; |
363 | 363 | $container = $this->$container; |
364 | 364 | |
365 | - $argument = ! empty($arguments[0]) ? $arguments[0] : false; |
|
365 | + $argument = !empty($arguments[0]) ? $arguments[0] : false; |
|
366 | 366 | |
367 | 367 | if ($argument === false && !empty($container)) { |
368 | 368 | return $container; |
369 | 369 | } |
370 | - if (! empty($container[$argument])) { |
|
370 | + if (!empty($container[$argument])) { |
|
371 | 371 | if (!is_array($container[$argument]) |
372 | 372 | && !is_object($container[$argument]) |
373 | 373 | && strlen($container[$argument]) > 0 |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | } |
379 | 379 | } |
380 | 380 | |
381 | - return ! empty($arguments[1]) ? $arguments[1] : false; |
|
381 | + return !empty($arguments[1]) ? $arguments[1] : false; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | throw new Exception\FunctionException('Method ' . $name . ' does not exist.'); |
@@ -16,15 +16,15 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function __construct() |
18 | 18 | { |
19 | - $database = function () { |
|
19 | + $database = function() { |
|
20 | 20 | return new Database(); |
21 | 21 | }; |
22 | 22 | |
23 | - $router = function () { |
|
23 | + $router = function() { |
|
24 | 24 | return new Router(); |
25 | 25 | }; |
26 | 26 | |
27 | - $request = function () { |
|
27 | + $request = function() { |
|
28 | 28 | return new Request(); |
29 | 29 | }; |
30 | 30 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | public function __get($property) |
37 | 37 | { |
38 | - if (! empty($this->services[$property])) { |
|
38 | + if (!empty($this->services[$property])) { |
|
39 | 39 | return $this->services[$property]; |
40 | 40 | } |
41 | 41 | throw new Exception\LookupException('The service: ' . $property . ' hasn\'t been registered.'); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | public function establishConnection($name = 'default') |
32 | 32 | { |
33 | 33 | if ($this->configuration !== false) { |
34 | - if (! empty($this->configuration->$name)) { |
|
34 | + if (!empty($this->configuration->$name)) { |
|
35 | 35 | $dbConfig = $this->configuration->$name; |
36 | 36 | self::$dbh[$name] = new \PDO($dbConfig->dsn, $dbConfig->user, $dbConfig->pass); |
37 | 37 | self::$dbh[$name]->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
@@ -214,6 +214,9 @@ discard block |
||
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | + /** |
|
218 | + * @param string $service |
|
219 | + */ |
|
217 | 220 | public function setService($service, $class) |
218 | 221 | { |
219 | 222 | if($this->services === null) { |
@@ -225,6 +228,7 @@ discard block |
||
225 | 228 | |
226 | 229 | /** |
227 | 230 | * @param mixed string with reference to config |
231 | + * @param string $config |
|
228 | 232 | * @return mixed bool or config values |
229 | 233 | */ |
230 | 234 | public function getConfiguration($config = null) |
@@ -342,7 +346,6 @@ discard block |
||
342 | 346 | * Attach (or remove) multiple callbacks to an event and trigger those callbacks when that event is called. |
343 | 347 | * |
344 | 348 | * @param string $event name |
345 | - * @param mixed $value the optional value to pass to each callback |
|
346 | 349 | * @param mixed $callback the method or function to call - FALSE to remove all callbacks for event |
347 | 350 | */ |
348 | 351 | |
@@ -356,6 +359,9 @@ discard block |
||
356 | 359 | } |
357 | 360 | } |
358 | 361 | |
362 | + /** |
|
363 | + * @param string $event |
|
364 | + */ |
|
359 | 365 | public function callEvent($event, $method = false, $arguments = []) |
360 | 366 | { |
361 | 367 | if (isset(self::$events[$event])) { |
@@ -231,9 +231,9 @@ |
||
231 | 231 | public function getConfiguration($config = null) |
232 | 232 | { |
233 | 233 | if ($config !== null) { |
234 | - if (! empty($this->configuration->$config)) { |
|
234 | + if (!empty($this->configuration->$config)) { |
|
235 | 235 | return $this->configuration->$config; |
236 | - } elseif (! empty($this->files{$config})) { |
|
236 | + } elseif (!empty($this->files{$config})) { |
|
237 | 237 | $vars = include $this->files{$config}; |
238 | 238 | |
239 | 239 | if ($vars === false) { |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Zewa; |
4 | 4 | |
5 | -use Zewa\Exception\LookupException; |
|
6 | - |
|
7 | 5 | /** |
8 | 6 | * This class is the starting point for application |
9 | 7 | * |
@@ -170,6 +170,9 @@ discard block |
||
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | + /** |
|
174 | + * @param boolean|string $layout |
|
175 | + */ |
|
173 | 176 | public function setLayout($layout) |
174 | 177 | { |
175 | 178 | |
@@ -211,6 +214,10 @@ discard block |
||
211 | 214 | * @return string processed content |
212 | 215 | */ |
213 | 216 | //@TODO: come back and clean up this and the way the view receives stuff |
217 | + |
|
218 | + /** |
|
219 | + * @param string|boolean $file |
|
220 | + */ |
|
214 | 221 | private function process($file) |
215 | 222 | { |
216 | 223 | ob_start(); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $this->view = $this->process($this->view); |
115 | 115 | } |
116 | 116 | |
117 | - if (! is_null($this->layout)) { |
|
117 | + if (!is_null($this->layout)) { |
|
118 | 118 | return $this->process($this->layout); |
119 | 119 | } else { |
120 | 120 | return $this->view; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | foreach ($sheets as $sheet) { |
250 | - $string .= '<link rel="stylesheet" href="' . $sheet .'">' . "\r\n"; |
|
250 | + $string .= '<link rel="stylesheet" href="' . $sheet . '">' . "\r\n"; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | return $string; |