@@ -122,6 +122,9 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | + /** |
|
126 | + * @param string $uri |
|
127 | + */ |
|
125 | 128 | private function isURIClean($uri, $uriChunks) |
126 | 129 | { |
127 | 130 | if (!preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $uri) |
@@ -138,6 +141,10 @@ discard block |
||
138 | 141 | } |
139 | 142 | |
140 | 143 | //@TODO add Security class. |
144 | + |
|
145 | + /** |
|
146 | + * @param string $data |
|
147 | + */ |
|
141 | 148 | private function normalize($data) |
142 | 149 | { |
143 | 150 | if (is_numeric($data)) { |
@@ -218,6 +225,9 @@ discard block |
||
218 | 225 | return $normalizedURI; |
219 | 226 | } |
220 | 227 | |
228 | + /** |
|
229 | + * @param string $uri |
|
230 | + */ |
|
221 | 231 | private function discoverRoute($uri) |
222 | 232 | { |
223 | 233 | $routes = $this->configuration->routes; |
@@ -249,6 +259,7 @@ discard block |
||
249 | 259 | * Normalize the $_SERVER vars for formatting the URI. |
250 | 260 | * |
251 | 261 | * @access public |
262 | + * @param string $uri |
|
252 | 263 | * @return string formatted/u/r/l |
253 | 264 | */ |
254 | 265 | private function uri($uri) |
@@ -307,6 +318,9 @@ discard block |
||
307 | 318 | return array_merge($return, array_values($uriChunks)); |
308 | 319 | } |
309 | 320 | |
321 | + /** |
|
322 | + * @param string $url |
|
323 | + */ |
|
310 | 324 | private function addQueryString($url, $key, $value) |
311 | 325 | { |
312 | 326 | $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); |
@@ -318,6 +332,9 @@ discard block |
||
318 | 332 | } |
319 | 333 | } |
320 | 334 | |
335 | + /** |
|
336 | + * @param string $url |
|
337 | + */ |
|
321 | 338 | private function removeQueryString($url, $key) |
322 | 339 | { |
323 | 340 | $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); |
@@ -392,7 +409,7 @@ discard block |
||
392 | 409 | * Set optional status header, and redirect to provided URL |
393 | 410 | * |
394 | 411 | * @access public |
395 | - * @return bool |
|
412 | + * @return false|null |
|
396 | 413 | */ |
397 | 414 | public function redirect($url = '/', $status = null) |
398 | 415 | { |
@@ -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']) |
@@ -410,29 +410,29 @@ |
||
410 | 410 | // push a status to the browser if necessary |
411 | 411 | if ((int)$status > 0) { |
412 | 412 | switch ($status) { |
413 | - case '301': |
|
414 | - $msg = '301 Moved Permanently'; |
|
415 | - break; |
|
416 | - case '307': |
|
417 | - $msg = '307 Temporary Redirect'; |
|
418 | - break; |
|
419 | - // Using these below (except 302) would be an intentional misuse of the 'system' |
|
420 | - case '401': |
|
421 | - $msg = '401 Access Denied'; |
|
422 | - break; |
|
423 | - case '403': |
|
424 | - $msg = '403 Request Forbidden'; |
|
425 | - break; |
|
426 | - case '404': |
|
427 | - $msg = '404 Not Found'; |
|
428 | - break; |
|
429 | - case '405': |
|
430 | - $msg = '405 Method Not Allowed'; |
|
431 | - break; |
|
432 | - case '302': |
|
433 | - default: |
|
434 | - $msg = '302 Found'; |
|
435 | - break; // temp redirect |
|
413 | + case '301': |
|
414 | + $msg = '301 Moved Permanently'; |
|
415 | + break; |
|
416 | + case '307': |
|
417 | + $msg = '307 Temporary Redirect'; |
|
418 | + break; |
|
419 | + // Using these below (except 302) would be an intentional misuse of the 'system' |
|
420 | + case '401': |
|
421 | + $msg = '401 Access Denied'; |
|
422 | + break; |
|
423 | + case '403': |
|
424 | + $msg = '403 Request Forbidden'; |
|
425 | + break; |
|
426 | + case '404': |
|
427 | + $msg = '404 Not Found'; |
|
428 | + break; |
|
429 | + case '405': |
|
430 | + $msg = '405 Method Not Allowed'; |
|
431 | + break; |
|
432 | + case '302': |
|
433 | + default: |
|
434 | + $msg = '302 Found'; |
|
435 | + break; // temp redirect |
|
436 | 436 | } |
437 | 437 | if (isset($msg)) { |
438 | 438 | header('HTTP/1.1 ' . $msg); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | if (!preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $uri) |
134 | 134 | || array_filter( |
135 | - $uriChunks, function ($uriChunk) { |
|
135 | + $uriChunks, function($uriChunk) { |
|
136 | 136 | if (strpos($uriChunk, '__') !== false) { |
137 | 137 | return true; |
138 | 138 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | $normalizedURI = ltrim(preg_replace('/\?.*/', '', $normalizedURI), '/'); |
218 | 218 | |
219 | - if (! empty($this->configuration->routes)) { |
|
219 | + if (!empty($this->configuration->routes)) { |
|
220 | 220 | $normalizedURI = $this->discoverRoute($normalizedURI); |
221 | 221 | } |
222 | 222 | |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | |
236 | 236 | $uri = $reroute; |
237 | 237 | |
238 | - if (! empty($params)) { |
|
238 | + if (!empty($params)) { |
|
239 | 239 | $pat = '/(\$\d+)/'; |
240 | 240 | $uri = preg_replace_callback( |
241 | - $pat, function () use (&$params) { |
|
241 | + $pat, function() use (&$params) { |
|
242 | 242 | $first = $params[0]; |
243 | 243 | array_shift($params); |
244 | 244 | return $first; |
@@ -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)) { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if ($interface !== 'file') { |
78 | 78 | try { |
79 | 79 | //@TODO: database should be pulling an instance or DI. |
80 | - $database = new Database();//App::getService('database')->fetchConnection(); |
|
80 | + $database = new Database(); //App::getService('database')->fetchConnection(); |
|
81 | 81 | $this->dbh = $database->fetchConnection('default'); |
82 | 82 | |
83 | 83 | session_set_save_handler( |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | public function destroy($sessionId) |
164 | 164 | { |
165 | 165 | $success = false; |
166 | - $query = "DELETE FROM ". $this->tableName |
|
166 | + $query = "DELETE FROM " . $this->tableName |
|
167 | 167 | . " WHERE id = ?"; |
168 | 168 | |
169 | 169 | $success = $this->dbh->prepare($query) |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | public function gc() |
180 | 180 | { |
181 | 181 | |
182 | - $query = "DELETE FROM ". $this->tableName |
|
182 | + $query = "DELETE FROM " . $this->tableName |
|
183 | 183 | . " WHERE session_expire < ?"; |
184 | 184 | |
185 | 185 | return $this->dbh->prepare($query) |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | . ") ENGINE=InnoDB DEFAULT CHARSET=utf8"; |
311 | 311 | |
312 | 312 | $this->dbh->prepare($query)->execute(); |
313 | - } catch(\PDOException $e) { |
|
313 | + } catch (\PDOException $e) { |
|
314 | 314 | print_r($e->getMessage()); |
315 | 315 | } |
316 | 316 | die('test'); |
@@ -226,7 +226,7 @@ |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | foreach ($sheets as $sheet) { |
229 | - $string .= '<link rel="stylesheet" href="' . $sheet .'">' . "\r\n"; |
|
229 | + $string .= '<link rel="stylesheet" href="' . $sheet . '">' . "\r\n"; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | return $string; |
@@ -90,8 +90,6 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @access public |
92 | 92 | * |
93 | - * @param string $requestedView relative path for the view |
|
94 | - * @param string $renderName array of data to expose to view |
|
95 | 93 | * |
96 | 94 | * @throws \Exception when a view can not be found |
97 | 95 | */ |
@@ -181,6 +179,10 @@ discard block |
||
181 | 179 | * @return string processed content |
182 | 180 | */ |
183 | 181 | //@TODO: come back and clean up this and the way the view receives stuff |
182 | + |
|
183 | + /** |
|
184 | + * @param string|boolean $file |
|
185 | + */ |
|
184 | 186 | private function process($file) |
185 | 187 | { |
186 | 188 | ob_start(); |
@@ -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])) { |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | private function prepareServices() |
190 | 190 | { |
191 | - if(isset($this->files['services'])) { |
|
191 | + if (isset($this->files['services'])) { |
|
192 | 192 | $services = include $this->files['services']; |
193 | 193 | if ($services === false) { |
194 | 194 | $this->services = []; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | public function getService($service, $new = false, $options = []) |
204 | 204 | { |
205 | - if($this->services === null) { |
|
205 | + if ($this->services === null) { |
|
206 | 206 | $this->prepareServices(); |
207 | 207 | } |
208 | 208 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | public function setService($service, $class) |
218 | 218 | { |
219 | - if($this->services === null) { |
|
219 | + if ($this->services === null) { |
|
220 | 220 | $this->prepareServices(); |
221 | 221 | } |
222 | 222 | |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | public function getConfiguration($config = null) |
231 | 231 | { |
232 | 232 | if ($config !== null) { |
233 | - if (! empty($this->configuration->$config)) { |
|
233 | + if (!empty($this->configuration->$config)) { |
|
234 | 234 | return $this->configuration->$config; |
235 | - } elseif(! empty($this->files{$config}) ) { |
|
235 | + } elseif (!empty($this->files{$config})) { |
|
236 | 236 | |
237 | 237 | $vars = include $this->files{$config}; |
238 | 238 |