@@ -49,7 +49,7 @@ |
||
49 | 49 | |
50 | 50 | public function inputAction(InputScope $i) |
51 | 51 | { |
52 | - return 'value: ' . $i->withPrefix('section')->getValue('query', 'value'); |
|
52 | + return 'value: '.$i->withPrefix('section')->getValue('query', 'value'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | public function errorAction(): void |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | |
36 | 36 | public function testHasCookie(): void |
37 | 37 | { |
38 | - $this->http->setHandler(function () { |
|
38 | + $this->http->setHandler(function (){ |
|
39 | 39 | return (int)$this->cookies()->has('a'); |
40 | 40 | }); |
41 | 41 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | ]); |
54 | 54 | $this->http = $this->app->get(Http::class); |
55 | 55 | |
56 | - $this->http->setHandler(function () { |
|
56 | + $this->http->setHandler(function (){ |
|
57 | 57 | return (int)$this->cookies()->has('a'); |
58 | 58 | }); |
59 | 59 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
71 | 71 | $this->http = $this->app->get(Http::class); |
72 | 72 | |
73 | - $this->http->setHandler(function () { |
|
73 | + $this->http->setHandler(function (){ |
|
74 | 74 | return $this->cookies()->get('a'); |
75 | 75 | }); |
76 | 76 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
88 | 88 | $this->http = $this->app->get(Http::class); |
89 | 89 | |
90 | - $this->http->setHandler(function () { |
|
90 | + $this->http->setHandler(function (){ |
|
91 | 91 | $this->cookies()->set('a', 'value'); |
92 | 92 | |
93 | 93 | return 'ok'; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
112 | 112 | $this->http = $this->app->get(Http::class); |
113 | 113 | |
114 | - $this->http->setHandler(function () { |
|
114 | + $this->http->setHandler(function (){ |
|
115 | 115 | $this->cookies()->schedule(Cookie::create('a', 'value')); |
116 | 116 | $this->assertSame([], $this->cookies()->getAll()); |
117 | 117 |
@@ -35,7 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | public function testHasCookie(): void |
37 | 37 | { |
38 | - $this->http->setHandler(function () { |
|
38 | + $this->http->setHandler(function () |
|
39 | + { |
|
39 | 40 | return (int)$this->cookies()->has('a'); |
40 | 41 | }); |
41 | 42 | |
@@ -53,7 +54,8 @@ discard block |
||
53 | 54 | ]); |
54 | 55 | $this->http = $this->app->get(Http::class); |
55 | 56 | |
56 | - $this->http->setHandler(function () { |
|
57 | + $this->http->setHandler(function () |
|
58 | + { |
|
57 | 59 | return (int)$this->cookies()->has('a'); |
58 | 60 | }); |
59 | 61 | |
@@ -70,7 +72,8 @@ discard block |
||
70 | 72 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
71 | 73 | $this->http = $this->app->get(Http::class); |
72 | 74 | |
73 | - $this->http->setHandler(function () { |
|
75 | + $this->http->setHandler(function () |
|
76 | + { |
|
74 | 77 | return $this->cookies()->get('a'); |
75 | 78 | }); |
76 | 79 | |
@@ -87,7 +90,8 @@ discard block |
||
87 | 90 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
88 | 91 | $this->http = $this->app->get(Http::class); |
89 | 92 | |
90 | - $this->http->setHandler(function () { |
|
93 | + $this->http->setHandler(function () |
|
94 | + { |
|
91 | 95 | $this->cookies()->set('a', 'value'); |
92 | 96 | |
93 | 97 | return 'ok'; |
@@ -111,7 +115,8 @@ discard block |
||
111 | 115 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
112 | 116 | $this->http = $this->app->get(Http::class); |
113 | 117 | |
114 | - $this->http->setHandler(function () { |
|
118 | + $this->http->setHandler(function () |
|
119 | + { |
|
115 | 120 | $this->cookies()->schedule(Cookie::create('a', 'value')); |
116 | 121 | $this->assertSame([], $this->cookies()->getAll()); |
117 | 122 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | bool $suppressErrors, |
46 | 46 | RendererInterface $renderer, |
47 | 47 | SnapshotterInterface $snapshots = null |
48 | - ) { |
|
48 | + ){ |
|
49 | 49 | $this->suppressErrors = $suppressErrors; |
50 | 50 | $this->renderer = $renderer; |
51 | 51 | $this->snapshots = $snapshots; |
@@ -58,20 +58,20 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function process(Request $request, Handler $handler): Response |
60 | 60 | { |
61 | - try { |
|
61 | + try{ |
|
62 | 62 | return $handler->handle($request); |
63 | - } catch (ClientException | RouterException $e) { |
|
64 | - if ($e instanceof ClientException) { |
|
63 | + }catch (ClientException | RouterException $e){ |
|
64 | + if ($e instanceof ClientException){ |
|
65 | 65 | $code = $e->getCode(); |
66 | - } else { |
|
66 | + }else{ |
|
67 | 67 | $code = 404; |
68 | 68 | } |
69 | - } catch (\Throwable $e) { |
|
70 | - if (!$this->suppressErrors) { |
|
69 | + }catch (\Throwable $e){ |
|
70 | + if (!$this->suppressErrors){ |
|
71 | 71 | throw $e; |
72 | 72 | } |
73 | 73 | |
74 | - if ($this->snapshots !== null) { |
|
74 | + if ($this->snapshots !== null){ |
|
75 | 75 | $this->snapshots->register($e); |
76 | 76 | } |
77 | 77 |
@@ -58,20 +58,30 @@ |
||
58 | 58 | */ |
59 | 59 | public function process(Request $request, Handler $handler): Response |
60 | 60 | { |
61 | - try { |
|
61 | + try |
|
62 | + { |
|
62 | 63 | return $handler->handle($request); |
63 | - } catch (ClientException | RouterException $e) { |
|
64 | - if ($e instanceof ClientException) { |
|
64 | + } |
|
65 | + catch (ClientException | RouterException $e) |
|
66 | + { |
|
67 | + if ($e instanceof ClientException) |
|
68 | + { |
|
65 | 69 | $code = $e->getCode(); |
66 | - } else { |
|
70 | + } |
|
71 | + else |
|
72 | + { |
|
67 | 73 | $code = 404; |
68 | 74 | } |
69 | - } catch (\Throwable $e) { |
|
70 | - if (!$this->suppressErrors) { |
|
75 | + } |
|
76 | + catch (\Throwable $e) |
|
77 | + { |
|
78 | + if (!$this->suppressErrors) |
|
79 | + { |
|
71 | 80 | throw $e; |
72 | 81 | } |
73 | 82 | |
74 | - if ($this->snapshots !== null) { |
|
83 | + if ($this->snapshots !== null) |
|
84 | + { |
|
75 | 85 | $this->snapshots->register($e); |
76 | 86 | } |
77 | 87 |
@@ -123,9 +123,9 @@ |
||
123 | 123 | */ |
124 | 124 | public function getActiveSession(): SessionInterface |
125 | 125 | { |
126 | - try { |
|
126 | + try{ |
|
127 | 127 | return $this->container->get(SessionInterface::class); |
128 | - } catch (NotFoundExceptionInterface $e) { |
|
128 | + }catch (NotFoundExceptionInterface $e){ |
|
129 | 129 | throw new ScopeException('Unable to receive active session, invalid request scope', $e->getCode(), $e); |
130 | 130 | } |
131 | 131 | } |
@@ -123,9 +123,12 @@ |
||
123 | 123 | */ |
124 | 124 | public function getActiveSession(): SessionInterface |
125 | 125 | { |
126 | - try { |
|
126 | + try |
|
127 | + { |
|
127 | 128 | return $this->container->get(SessionInterface::class); |
128 | - } catch (NotFoundExceptionInterface $e) { |
|
129 | + } |
|
130 | + catch (NotFoundExceptionInterface $e) |
|
131 | + { |
|
129 | 132 | throw new ScopeException('Unable to receive active session, invalid request scope', $e->getCode(), $e); |
130 | 133 | } |
131 | 134 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | string $domain = null, |
119 | 119 | bool $secure = null, |
120 | 120 | bool $httpOnly = true |
121 | - ) { |
|
121 | + ){ |
|
122 | 122 | $this->getCookieQueue()->set($name, $value, $lifetime, $path, $domain, $secure, $httpOnly); |
123 | 123 | |
124 | 124 | return $this; |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | */ |
170 | 170 | private function getRequest(): ServerRequestInterface |
171 | 171 | { |
172 | - try { |
|
172 | + try{ |
|
173 | 173 | return $this->container->get(ServerRequestInterface::class); |
174 | - } catch (NotFoundExceptionInterface $e) { |
|
174 | + }catch (NotFoundExceptionInterface $e){ |
|
175 | 175 | throw new ScopeException('Unable to receive active request', $e->getCode(), $e); |
176 | 176 | } |
177 | 177 | } |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | */ |
184 | 184 | private function getCookieQueue(): CookieQueue |
185 | 185 | { |
186 | - try { |
|
186 | + try{ |
|
187 | 187 | return $this->container->get(CookieQueue::class); |
188 | - } catch (NotFoundExceptionInterface $e) { |
|
188 | + }catch (NotFoundExceptionInterface $e){ |
|
189 | 189 | throw new ScopeException('Unable to receive cookie queue, invalid request scope', $e->getCode(), $e); |
190 | 190 | } |
191 | 191 | } |
@@ -169,9 +169,12 @@ discard block |
||
169 | 169 | */ |
170 | 170 | private function getRequest(): ServerRequestInterface |
171 | 171 | { |
172 | - try { |
|
172 | + try |
|
173 | + { |
|
173 | 174 | return $this->container->get(ServerRequestInterface::class); |
174 | - } catch (NotFoundExceptionInterface $e) { |
|
175 | + } |
|
176 | + catch (NotFoundExceptionInterface $e) |
|
177 | + { |
|
175 | 178 | throw new ScopeException('Unable to receive active request', $e->getCode(), $e); |
176 | 179 | } |
177 | 180 | } |
@@ -183,9 +186,12 @@ discard block |
||
183 | 186 | */ |
184 | 187 | private function getCookieQueue(): CookieQueue |
185 | 188 | { |
186 | - try { |
|
189 | + try |
|
190 | + { |
|
187 | 191 | return $this->container->get(CookieQueue::class); |
188 | - } catch (NotFoundExceptionInterface $e) { |
|
192 | + } |
|
193 | + catch (NotFoundExceptionInterface $e) |
|
194 | + { |
|
189 | 195 | throw new ScopeException('Unable to receive cookie queue, invalid request scope', $e->getCode(), $e); |
190 | 196 | } |
191 | 197 | } |
@@ -94,9 +94,9 @@ |
||
94 | 94 | */ |
95 | 95 | private function getAuthContext(): AuthContextInterface |
96 | 96 | { |
97 | - try { |
|
97 | + try{ |
|
98 | 98 | return $this->container->get(AuthContextInterface::class); |
99 | - } catch (NotFoundExceptionInterface $e) { |
|
99 | + }catch (NotFoundExceptionInterface $e){ |
|
100 | 100 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
101 | 101 | } |
102 | 102 | } |
@@ -94,9 +94,12 @@ |
||
94 | 94 | */ |
95 | 95 | private function getAuthContext(): AuthContextInterface |
96 | 96 | { |
97 | - try { |
|
97 | + try |
|
98 | + { |
|
98 | 99 | return $this->container->get(AuthContextInterface::class); |
99 | - } catch (NotFoundExceptionInterface $e) { |
|
100 | + } |
|
101 | + catch (NotFoundExceptionInterface $e) |
|
102 | + { |
|
100 | 103 | throw new ScopeException('Unable to resolve auth context, invalid scope', $e->getCode(), $e); |
101 | 104 | } |
102 | 105 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | PermissionsInterface $permissions, |
42 | 42 | ContainerInterface $actorScope, |
43 | 43 | array $roles = [] |
44 | - ) { |
|
44 | + ){ |
|
45 | 45 | $this->roles = $roles; |
46 | 46 | $this->container = $actorScope; |
47 | 47 | $this->permissions = $permissions; |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | public function allows(string $permission, array $context = []): bool |
56 | 56 | { |
57 | 57 | $allows = false; |
58 | - foreach ($this->getRoles() as $role) { |
|
59 | - if (!$this->permissions->hasRole($role)) { |
|
58 | + foreach ($this->getRoles() as $role){ |
|
59 | + if (!$this->permissions->hasRole($role)){ |
|
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getActor(): ActorInterface |
105 | 105 | { |
106 | - if (!is_null($this->actor)) { |
|
106 | + if (!is_null($this->actor)){ |
|
107 | 107 | return $this->actor; |
108 | 108 | } |
109 | 109 | |
110 | - try { |
|
110 | + try{ |
|
111 | 111 | return $this->container->get(ActorInterface::class); |
112 | - } catch (NotFoundExceptionInterface $e) { |
|
112 | + }catch (NotFoundExceptionInterface $e){ |
|
113 | 113 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
114 | 114 | } |
115 | 115 | } |
@@ -55,8 +55,10 @@ discard block |
||
55 | 55 | public function allows(string $permission, array $context = []): bool |
56 | 56 | { |
57 | 57 | $allows = false; |
58 | - foreach ($this->getRoles() as $role) { |
|
59 | - if (!$this->permissions->hasRole($role)) { |
|
58 | + foreach ($this->getRoles() as $role) |
|
59 | + { |
|
60 | + if (!$this->permissions->hasRole($role)) |
|
61 | + { |
|
60 | 62 | continue; |
61 | 63 | } |
62 | 64 | |
@@ -103,13 +105,17 @@ discard block |
||
103 | 105 | */ |
104 | 106 | public function getActor(): ActorInterface |
105 | 107 | { |
106 | - if (!is_null($this->actor)) { |
|
108 | + if (!is_null($this->actor)) |
|
109 | + { |
|
107 | 110 | return $this->actor; |
108 | 111 | } |
109 | 112 | |
110 | - try { |
|
113 | + try |
|
114 | + { |
|
111 | 115 | return $this->container->get(ActorInterface::class); |
112 | - } catch (NotFoundExceptionInterface $e) { |
|
116 | + } |
|
117 | + catch (NotFoundExceptionInterface $e) |
|
118 | + { |
|
113 | 119 | throw new ScopeException('Unable to resolve Actor from the scope', $e->getCode(), $e); |
114 | 120 | } |
115 | 121 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function getActor(TokenInterface $token): ?object |
53 | 53 | { |
54 | - foreach ($this->getProviders() as $provider) { |
|
55 | - if (!$provider instanceof ActorProviderInterface) { |
|
54 | + foreach ($this->getProviders() as $provider){ |
|
55 | + if (!$provider instanceof ActorProviderInterface){ |
|
56 | 56 | throw new AuthException(sprintf( |
57 | 57 | 'Expected `ActorProviderInterface`, got `%s`', |
58 | 58 | get_class($provider) |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | $actor = $provider->getActor($token); |
63 | - if ($actor !== null) { |
|
63 | + if ($actor !== null){ |
|
64 | 64 | return $actor; |
65 | 65 | } |
66 | 66 | } |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | */ |
84 | 84 | private function getProviders(): \Generator |
85 | 85 | { |
86 | - foreach ($this->actorProvider as $provider) { |
|
87 | - if ($provider instanceof Autowire) { |
|
86 | + foreach ($this->actorProvider as $provider){ |
|
87 | + if ($provider instanceof Autowire){ |
|
88 | 88 | yield $provider->resolve($this->factory); |
89 | 89 | continue; |
90 | 90 | } |
91 | 91 | |
92 | - if (is_object($provider)) { |
|
92 | + if (is_object($provider)){ |
|
93 | 93 | yield $provider; |
94 | 94 | continue; |
95 | 95 | } |
@@ -51,8 +51,10 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function getActor(TokenInterface $token): ?object |
53 | 53 | { |
54 | - foreach ($this->getProviders() as $provider) { |
|
55 | - if (!$provider instanceof ActorProviderInterface) { |
|
54 | + foreach ($this->getProviders() as $provider) |
|
55 | + { |
|
56 | + if (!$provider instanceof ActorProviderInterface) |
|
57 | + { |
|
56 | 58 | throw new AuthException(sprintf( |
57 | 59 | 'Expected `ActorProviderInterface`, got `%s`', |
58 | 60 | get_class($provider) |
@@ -60,7 +62,8 @@ discard block |
||
60 | 62 | } |
61 | 63 | |
62 | 64 | $actor = $provider->getActor($token); |
63 | - if ($actor !== null) { |
|
65 | + if ($actor !== null) |
|
66 | + { |
|
64 | 67 | return $actor; |
65 | 68 | } |
66 | 69 | } |
@@ -83,13 +86,16 @@ discard block |
||
83 | 86 | */ |
84 | 87 | private function getProviders(): \Generator |
85 | 88 | { |
86 | - foreach ($this->actorProvider as $provider) { |
|
87 | - if ($provider instanceof Autowire) { |
|
89 | + foreach ($this->actorProvider as $provider) |
|
90 | + { |
|
91 | + if ($provider instanceof Autowire) |
|
92 | + { |
|
88 | 93 | yield $provider->resolve($this->factory); |
89 | 94 | continue; |
90 | 95 | } |
91 | 96 | |
92 | - if (is_object($provider)) { |
|
97 | + if (is_object($provider)) |
|
98 | + { |
|
93 | 99 | yield $provider; |
94 | 100 | continue; |
95 | 101 | } |
@@ -87,8 +87,8 @@ |
||
87 | 87 | $registry = new TransportRegistry(); |
88 | 88 | $registry->setDefaultTransport($config->getDefaultTransport()); |
89 | 89 | |
90 | - foreach ($config->getTransports() as $name => $transport) { |
|
91 | - if ($transport instanceof Autowire) { |
|
90 | + foreach ($config->getTransports() as $name => $transport){ |
|
91 | + if ($transport instanceof Autowire){ |
|
92 | 92 | $transport = $transport->resolve($factory); |
93 | 93 | } |
94 | 94 |
@@ -87,8 +87,10 @@ |
||
87 | 87 | $registry = new TransportRegistry(); |
88 | 88 | $registry->setDefaultTransport($config->getDefaultTransport()); |
89 | 89 | |
90 | - foreach ($config->getTransports() as $name => $transport) { |
|
91 | - if ($transport instanceof Autowire) { |
|
90 | + foreach ($config->getTransports() as $name => $transport) |
|
91 | + { |
|
92 | + if ($transport instanceof Autowire) |
|
93 | + { |
|
92 | 94 | $transport = $transport->resolve($factory); |
93 | 95 | } |
94 | 96 |