@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | $route = clone $this; |
47 | 47 | |
48 | 48 | // array fallback |
49 | - if (count($middleware) === 1 && is_array($middleware[0])) { |
|
49 | + if (count($middleware) === 1 && is_array($middleware[0])){ |
|
50 | 50 | $middleware = $middleware[0]; |
51 | 51 | } |
52 | 52 | |
53 | - foreach ($middleware as $item) { |
|
54 | - if (!is_string($item) && !$item instanceof MiddlewareInterface) { |
|
55 | - if (is_object($item)) { |
|
53 | + foreach ($middleware as $item){ |
|
54 | + if (!is_string($item) && !$item instanceof MiddlewareInterface){ |
|
55 | + if (is_object($item)){ |
|
56 | 56 | $name = get_class($item); |
57 | - } else { |
|
57 | + }else{ |
|
58 | 58 | $name = gettype($item); |
59 | 59 | } |
60 | 60 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $route->middleware[] = $item; |
65 | 65 | } |
66 | 66 | |
67 | - if ($route->pipeline !== null) { |
|
67 | + if ($route->pipeline !== null){ |
|
68 | 68 | $route->pipeline = $route->makePipeline(); |
69 | 69 | } |
70 | 70 | |
@@ -81,22 +81,22 @@ discard block |
||
81 | 81 | protected function makePipeline(): Pipeline |
82 | 82 | { |
83 | 83 | // pre-aggregated |
84 | - if (count($this->middleware) === 1 && $this->middleware[0] instanceof Pipeline) { |
|
84 | + if (count($this->middleware) === 1 && $this->middleware[0] instanceof Pipeline){ |
|
85 | 85 | return $this->middleware[0]; |
86 | 86 | } |
87 | 87 | |
88 | - try { |
|
88 | + try{ |
|
89 | 89 | $pipeline = $this->container->get(Pipeline::class); |
90 | 90 | |
91 | - foreach ($this->middleware as $middleware) { |
|
92 | - if ($middleware instanceof MiddlewareInterface) { |
|
91 | + foreach ($this->middleware as $middleware){ |
|
92 | + if ($middleware instanceof MiddlewareInterface){ |
|
93 | 93 | $pipeline->pushMiddleware($middleware); |
94 | - } else { |
|
94 | + }else{ |
|
95 | 95 | // dynamically resolved |
96 | 96 | $pipeline->pushMiddleware($this->container->get($middleware)); |
97 | 97 | } |
98 | 98 | } |
99 | - } catch (ContainerExceptionInterface $e) { |
|
99 | + }catch (ContainerExceptionInterface $e){ |
|
100 | 100 | throw new RouteException($e->getMessage(), $e->getCode(), $e); |
101 | 101 | } |
102 | 102 |
@@ -46,15 +46,21 @@ discard block |
||
46 | 46 | $route = clone $this; |
47 | 47 | |
48 | 48 | // array fallback |
49 | - if (count($middleware) === 1 && is_array($middleware[0])) { |
|
49 | + if (count($middleware) === 1 && is_array($middleware[0])) |
|
50 | + { |
|
50 | 51 | $middleware = $middleware[0]; |
51 | 52 | } |
52 | 53 | |
53 | - foreach ($middleware as $item) { |
|
54 | - if (!is_string($item) && !$item instanceof MiddlewareInterface) { |
|
55 | - if (is_object($item)) { |
|
54 | + foreach ($middleware as $item) |
|
55 | + { |
|
56 | + if (!is_string($item) && !$item instanceof MiddlewareInterface) |
|
57 | + { |
|
58 | + if (is_object($item)) |
|
59 | + { |
|
56 | 60 | $name = get_class($item); |
57 | - } else { |
|
61 | + } |
|
62 | + else |
|
63 | + { |
|
58 | 64 | $name = gettype($item); |
59 | 65 | } |
60 | 66 | |
@@ -64,7 +70,8 @@ discard block |
||
64 | 70 | $route->middleware[] = $item; |
65 | 71 | } |
66 | 72 | |
67 | - if ($route->pipeline !== null) { |
|
73 | + if ($route->pipeline !== null) |
|
74 | + { |
|
68 | 75 | $route->pipeline = $route->makePipeline(); |
69 | 76 | } |
70 | 77 | |
@@ -81,22 +88,30 @@ discard block |
||
81 | 88 | protected function makePipeline(): Pipeline |
82 | 89 | { |
83 | 90 | // pre-aggregated |
84 | - if (count($this->middleware) === 1 && $this->middleware[0] instanceof Pipeline) { |
|
91 | + if (count($this->middleware) === 1 && $this->middleware[0] instanceof Pipeline) |
|
92 | + { |
|
85 | 93 | return $this->middleware[0]; |
86 | 94 | } |
87 | 95 | |
88 | - try { |
|
96 | + try |
|
97 | + { |
|
89 | 98 | $pipeline = $this->container->get(Pipeline::class); |
90 | 99 | |
91 | - foreach ($this->middleware as $middleware) { |
|
92 | - if ($middleware instanceof MiddlewareInterface) { |
|
100 | + foreach ($this->middleware as $middleware) |
|
101 | + { |
|
102 | + if ($middleware instanceof MiddlewareInterface) |
|
103 | + { |
|
93 | 104 | $pipeline->pushMiddleware($middleware); |
94 | - } else { |
|
105 | + } |
|
106 | + else |
|
107 | + { |
|
95 | 108 | // dynamically resolved |
96 | 109 | $pipeline->pushMiddleware($this->container->get($middleware)); |
97 | 110 | } |
98 | 111 | } |
99 | - } catch (ContainerExceptionInterface $e) { |
|
112 | + } |
|
113 | + catch (ContainerExceptionInterface $e) |
|
114 | + { |
|
100 | 115 | throw new RouteException($e->getMessage(), $e->getCode(), $e); |
101 | 116 | } |
102 | 117 |
@@ -30,9 +30,9 @@ |
||
30 | 30 | */ |
31 | 31 | public function withVerbs(string ...$verbs): RouteInterface |
32 | 32 | { |
33 | - foreach ($verbs as &$verb) { |
|
33 | + foreach ($verbs as &$verb){ |
|
34 | 34 | $verb = strtoupper($verb); |
35 | - if (!in_array($verb, RouteInterface::VERBS, true)) { |
|
35 | + if (!in_array($verb, RouteInterface::VERBS, true)){ |
|
36 | 36 | throw new RouteException("Invalid HTTP verb `{$verb}`"); |
37 | 37 | } |
38 | 38 |
@@ -30,9 +30,11 @@ |
||
30 | 30 | */ |
31 | 31 | public function withVerbs(string ...$verbs): RouteInterface |
32 | 32 | { |
33 | - foreach ($verbs as &$verb) { |
|
33 | + foreach ($verbs as &$verb) |
|
34 | + { |
|
34 | 35 | $verb = strtoupper($verb); |
35 | - if (!in_array($verb, RouteInterface::VERBS, true)) { |
|
36 | + if (!in_array($verb, RouteInterface::VERBS, true)) |
|
37 | + { |
|
36 | 38 | throw new RouteException("Invalid HTTP verb `{$verb}`"); |
37 | 39 | } |
38 | 40 |
@@ -65,12 +65,12 @@ |
||
65 | 65 | */ |
66 | 66 | public function match(Request $request): ?RouteInterface |
67 | 67 | { |
68 | - if (!in_array(strtoupper($request->getMethod()), $this->getVerbs(), true)) { |
|
68 | + if (!in_array(strtoupper($request->getMethod()), $this->getVerbs(), true)){ |
|
69 | 69 | return null; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $matches = $this->uriHandler->match($request->getUri(), $this->defaults); |
73 | - if ($matches === null) { |
|
73 | + if ($matches === null){ |
|
74 | 74 | return null; |
75 | 75 | } |
76 | 76 |
@@ -65,12 +65,14 @@ |
||
65 | 65 | */ |
66 | 66 | public function match(Request $request): ?RouteInterface |
67 | 67 | { |
68 | - if (!in_array(strtoupper($request->getMethod()), $this->getVerbs(), true)) { |
|
68 | + if (!in_array(strtoupper($request->getMethod()), $this->getVerbs(), true)) |
|
69 | + { |
|
69 | 70 | return null; |
70 | 71 | } |
71 | 72 | |
72 | 73 | $matches = $this->uriHandler->match($request->getUri(), $this->defaults); |
73 | - if ($matches === null) { |
|
74 | + if ($matches === null) |
|
75 | + { |
|
74 | 76 | return null; |
75 | 77 | } |
76 | 78 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | { |
25 | 25 | public function tearDown(): void |
26 | 26 | { |
27 | - if ((int)session_status() === PHP_SESSION_ACTIVE) { |
|
27 | + if ((int)session_status() === PHP_SESSION_ACTIVE){ |
|
28 | 28 | session_abort(); |
29 | 29 | } |
30 | 30 | } |
@@ -24,7 +24,8 @@ |
||
24 | 24 | { |
25 | 25 | public function tearDown(): void |
26 | 26 | { |
27 | - if ((int)session_status() === PHP_SESSION_ACTIVE) { |
|
27 | + if ((int)session_status() === PHP_SESSION_ACTIVE) |
|
28 | + { |
|
28 | 29 | session_abort(); |
29 | 30 | } |
30 | 31 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | public function tearDown(): void |
53 | 53 | { |
54 | - if ((int)session_status() === PHP_SESSION_ACTIVE) { |
|
54 | + if ((int)session_status() === PHP_SESSION_ACTIVE){ |
|
55 | 55 | session_abort(); |
56 | 56 | } |
57 | 57 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->assertSame('default', $section->getName()); |
126 | 126 | |
127 | 127 | $section->set('key', 'value'); |
128 | - foreach ($section as $key => $value) { |
|
128 | + foreach ($section as $key => $value){ |
|
129 | 129 | $this->assertSame('key', $key); |
130 | 130 | $this->assertSame('value', $value); |
131 | 131 | } |
@@ -51,7 +51,8 @@ discard block |
||
51 | 51 | |
52 | 52 | public function tearDown(): void |
53 | 53 | { |
54 | - if ((int)session_status() === PHP_SESSION_ACTIVE) { |
|
54 | + if ((int)session_status() === PHP_SESSION_ACTIVE) |
|
55 | + { |
|
55 | 56 | session_abort(); |
56 | 57 | } |
57 | 58 | } |
@@ -125,7 +126,8 @@ discard block |
||
125 | 126 | $this->assertSame('default', $section->getName()); |
126 | 127 | |
127 | 128 | $section->set('key', 'value'); |
128 | - foreach ($section as $key => $value) { |
|
129 | + foreach ($section as $key => $value) |
|
130 | + { |
|
129 | 131 | $this->assertSame('key', $key); |
130 | 132 | $this->assertSame('value', $value); |
131 | 133 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function get(string $name, $default = null) |
129 | 129 | { |
130 | - if (!$this->has($name)) { |
|
130 | + if (!$this->has($name)){ |
|
131 | 131 | return $default; |
132 | 132 | } |
133 | 133 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | { |
203 | 203 | $this->session->resume(); |
204 | 204 | |
205 | - if (!isset($_SESSION[$this->name])) { |
|
205 | + if (!isset($_SESSION[$this->name])){ |
|
206 | 206 | $_SESSION[$this->name] = []; |
207 | 207 | } |
208 | 208 | } |
@@ -127,7 +127,8 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function get(string $name, $default = null) |
129 | 129 | { |
130 | - if (!$this->has($name)) { |
|
130 | + if (!$this->has($name)) |
|
131 | + { |
|
131 | 132 | return $default; |
132 | 133 | } |
133 | 134 | |
@@ -202,7 +203,8 @@ discard block |
||
202 | 203 | { |
203 | 204 | $this->session->resume(); |
204 | 205 | |
205 | - if (!isset($_SESSION[$this->name])) { |
|
206 | + if (!isset($_SESSION[$this->name])) |
|
207 | + { |
|
206 | 208 | $_SESSION[$this->name] = []; |
207 | 209 | } |
208 | 210 | } |
@@ -64,15 +64,15 @@ |
||
64 | 64 | */ |
65 | 65 | public function getHandler(): ?Autowire |
66 | 66 | { |
67 | - if (empty($this->config['handler'])) { |
|
67 | + if (empty($this->config['handler'])){ |
|
68 | 68 | return null; |
69 | 69 | } |
70 | 70 | |
71 | - if ($this->config['handler'] instanceof Autowire) { |
|
71 | + if ($this->config['handler'] instanceof Autowire){ |
|
72 | 72 | return $this->config['handler']; |
73 | 73 | } |
74 | 74 | |
75 | - if (class_exists($this->config['handler'])) { |
|
75 | + if (class_exists($this->config['handler'])){ |
|
76 | 76 | return new Autowire($this->config['handler']); |
77 | 77 | } |
78 | 78 |
@@ -64,15 +64,18 @@ |
||
64 | 64 | */ |
65 | 65 | public function getHandler(): ?Autowire |
66 | 66 | { |
67 | - if (empty($this->config['handler'])) { |
|
67 | + if (empty($this->config['handler'])) |
|
68 | + { |
|
68 | 69 | return null; |
69 | 70 | } |
70 | 71 | |
71 | - if ($this->config['handler'] instanceof Autowire) { |
|
72 | + if ($this->config['handler'] instanceof Autowire) |
|
73 | + { |
|
72 | 74 | return $this->config['handler']; |
73 | 75 | } |
74 | 76 | |
75 | - if (class_exists($this->config['handler'])) { |
|
77 | + if (class_exists($this->config['handler'])) |
|
78 | + { |
|
76 | 79 | return new Autowire($this->config['handler']); |
77 | 80 | } |
78 | 81 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | $this->expectException(LoaderException::class); |
25 | 25 | |
26 | 26 | $loader = new ViewLoader([ |
27 | - 'default' => __DIR__ . '/fixtures/default', |
|
27 | + 'default' => __DIR__.'/fixtures/default', |
|
28 | 28 | ]); |
29 | 29 | |
30 | 30 | $loader->exists('view'); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $this->expectException(LoaderException::class); |
36 | 36 | |
37 | 37 | $loader = new ViewLoader([ |
38 | - 'default' => __DIR__ . '/fixtures/default', |
|
38 | + 'default' => __DIR__.'/fixtures/default', |
|
39 | 39 | ]); |
40 | 40 | |
41 | 41 | $loader->list(); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $this->expectException(LoaderException::class); |
47 | 47 | |
48 | 48 | $loader = new ViewLoader([ |
49 | - 'default' => __DIR__ . '/fixtures/default', |
|
49 | + 'default' => __DIR__.'/fixtures/default', |
|
50 | 50 | ]); |
51 | 51 | |
52 | 52 | $loader->load('view'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | public function testExists(): void |
56 | 56 | { |
57 | 57 | $loader = new ViewLoader([ |
58 | - 'default' => __DIR__ . '/fixtures/default', |
|
58 | + 'default' => __DIR__.'/fixtures/default', |
|
59 | 59 | ]); |
60 | 60 | |
61 | 61 | $loader = $loader->withExtension('php'); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function testList(): void |
87 | 87 | { |
88 | 88 | $loader = new ViewLoader([ |
89 | - 'default' => __DIR__ . '/fixtures/default', |
|
89 | + 'default' => __DIR__.'/fixtures/default', |
|
90 | 90 | ]); |
91 | 91 | |
92 | 92 | $loader = $loader->withExtension('php'); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $this->expectException(LoaderException::class); |
104 | 104 | |
105 | 105 | $loader = new ViewLoader([ |
106 | - 'default' => __DIR__ . '/fixtures/default', |
|
106 | + 'default' => __DIR__.'/fixtures/default', |
|
107 | 107 | ]); |
108 | 108 | |
109 | 109 | $loader = $loader->withExtension('php'); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | public function testLoad(): void |
147 | 147 | { |
148 | 148 | $loader = new ViewLoader([ |
149 | - 'default' => __DIR__ . '/fixtures/default', |
|
149 | + 'default' => __DIR__.'/fixtures/default', |
|
150 | 150 | ]); |
151 | 151 | |
152 | 152 | $loader = $loader->withExtension('php'); |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | public function testMultipleNamespaces(): void |
170 | 170 | { |
171 | 171 | $loader = new ViewLoader([ |
172 | - 'default' => __DIR__ . '/fixtures/default', |
|
173 | - 'other' => __DIR__ . '/fixtures/other', |
|
172 | + 'default' => __DIR__.'/fixtures/default', |
|
173 | + 'other' => __DIR__.'/fixtures/other', |
|
174 | 174 | |
175 | 175 | ]); |
176 | 176 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $manager->addEngine(new NativeEngine($this->container, 'dark.php')); |
37 | 37 | |
38 | 38 | $ext = []; |
39 | - foreach ($manager->getEngines() as $e) { |
|
39 | + foreach ($manager->getEngines() as $e){ |
|
40 | 40 | $ext[] = $e->getLoader()->getExtension(); |
41 | 41 | } |
42 | 42 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | 'directory' => '/tmp', |
125 | 125 | ], |
126 | 126 | 'namespaces' => [ |
127 | - 'default' => __DIR__ . '/fixtures/default', |
|
128 | - 'other' => __DIR__ . '/fixtures/other', |
|
127 | + 'default' => __DIR__.'/fixtures/default', |
|
128 | + 'other' => __DIR__.'/fixtures/other', |
|
129 | 129 | ], |
130 | 130 | 'dependencies' => [ |
131 | 131 |
@@ -36,7 +36,8 @@ |
||
36 | 36 | $manager->addEngine(new NativeEngine($this->container, 'dark.php')); |
37 | 37 | |
38 | 38 | $ext = []; |
39 | - foreach ($manager->getEngines() as $e) { |
|
39 | + foreach ($manager->getEngines() as $e) |
|
40 | + { |
|
40 | 41 | $ext[] = $e->getLoader()->getExtension(); |
41 | 42 | } |
42 | 43 |