@@ -48,7 +48,7 @@ |
||
48 | 48 | |
49 | 49 | public function input(InputScope $i) |
50 | 50 | { |
51 | - return 'value: ' . $i->withPrefix('section')->getValue('query', 'value'); |
|
51 | + return 'value: '.$i->withPrefix('section')->getValue('query', 'value'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function error(): void |
@@ -38,7 +38,7 @@ |
||
38 | 38 | { |
39 | 39 | $core = new InterceptableCore($core); |
40 | 40 | |
41 | - foreach (static::INTERCEPTORS as $interceptor) { |
|
41 | + foreach (static::INTERCEPTORS as $interceptor){ |
|
42 | 42 | $core->addInterceptor($container->get($interceptor)); |
43 | 43 | } |
44 | 44 |
@@ -38,7 +38,8 @@ |
||
38 | 38 | { |
39 | 39 | $core = new InterceptableCore($core); |
40 | 40 | |
41 | - foreach (static::INTERCEPTORS as $interceptor) { |
|
41 | + foreach (static::INTERCEPTORS as $interceptor) |
|
42 | + { |
|
42 | 43 | $core->addInterceptor($container->get($interceptor)); |
43 | 44 | } |
44 | 45 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function testHasCookie(): void |
38 | 38 | { |
39 | - $this->http->setHandler(function () { |
|
39 | + $this->http->setHandler(function (){ |
|
40 | 40 | return (int)$this->cookies()->has('a'); |
41 | 41 | }); |
42 | 42 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | ]); |
55 | 55 | $this->http = $this->app->get(Http::class); |
56 | 56 | |
57 | - $this->http->setHandler(function () { |
|
57 | + $this->http->setHandler(function (){ |
|
58 | 58 | return (int)$this->cookies()->has('a'); |
59 | 59 | }); |
60 | 60 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
72 | 72 | $this->http = $this->app->get(Http::class); |
73 | 73 | |
74 | - $this->http->setHandler(function () { |
|
74 | + $this->http->setHandler(function (){ |
|
75 | 75 | return $this->cookies()->get('a'); |
76 | 76 | }); |
77 | 77 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
89 | 89 | $this->http = $this->app->get(Http::class); |
90 | 90 | |
91 | - $this->http->setHandler(function () { |
|
91 | + $this->http->setHandler(function (){ |
|
92 | 92 | $this->cookies()->set('a', 'value'); |
93 | 93 | |
94 | 94 | return 'ok'; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
113 | 113 | $this->http = $this->app->get(Http::class); |
114 | 114 | |
115 | - $this->http->setHandler(function () { |
|
115 | + $this->http->setHandler(function (){ |
|
116 | 116 | $this->cookies()->schedule(Cookie::create('a', 'value')); |
117 | 117 | $this->assertSame([], $this->cookies()->getAll()); |
118 | 118 | $this->assertCount(1, $this->cookies()->getScheduled()); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
139 | 139 | $this->http = $this->app->get(Http::class); |
140 | 140 | |
141 | - $this->http->setHandler(function () { |
|
141 | + $this->http->setHandler(function (){ |
|
142 | 142 | $this->cookies()->delete('cookie'); |
143 | 143 | |
144 | 144 | return 'ok'; |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | |
37 | 37 | public function testHasCookie(): void |
38 | 38 | { |
39 | - $this->http->setHandler(function () { |
|
39 | + $this->http->setHandler(function () |
|
40 | + { |
|
40 | 41 | return (int)$this->cookies()->has('a'); |
41 | 42 | }); |
42 | 43 | |
@@ -54,7 +55,8 @@ discard block |
||
54 | 55 | ]); |
55 | 56 | $this->http = $this->app->get(Http::class); |
56 | 57 | |
57 | - $this->http->setHandler(function () { |
|
58 | + $this->http->setHandler(function () |
|
59 | + { |
|
58 | 60 | return (int)$this->cookies()->has('a'); |
59 | 61 | }); |
60 | 62 | |
@@ -71,7 +73,8 @@ discard block |
||
71 | 73 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
72 | 74 | $this->http = $this->app->get(Http::class); |
73 | 75 | |
74 | - $this->http->setHandler(function () { |
|
76 | + $this->http->setHandler(function () |
|
77 | + { |
|
75 | 78 | return $this->cookies()->get('a'); |
76 | 79 | }); |
77 | 80 | |
@@ -88,7 +91,8 @@ discard block |
||
88 | 91 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
89 | 92 | $this->http = $this->app->get(Http::class); |
90 | 93 | |
91 | - $this->http->setHandler(function () { |
|
94 | + $this->http->setHandler(function () |
|
95 | + { |
|
92 | 96 | $this->cookies()->set('a', 'value'); |
93 | 97 | |
94 | 98 | return 'ok'; |
@@ -112,7 +116,8 @@ discard block |
||
112 | 116 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
113 | 117 | $this->http = $this->app->get(Http::class); |
114 | 118 | |
115 | - $this->http->setHandler(function () { |
|
119 | + $this->http->setHandler(function () |
|
120 | + { |
|
116 | 121 | $this->cookies()->schedule(Cookie::create('a', 'value')); |
117 | 122 | $this->assertSame([], $this->cookies()->getAll()); |
118 | 123 | $this->assertCount(1, $this->cookies()->getScheduled()); |
@@ -138,7 +143,8 @@ discard block |
||
138 | 143 | $this->app = $this->makeApp(['ENCRYPTER_KEY' => $key]); |
139 | 144 | $this->http = $this->app->get(Http::class); |
140 | 145 | |
141 | - $this->http->setHandler(function () { |
|
146 | + $this->http->setHandler(function () |
|
147 | + { |
|
142 | 148 | $this->cookies()->delete('cookie'); |
143 | 149 | |
144 | 150 | return 'ok'; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | public function do(GuardInterface $guard) |
30 | 30 | { |
31 | - if (!$guard->allows('do')) { |
|
31 | + if (!$guard->allows('do')){ |
|
32 | 32 | throw new ControllerException("Unauthorized permission 'do'", ControllerException::FORBIDDEN); |
33 | 33 | } |
34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function token(AuthContextInterface $authContext) |
39 | 39 | { |
40 | - if ($authContext->getToken() !== null) { |
|
40 | + if ($authContext->getToken() !== null){ |
|
41 | 41 | return $authContext->getToken()->getID(); |
42 | 42 | } |
43 | 43 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | public function token2() |
57 | 57 | { |
58 | - if ($this->auth->getToken() !== null) { |
|
58 | + if ($this->auth->getToken() !== null){ |
|
59 | 59 | return $this->auth->getToken()->getID(); |
60 | 60 | } |
61 | 61 |
@@ -26,10 +26,12 @@ discard block |
||
26 | 26 | $this->auth = $auth; |
27 | 27 | } |
28 | 28 | |
29 | - public function do(GuardInterface $guard) |
|
29 | + public function do{ |
|
30 | + (GuardInterface $guard) |
|
30 | 31 | { |
31 | 32 | if (!$guard->allows('do')) { |
32 | 33 | throw new ControllerException("Unauthorized permission 'do'", ControllerException::FORBIDDEN); |
34 | + } |
|
33 | 35 | } |
34 | 36 | |
35 | 37 | return 'ok'; |
@@ -37,7 +39,8 @@ discard block |
||
37 | 39 | |
38 | 40 | public function token(AuthContextInterface $authContext) |
39 | 41 | { |
40 | - if ($authContext->getToken() !== null) { |
|
42 | + if ($authContext->getToken() !== null) |
|
43 | + { |
|
41 | 44 | return $authContext->getToken()->getID(); |
42 | 45 | } |
43 | 46 | |
@@ -55,7 +58,8 @@ discard block |
||
55 | 58 | |
56 | 59 | public function token2() |
57 | 60 | { |
58 | - if ($this->auth->getToken() !== null) { |
|
61 | + if ($this->auth->getToken() !== null) |
|
62 | + { |
|
59 | 63 | return $this->auth->getToken()->getID(); |
60 | 64 | } |
61 | 65 |
@@ -40,8 +40,10 @@ |
||
40 | 40 | * @Guarded("do") |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - public function do() |
|
43 | + public function do{ |
|
44 | + () |
|
44 | 45 | { |
45 | 46 | return 'ok'; |
46 | 47 | } |
48 | + } |
|
47 | 49 | } |
@@ -43,7 +43,8 @@ discard block |
||
43 | 43 | ); |
44 | 44 | |
45 | 45 | $psr->shouldReceive('respond')->once()->with( |
46 | - \Mockery::on(function ($r) { |
|
46 | + \Mockery::on(function ($r) |
|
47 | + { |
|
47 | 48 | $this->assertSame('Hello, dave.', (string)$r->getBody()); |
48 | 49 | return true; |
49 | 50 | }) |
@@ -65,7 +66,8 @@ discard block |
||
65 | 66 | ); |
66 | 67 | |
67 | 68 | $psr->shouldReceive('respond')->once()->with( |
68 | - \Mockery::on(function ($r) { |
|
69 | + \Mockery::on(function ($r) |
|
70 | + { |
|
69 | 71 | $this->assertContains('500', (string)$r->getBody()); |
70 | 72 | return true; |
71 | 73 | }) |
@@ -103,7 +105,8 @@ discard block |
||
103 | 105 | ); |
104 | 106 | |
105 | 107 | $psr->shouldReceive('respond')->once()->with( |
106 | - \Mockery::on(function ($r) { |
|
108 | + \Mockery::on(function ($r) |
|
109 | + { |
|
107 | 110 | $this->assertContains('undefined', (string)$r->getBody()); |
108 | 111 | return true; |
109 | 112 | }) |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ); |
44 | 44 | |
45 | 45 | $psr->shouldReceive('respond')->once()->with( |
46 | - \Mockery::on(function ($r) { |
|
46 | + \Mockery::on(function ($r){ |
|
47 | 47 | $this->assertSame('Hello, dave.', (string)$r->getBody()); |
48 | 48 | return true; |
49 | 49 | }) |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ); |
66 | 66 | |
67 | 67 | $psr->shouldReceive('respond')->once()->with( |
68 | - \Mockery::on(function ($r) { |
|
68 | + \Mockery::on(function ($r){ |
|
69 | 69 | $this->assertContains('500', (string)$r->getBody()); |
70 | 70 | return true; |
71 | 71 | }) |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $psr->shouldReceive('acceptRequest')->once()->andReturn(null); |
75 | 75 | |
76 | 76 | $files = $this->app->get(FilesInterface::class)->getFiles( |
77 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
77 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | $this->assertCount(0, $files); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $this->app->get(RrDispatcher::class)->serve($psr); |
83 | 83 | |
84 | 84 | $files = $this->app->get(FilesInterface::class)->getFiles( |
85 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
85 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | $this->assertCount(1, $files); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ); |
104 | 104 | |
105 | 105 | $psr->shouldReceive('respond')->once()->with( |
106 | - \Mockery::on(function ($r) { |
|
106 | + \Mockery::on(function ($r){ |
|
107 | 107 | $this->assertContains('undefined', (string)$r->getBody()); |
108 | 108 | return true; |
109 | 109 | }) |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $psr->shouldReceive('acceptRequest')->once()->andReturn(null); |
113 | 113 | |
114 | 114 | $files = $this->app->get(FilesInterface::class)->getFiles( |
115 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
115 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
116 | 116 | ); |
117 | 117 | |
118 | 118 | $this->assertCount(0, $files); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $this->app->get(RrDispatcher::class)->serve($psr); |
121 | 121 | |
122 | 122 | $files = $this->app->get(FilesInterface::class)->getFiles( |
123 | - $this->app->get(DirectoriesInterface::class)->get('runtime') . '/snapshots/' |
|
123 | + $this->app->get(DirectoriesInterface::class)->get('runtime').'/snapshots/' |
|
124 | 124 | ); |
125 | 125 | |
126 | 126 | $this->assertCount(1, $files); |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | $http = $this->container->get(Http::class); |
63 | 63 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
64 | 64 | |
65 | - try { |
|
65 | + try{ |
|
66 | 66 | $response = $http->handle($this->initRequest()); |
67 | 67 | $emitter->emit($response); |
68 | - } catch (\Throwable $e) { |
|
68 | + }catch (\Throwable $e){ |
|
69 | 69 | $this->handleException($emitter, $e); |
70 | - } finally { |
|
70 | + }finally{ |
|
71 | 71 | $this->finalizer->finalize(false); |
72 | 72 | } |
73 | 73 | } |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | { |
89 | 89 | $handler = new HtmlHandler(); |
90 | 90 | |
91 | - try { |
|
91 | + try{ |
|
92 | 92 | /** @var SnapshotInterface $snapshot */ |
93 | 93 | $this->container->get(SnapshotterInterface::class)->register($e); |
94 | 94 | |
95 | 95 | // on demand |
96 | 96 | $state = $this->container->get(StateInterface::class); |
97 | - if ($state !== null) { |
|
97 | + if ($state !== null){ |
|
98 | 98 | $handler = $handler->withState($state); |
99 | 99 | } |
100 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
100 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
101 | 101 | // nothing to report |
102 | 102 | } |
103 | 103 |
@@ -62,12 +62,17 @@ discard block |
||
62 | 62 | $http = $this->container->get(Http::class); |
63 | 63 | $emitter = $emitter ?? $this->container->get(EmitterInterface::class); |
64 | 64 | |
65 | - try { |
|
65 | + try |
|
66 | + { |
|
66 | 67 | $response = $http->handle($this->initRequest()); |
67 | 68 | $emitter->emit($response); |
68 | - } catch (\Throwable $e) { |
|
69 | + } |
|
70 | + catch (\Throwable $e) |
|
71 | + { |
|
69 | 72 | $this->handleException($emitter, $e); |
70 | - } finally { |
|
73 | + } |
|
74 | + finally |
|
75 | + { |
|
71 | 76 | $this->finalizer->finalize(false); |
72 | 77 | } |
73 | 78 | } |
@@ -88,16 +93,20 @@ discard block |
||
88 | 93 | { |
89 | 94 | $handler = new HtmlHandler(); |
90 | 95 | |
91 | - try { |
|
96 | + try |
|
97 | + { |
|
92 | 98 | /** @var SnapshotInterface $snapshot */ |
93 | 99 | $this->container->get(SnapshotterInterface::class)->register($e); |
94 | 100 | |
95 | 101 | // on demand |
96 | 102 | $state = $this->container->get(StateInterface::class); |
97 | - if ($state !== null) { |
|
103 | + if ($state !== null) |
|
104 | + { |
|
98 | 105 | $handler = $handler->withState($state); |
99 | 106 | } |
100 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
107 | + } |
|
108 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
109 | + { |
|
101 | 110 | // nothing to report |
102 | 111 | } |
103 | 112 |
@@ -46,9 +46,9 @@ |
||
46 | 46 | DirectoriesInterface $dirs, |
47 | 47 | FilesInterface $files, |
48 | 48 | LoggerInterface $logger = null |
49 | - ) { |
|
49 | + ){ |
|
50 | 50 | return new FileSnapshooter( |
51 | - $dirs->get('runtime') . '/snapshots/', |
|
51 | + $dirs->get('runtime').'/snapshots/', |
|
52 | 52 | $env->get('SNAPSHOT_MAX_FILES', self::MAX_SNAPSHOTS), |
53 | 53 | $env->get('SNAPSHOT_VERBOSITY', HandlerInterface::VERBOSITY_VERBOSE), |
54 | 54 | new PlainHandler(), |
@@ -40,9 +40,9 @@ |
||
40 | 40 | public function renderException(Request $request, int $code, string $message): Response |
41 | 41 | { |
42 | 42 | $response = $this->responseFactory->createResponse($code); |
43 | - if ($request->getHeaderLine('Accept') == 'application/json') { |
|
43 | + if ($request->getHeaderLine('Accept') == 'application/json'){ |
|
44 | 44 | $response->getBody()->write(json_encode(['status' => $code, 'error' => $message])); |
45 | - } else { |
|
45 | + }else{ |
|
46 | 46 | $response->getBody()->write("Error code: {$code}"); |
47 | 47 | } |
48 | 48 |
@@ -40,9 +40,12 @@ |
||
40 | 40 | public function renderException(Request $request, int $code, string $message): Response |
41 | 41 | { |
42 | 42 | $response = $this->responseFactory->createResponse($code); |
43 | - if ($request->getHeaderLine('Accept') == 'application/json') { |
|
43 | + if ($request->getHeaderLine('Accept') == 'application/json') |
|
44 | + { |
|
44 | 45 | $response->getBody()->write(json_encode(['status' => $code, 'error' => $message])); |
45 | - } else { |
|
46 | + } |
|
47 | + else |
|
48 | + { |
|
46 | 49 | $response->getBody()->write("Error code: {$code}"); |
47 | 50 | } |
48 | 51 |