@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | self::getInstance()->checkMethod($route, $requestMethod); |
| 71 | 71 | self::getInstance()->checkData($route, (new Uri($_SERVER['REQUEST_URI']))->getPath()); |
| 72 | 72 | return self::getInstance(); |
| 73 | - }catch(\Exception $er){ |
|
| 73 | + } catch(\Exception $er){ |
|
| 74 | 74 | continue; |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | try{ |
| 98 | 98 | $action = unserialize(self::getInstance()->current()['action']); |
| 99 | 99 | self::getInstance()->executeRouteAction( (is_string($action)) ? $action : $action->getClosure() ); |
| 100 | - }catch(\Exception $er){ |
|
| 100 | + } catch(\Exception $er){ |
|
| 101 | 101 | self::getInstance()->error = $er; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $routes[strval($index)] = [ |
| 72 | - 'uri' => serialize(new Uri(self::getInstance()->getHost().self::getInstance()->getPrefix().$uri)), |
|
| 73 | - 'action' => (is_callable($closure)) ? serialize(new SerializableClosure($closure)) : serialize($closure), |
|
| 74 | - 'method' => strtoupper($method), |
|
| 72 | + 'uri' => serialize(new Uri(self::getInstance()->getHost().self::getInstance()->getPrefix().$uri)), |
|
| 73 | + 'action' => (is_callable($closure)) ? serialize(new SerializableClosure($closure)) : serialize($closure), |
|
| 74 | + 'method' => strtoupper($method), |
|
| 75 | 75 | 'middlewares' => [], |
| 76 | 76 | 'where' => [], |
| 77 | 77 | 'before' => [], |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | private static function checkDuplicity(string $uri, string $method): void |
| 91 | 91 | { |
| 92 | 92 | foreach(self::getInstance()->getRoutes() as $route){ |
| 93 | - if( md5(strtoupper(unserialize($route['uri'])->getPath().$route['method'])) === md5(strtoupper($uri.$method)) ){ |
|
| 93 | + if( md5(strtoupper(unserialize($route['uri'])->getPath().$route['method'])) === md5(strtoupper($uri.$method)) ){ |
|
| 94 | 94 | throw new \RuntimeException("There is already a route with the URI {$uri} and with the {$method} METHOD configured."); |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -91,7 +91,9 @@ discard block |
||
| 91 | 91 | $ReflectionMethod = new \ReflectionFunction ($closure); |
| 92 | 92 | |
| 93 | 93 | foreach($ReflectionMethod->getParameters() as $param){ |
| 94 | - if(!isset($_REQUEST[$param->name])) continue; |
|
| 94 | + if(!isset($_REQUEST[$param->name])) { |
|
| 95 | + continue; |
|
| 96 | + } |
|
| 95 | 97 | $params[$param->name] = $_REQUEST[$param->name]; |
| 96 | 98 | } |
| 97 | 99 | |
@@ -174,7 +176,9 @@ discard block |
||
| 174 | 176 | $ReflectionMethod = new \ReflectionMethod(new $controller(), $method); |
| 175 | 177 | |
| 176 | 178 | foreach($ReflectionMethod->getParameters() as $param){ |
| 177 | - if(!isset($_REQUEST[$param->name])) continue; |
|
| 179 | + if(!isset($_REQUEST[$param->name])) { |
|
| 180 | + continue; |
|
| 181 | + } |
|
| 178 | 182 | $params[$param->name] = $_REQUEST[$param->name]; |
| 179 | 183 | } |
| 180 | 184 | |
@@ -7,18 +7,18 @@ |
||
| 7 | 7 | #[Attribute] |
| 8 | 8 | class RouteAttribute{ |
| 9 | 9 | public function __construct |
| 10 | - ( |
|
| 11 | - private string $uri, |
|
| 12 | - private array $methods, |
|
| 13 | - private string $name, |
|
| 14 | - private ?array $where, |
|
| 15 | - private ?string|Closure $after, |
|
| 16 | - private ?string|Closure $before, |
|
| 17 | - private ?array $attributes, |
|
| 18 | - private ?array $middleware |
|
| 19 | - ) |
|
| 20 | - { |
|
| 21 | - echo 1; |
|
| 10 | + ( |
|
| 11 | + private string $uri, |
|
| 12 | + private array $methods, |
|
| 13 | + private string $name, |
|
| 14 | + private ?array $where, |
|
| 15 | + private ?string|Closure $after, |
|
| 16 | + private ?string|Closure $before, |
|
| 17 | + private ?array $attributes, |
|
| 18 | + private ?array $middleware |
|
| 19 | + ) |
|
| 20 | + { |
|
| 21 | + echo 1; |
|
| 22 | 22 | |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |