@@ -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']) |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | if (!preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $uri) |
| 143 | 143 | || array_filter( |
| 144 | 144 | $uriChunks, |
| 145 | - function ($uriChunk) { |
|
| 145 | + function($uriChunk) { |
|
| 146 | 146 | if (strpos($uriChunk, '__') !== false) { |
| 147 | 147 | return true; |
| 148 | 148 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | $normalizedURI = ltrim(preg_replace('/\?.*/', '', $normalizedURI), '/'); |
| 227 | 227 | |
| 228 | - if (! empty($this->routes)) { |
|
| 228 | + if (!empty($this->routes)) { |
|
| 229 | 229 | $normalizedURI = $this->discoverRoute($normalizedURI); |
| 230 | 230 | } |
| 231 | 231 | |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | |
| 245 | 245 | $uri = $reroute; |
| 246 | 246 | |
| 247 | - if (! empty($params)) { |
|
| 247 | + if (!empty($params)) { |
|
| 248 | 248 | $pat = '/(\$\d+)/'; |
| 249 | 249 | $uri = preg_replace_callback( |
| 250 | 250 | $pat, |
| 251 | - function () use (&$params) { |
|
| 251 | + function() use (&$params) { |
|
| 252 | 252 | $first = $params[0]; |
| 253 | 253 | array_shift($params); |
| 254 | 254 | return $first; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * Safe: a-z, 0-9, :, _, [, ], + |
| 145 | 145 | * |
| 146 | - * @param $uri |
|
| 146 | + * @param string $uri |
|
| 147 | 147 | * @param $uriChunks |
| 148 | 148 | * @return bool |
| 149 | 149 | */ |
@@ -152,6 +152,10 @@ discard block |
||
| 152 | 152 | if (!preg_match("/^[a-z0-9:_\/\.\[\]-]+$/i", $uri) |
| 153 | 153 | || array_filter( |
| 154 | 154 | $uriChunks, |
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @param string $uriChunk |
|
| 158 | + */ |
|
| 155 | 159 | function ($uriChunk) { |
| 156 | 160 | if (strpos($uriChunk, '__') !== false) { |
| 157 | 161 | return true; |
@@ -166,6 +170,10 @@ discard block |
||
| 166 | 170 | } |
| 167 | 171 | |
| 168 | 172 | //@TODO add Security class. |
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * @param string $data |
|
| 176 | + */ |
|
| 169 | 177 | private function normalize($data) |
| 170 | 178 | { |
| 171 | 179 | if (is_numeric($data)) { |
@@ -242,6 +250,9 @@ discard block |
||
| 242 | 250 | return $normalizedURI; |
| 243 | 251 | } |
| 244 | 252 | |
| 253 | + /** |
|
| 254 | + * @param string $uri |
|
| 255 | + */ |
|
| 245 | 256 | private function discoverRoute($uri) |
| 246 | 257 | { |
| 247 | 258 | $routes = $this->routes; |
@@ -274,7 +285,7 @@ discard block |
||
| 274 | 285 | /** |
| 275 | 286 | * Normalize the $_SERVER vars for formatting the URI. |
| 276 | 287 | * |
| 277 | - * @param $uri |
|
| 288 | + * @param string $uri |
|
| 278 | 289 | * @access public |
| 279 | 290 | * @return string formatted/u/r/l |
| 280 | 291 | */ |
@@ -329,6 +340,9 @@ discard block |
||
| 329 | 340 | return array_merge($return, array_values($uriChunks)); |
| 330 | 341 | } |
| 331 | 342 | |
| 343 | + /** |
|
| 344 | + * @param string $url |
|
| 345 | + */ |
|
| 332 | 346 | private function addQueryString($url, $key, $value) |
| 333 | 347 | { |
| 334 | 348 | $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); |
@@ -340,6 +354,9 @@ discard block |
||
| 340 | 354 | } |
| 341 | 355 | } |
| 342 | 356 | |
| 357 | + /** |
|
| 358 | + * @param string $url |
|
| 359 | + */ |
|
| 343 | 360 | private function removeQueryString($url, $key) |
| 344 | 361 | { |
| 345 | 362 | $url = preg_replace('/(.*)(\?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); |
@@ -411,7 +428,7 @@ discard block |
||
| 411 | 428 | * Set optional status header, and redirect to provided URL |
| 412 | 429 | * |
| 413 | 430 | * @access public |
| 414 | - * @return bool |
|
| 431 | + * @return false|null |
|
| 415 | 432 | */ |
| 416 | 433 | public function redirect($url = '/', $status = null) |
| 417 | 434 | { |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | // iterate through all the entries |
| 173 | 173 | foreach ($this->flashdata as $variable => $data) { |
| 174 | 174 | // increment counter representing server requests |
| 175 | - $this->flashdata[$variable]['inc'] ++; |
|
| 175 | + $this->flashdata[$variable]['inc']++; |
|
| 176 | 176 | |
| 177 | 177 | // if we're past the first server request |
| 178 | 178 | if ($this->flashdata[$variable]['inc'] > 1) { |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | //@TODO this will not accept all float values, this validates /against/ syntax |
| 349 | 349 | |
| 350 | 350 | if (($int === (int)trim($data, '-')) && strlen((string)(int)$data) === strlen($data)) { |
| 351 | - $data = (int) $data; |
|
| 351 | + $data = (int)$data; |
|
| 352 | 352 | } elseif ($int !== $float && preg_match($re, $data) === 1) { |
| 353 | 353 | $data = floatval($data); |
| 354 | 354 | } |
@@ -368,12 +368,12 @@ discard block |
||
| 368 | 368 | $container = $name . 'Container'; |
| 369 | 369 | $container = $this->$container; |
| 370 | 370 | |
| 371 | - $argument = ! empty($arguments[0]) ? $arguments[0] : false; |
|
| 371 | + $argument = !empty($arguments[0]) ? $arguments[0] : false; |
|
| 372 | 372 | |
| 373 | 373 | if ($argument === false && !empty($container)) { |
| 374 | 374 | return $container; |
| 375 | 375 | } |
| 376 | - if (! empty($container[$argument])) { |
|
| 376 | + if (!empty($container[$argument])) { |
|
| 377 | 377 | if (!is_array($container[$argument]) |
| 378 | 378 | && !is_object($container[$argument]) |
| 379 | 379 | && strlen($container[$argument]) > 0 |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - return ! empty($arguments[1]) ? $arguments[1] : false; |
|
| 387 | + return !empty($arguments[1]) ? $arguments[1] : false; |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | throw new Exception\FunctionException('Method ' . $name . ' does not exist.'); |
@@ -200,6 +200,9 @@ discard block |
||
| 200 | 200 | return false; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | + /** |
|
| 204 | + * @param string|boolean $layout |
|
| 205 | + */ |
|
| 203 | 206 | public function setLayout($layout) |
| 204 | 207 | { |
| 205 | 208 | if ($layout === false) { |
@@ -241,6 +244,10 @@ discard block |
||
| 241 | 244 | * @return string processed content |
| 242 | 245 | */ |
| 243 | 246 | //@TODO: come back and clean up this and the way the view receives stuff |
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param string|boolean $file |
|
| 250 | + */ |
|
| 244 | 251 | private function process($file) |
| 245 | 252 | { |
| 246 | 253 | ob_start(); |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $this->view = $return = $this->process($view); |
| 134 | 134 | |
| 135 | - if (! is_null($this->layout)) { |
|
| 135 | + if (!is_null($this->layout)) { |
|
| 136 | 136 | $return = $this->process($this->layout); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $this->view = $this->process($this->view); |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if (! is_null($this->layout)) { |
|
| 145 | + if (!is_null($this->layout)) { |
|
| 146 | 146 | return $this->process($this->layout); |
| 147 | 147 | } else { |
| 148 | 148 | return $this->view; |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | foreach ($this->queuedCSS as $sheet) { |
| 275 | - $string .= '<link rel="stylesheet" href="' . $sheet .'">' . "\r\n"; |
|
| 275 | + $string .= '<link rel="stylesheet" href="' . $sheet . '">' . "\r\n"; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | return $string; |
@@ -1,8 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace Zewa; |
| 3 | 3 | |
| 4 | -use Zewa\Interfaces\ContainerInterface; |
|
| 5 | - |
|
| 6 | 4 | /** |
| 7 | 5 | * View management |
| 8 | 6 | * |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | |
| 62 | 62 | // If there is no constructor, there is no |
| 63 | 63 | // dependencies, which means that our job is done. |
| 64 | - if (! $constructor) { |
|
| 64 | + if (!$constructor) { |
|
| 65 | 65 | $dependency = new $class; |
| 66 | 66 | if ($share === true) { |
| 67 | 67 | $this->dependencies[$class] = $dependency; |
@@ -172,7 +172,6 @@ discard block |
||
| 172 | 172 | * Attach (or remove) multiple callbacks to an event and trigger those callbacks when that event is called. |
| 173 | 173 | * |
| 174 | 174 | * @param string $event name |
| 175 | - * @param mixed $value the optional value to pass to each callback |
|
| 176 | 175 | * @param mixed $callback the method or function to call - FALSE to remove all callbacks for event |
| 177 | 176 | */ |
| 178 | 177 | |
@@ -186,6 +185,9 @@ discard block |
||
| 186 | 185 | } |
| 187 | 186 | } |
| 188 | 187 | |
| 188 | + /** |
|
| 189 | + * @param string $event |
|
| 190 | + */ |
|
| 189 | 191 | public function callEvent($event, $method = false, $arguments = []) |
| 190 | 192 | { |
| 191 | 193 | if (isset(self::$events[$event])) { |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types=1); |
|
| 2 | +declare(strict_types = 1); |
|
| 3 | 3 | |
| 4 | 4 | namespace Zewa; |
| 5 | 5 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $result = []; |
| 134 | 134 | |
| 135 | 135 | foreach ($this->collection as $key => $item) { |
| 136 | - if (! $func($key, $item)) { |
|
| 136 | + if (!$func($key, $item)) { |
|
| 137 | 137 | $result[$key] = $item; |
| 138 | 138 | } |
| 139 | 139 | } |