@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | FinalizerInterface $finalizer, |
| 50 | 50 | ContainerInterface $container, |
| 51 | 51 | FactoryInterface $factory |
| 52 | - ) { |
|
| 52 | + ){ |
|
| 53 | 53 | $this->env = $env; |
| 54 | 54 | $this->finalizer = $finalizer; |
| 55 | 55 | $this->container = $container; |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | /** @var Http $http */ |
| 77 | 77 | $http = $this->container->get(Http::class); |
| 78 | - while ($request = $client->acceptRequest()) { |
|
| 79 | - try { |
|
| 78 | + while ($request = $client->acceptRequest()){ |
|
| 79 | + try{ |
|
| 80 | 80 | $client->respond($http->handle($request)); |
| 81 | - } catch (\Throwable $e) { |
|
| 81 | + }catch (\Throwable $e){ |
|
| 82 | 82 | $this->handleException($client, $e); |
| 83 | - } finally { |
|
| 83 | + }finally{ |
|
| 84 | 84 | $this->finalizer->finalize(false); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -94,17 +94,17 @@ discard block |
||
| 94 | 94 | { |
| 95 | 95 | $handler = new HtmlHandler(); |
| 96 | 96 | |
| 97 | - try { |
|
| 97 | + try{ |
|
| 98 | 98 | /** @var SnapshotInterface $snapshot */ |
| 99 | 99 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
| 100 | 100 | error_log($snapshot->getMessage()); |
| 101 | 101 | |
| 102 | 102 | // on demand |
| 103 | 103 | $state = $this->container->get(StateInterface::class); |
| 104 | - if ($state !== null) { |
|
| 104 | + if ($state !== null){ |
|
| 105 | 105 | $handler = $handler->withState($state); |
| 106 | 106 | } |
| 107 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
| 107 | + }catch (\Throwable | ContainerExceptionInterface $se){ |
|
| 108 | 108 | error_log((string)$e); |
| 109 | 109 | } |
| 110 | 110 | |
@@ -75,12 +75,18 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | /** @var Http $http */ |
| 77 | 77 | $http = $this->container->get(Http::class); |
| 78 | - while ($request = $client->acceptRequest()) { |
|
| 79 | - try { |
|
| 78 | + while ($request = $client->acceptRequest()) |
|
| 79 | + { |
|
| 80 | + try |
|
| 81 | + { |
|
| 80 | 82 | $client->respond($http->handle($request)); |
| 81 | - } catch (\Throwable $e) { |
|
| 83 | + } |
|
| 84 | + catch (\Throwable $e) |
|
| 85 | + { |
|
| 82 | 86 | $this->handleException($client, $e); |
| 83 | - } finally { |
|
| 87 | + } |
|
| 88 | + finally |
|
| 89 | + { |
|
| 84 | 90 | $this->finalizer->finalize(false); |
| 85 | 91 | } |
| 86 | 92 | } |
@@ -94,17 +100,21 @@ discard block |
||
| 94 | 100 | { |
| 95 | 101 | $handler = new HtmlHandler(); |
| 96 | 102 | |
| 97 | - try { |
|
| 103 | + try |
|
| 104 | + { |
|
| 98 | 105 | /** @var SnapshotInterface $snapshot */ |
| 99 | 106 | $snapshot = $this->container->get(SnapshotterInterface::class)->register($e); |
| 100 | 107 | error_log($snapshot->getMessage()); |
| 101 | 108 | |
| 102 | 109 | // on demand |
| 103 | 110 | $state = $this->container->get(StateInterface::class); |
| 104 | - if ($state !== null) { |
|
| 111 | + if ($state !== null) |
|
| 112 | + { |
|
| 105 | 113 | $handler = $handler->withState($state); |
| 106 | 114 | } |
| 107 | - } catch (\Throwable | ContainerExceptionInterface $se) { |
|
| 115 | + } |
|
| 116 | + catch (\Throwable | ContainerExceptionInterface $se) |
|
| 117 | + { |
|
| 108 | 118 | error_log((string)$e); |
| 109 | 119 | } |
| 110 | 120 | |
@@ -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 | |
@@ -43,8 +43,8 @@ |
||
| 43 | 43 | { |
| 44 | 44 | $state->setTag('php', phpversion()); |
| 45 | 45 | |
| 46 | - if ($this->container->get(DispatcherInterface::class)) { |
|
| 47 | - switch (get_class($this->container->get(DispatcherInterface::class))) { |
|
| 46 | + if ($this->container->get(DispatcherInterface::class)){ |
|
| 47 | + switch (get_class($this->container->get(DispatcherInterface::class))){ |
|
| 48 | 48 | case RrDispacher::class: |
| 49 | 49 | $state->setTag('dispatcher', 'roadrunner'); |
| 50 | 50 | break; |
@@ -43,8 +43,10 @@ |
||
| 43 | 43 | { |
| 44 | 44 | $state->setTag('php', phpversion()); |
| 45 | 45 | |
| 46 | - if ($this->container->get(DispatcherInterface::class)) { |
|
| 47 | - switch (get_class($this->container->get(DispatcherInterface::class))) { |
|
| 46 | + if ($this->container->get(DispatcherInterface::class)) |
|
| 47 | + { |
|
| 48 | + switch (get_class($this->container->get(DispatcherInterface::class))) |
|
| 49 | + { |
|
| 48 | 50 | case RrDispacher::class: |
| 49 | 51 | $state->setTag('dispatcher', 'roadrunner'); |
| 50 | 52 | break; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function populate(StateInterface $state): void |
| 41 | 41 | { |
| 42 | - if (!$this->request === null) { |
|
| 42 | + if (!$this->request === null){ |
|
| 43 | 43 | return; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $state->setVariable('headers', $this->request->getHeaders()); |
| 50 | 50 | |
| 51 | - if ($this->request->getQueryParams() !== []) { |
|
| 51 | + if ($this->request->getQueryParams() !== []){ |
|
| 52 | 52 | $state->setVariable('query', $this->request->getQueryParams()); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ($this->request->getParsedBody() !== null) { |
|
| 55 | + if ($this->request->getParsedBody() !== null){ |
|
| 56 | 56 | $state->setVariable('data', $this->request->getParsedBody()); |
| 57 | 57 | } |
| 58 | 58 | } |
@@ -39,7 +39,8 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function populate(StateInterface $state): void |
| 41 | 41 | { |
| 42 | - if (!$this->request === null) { |
|
| 42 | + if (!$this->request === null) |
|
| 43 | + { |
|
| 43 | 44 | return; |
| 44 | 45 | } |
| 45 | 46 | |
@@ -48,11 +49,13 @@ discard block |
||
| 48 | 49 | |
| 49 | 50 | $state->setVariable('headers', $this->request->getHeaders()); |
| 50 | 51 | |
| 51 | - if ($this->request->getQueryParams() !== []) { |
|
| 52 | + if ($this->request->getQueryParams() !== []) |
|
| 53 | + { |
|
| 52 | 54 | $state->setVariable('query', $this->request->getQueryParams()); |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | - if ($this->request->getParsedBody() !== null) { |
|
| 57 | + if ($this->request->getParsedBody() !== null) |
|
| 58 | + { |
|
| 56 | 59 | $state->setVariable('data', $this->request->getParsedBody()); |
| 57 | 60 | } |
| 58 | 61 | } |
@@ -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 | |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | public function setUp(): void |
| 24 | 24 | { |
| 25 | 25 | exec('protoc 2>&1', $out); |
| 26 | - if (strpos(join("\n", $out), '--php_out') === false) { |
|
| 26 | + if (strpos(join("\n", $out), '--php_out') === false){ |
|
| 27 | 27 | $this->markTestSkipped('Protoc binary is missing'); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | parent::setUp(); |
| 31 | 31 | |
| 32 | 32 | $fs = new Files(); |
| 33 | - $proto = $fs->normalizePath($this->app->dir('app') . 'proto/service.proto'); |
|
| 33 | + $proto = $fs->normalizePath($this->app->dir('app').'proto/service.proto'); |
|
| 34 | 34 | |
| 35 | 35 | // protoc can't figure relative paths |
| 36 | 36 | $proto = str_replace('Framework/../', '', $proto); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | 'proto' => $proto |
| 40 | 40 | ]); |
| 41 | 41 | |
| 42 | - file_put_contents($this->app->dir('app') . 'src/Service/EchoService.php', GenerateTest::SERVICE); |
|
| 42 | + file_put_contents($this->app->dir('app').'src/Service/EchoService.php', GenerateTest::SERVICE); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function tearDown(): void |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $fs = new Files(); |
| 50 | 50 | |
| 51 | - if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) { |
|
| 52 | - $fs->deleteDirectory($this->app->dir('app') . 'src/Service'); |
|
| 51 | + if ($fs->isDirectory($this->app->dir('app').'src/Service')){ |
|
| 52 | + $fs->deleteDirectory($this->app->dir('app').'src/Service'); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) { |
|
| 56 | - $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata'); |
|
| 55 | + if ($fs->isDirectory($this->app->dir('app').'src/GPBMetadata')){ |
|
| 56 | + $fs->deleteDirectory($this->app->dir('app').'src/GPBMetadata'); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $msg->setMsg('hello'); |
| 80 | 80 | |
| 81 | 81 | $w->shouldReceive('receive')->once()->with( |
| 82 | - \Mockery::on(function (&$context) { |
|
| 82 | + \Mockery::on(function (&$context){ |
|
| 83 | 83 | $context = '{ |
| 84 | 84 | "service": "service.Echo", |
| 85 | 85 | "method": "Ping", |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | )->andReturn($msg->serializeToString()); |
| 92 | 92 | |
| 93 | 93 | $w->shouldReceive('send')->once()->with( |
| 94 | - \Mockery::on(function ($out) { |
|
| 94 | + \Mockery::on(function ($out){ |
|
| 95 | 95 | $msg = new Message(); |
| 96 | 96 | $msg->mergeFromString($out); |
| 97 | 97 | $this->assertSame('hello', $msg->getMsg()); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // one command only |
| 105 | 105 | $w->shouldReceive('receive')->once()->with( |
| 106 | - \Mockery::on(function (&$context) { |
|
| 106 | + \Mockery::on(function (&$context){ |
|
| 107 | 107 | $context = null; |
| 108 | 108 | return true; |
| 109 | 109 | }) |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $msg->setMsg('hello'); |
| 124 | 124 | |
| 125 | 125 | $w->shouldReceive('receive')->once()->with( |
| 126 | - \Mockery::on(function (&$context) { |
|
| 126 | + \Mockery::on(function (&$context){ |
|
| 127 | 127 | $context = '{ |
| 128 | 128 | "service": "service.Echo", |
| 129 | 129 | "method": "Invalid", |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | )->andReturn($msg->serializeToString()); |
| 136 | 136 | |
| 137 | 137 | $w->shouldReceive('error')->once()->with( |
| 138 | - \Mockery::on(function ($out) { |
|
| 138 | + \Mockery::on(function ($out){ |
|
| 139 | 139 | $this->assertContains('Method `Invalid` not found', $out); |
| 140 | 140 | return true; |
| 141 | 141 | }) |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | // one command only |
| 145 | 145 | $w->shouldReceive('receive')->once()->with( |
| 146 | - \Mockery::on(function (&$context) { |
|
| 146 | + \Mockery::on(function (&$context){ |
|
| 147 | 147 | $context = null; |
| 148 | 148 | return true; |
| 149 | 149 | }) |
@@ -23,7 +23,8 @@ discard block |
||
| 23 | 23 | public function setUp(): void |
| 24 | 24 | { |
| 25 | 25 | exec('protoc 2>&1', $out); |
| 26 | - if (strpos(join("\n", $out), '--php_out') === false) { |
|
| 26 | + if (strpos(join("\n", $out), '--php_out') === false) |
|
| 27 | + { |
|
| 27 | 28 | $this->markTestSkipped('Protoc binary is missing'); |
| 28 | 29 | } |
| 29 | 30 | |
@@ -48,11 +49,13 @@ discard block |
||
| 48 | 49 | |
| 49 | 50 | $fs = new Files(); |
| 50 | 51 | |
| 51 | - if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) { |
|
| 52 | + if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) |
|
| 53 | + { |
|
| 52 | 54 | $fs->deleteDirectory($this->app->dir('app') . 'src/Service'); |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | - if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) { |
|
| 57 | + if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) |
|
| 58 | + { |
|
| 56 | 59 | $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata'); |
| 57 | 60 | } |
| 58 | 61 | } |
@@ -79,7 +82,8 @@ discard block |
||
| 79 | 82 | $msg->setMsg('hello'); |
| 80 | 83 | |
| 81 | 84 | $w->shouldReceive('receive')->once()->with( |
| 82 | - \Mockery::on(function (&$context) { |
|
| 85 | + \Mockery::on(function (&$context) |
|
| 86 | + { |
|
| 83 | 87 | $context = '{ |
| 84 | 88 | "service": "service.Echo", |
| 85 | 89 | "method": "Ping", |
@@ -91,7 +95,8 @@ discard block |
||
| 91 | 95 | )->andReturn($msg->serializeToString()); |
| 92 | 96 | |
| 93 | 97 | $w->shouldReceive('send')->once()->with( |
| 94 | - \Mockery::on(function ($out) { |
|
| 98 | + \Mockery::on(function ($out) |
|
| 99 | + { |
|
| 95 | 100 | $msg = new Message(); |
| 96 | 101 | $msg->mergeFromString($out); |
| 97 | 102 | $this->assertSame('hello', $msg->getMsg()); |
@@ -103,7 +108,8 @@ discard block |
||
| 103 | 108 | |
| 104 | 109 | // one command only |
| 105 | 110 | $w->shouldReceive('receive')->once()->with( |
| 106 | - \Mockery::on(function (&$context) { |
|
| 111 | + \Mockery::on(function (&$context) |
|
| 112 | + { |
|
| 107 | 113 | $context = null; |
| 108 | 114 | return true; |
| 109 | 115 | }) |
@@ -123,7 +129,8 @@ discard block |
||
| 123 | 129 | $msg->setMsg('hello'); |
| 124 | 130 | |
| 125 | 131 | $w->shouldReceive('receive')->once()->with( |
| 126 | - \Mockery::on(function (&$context) { |
|
| 132 | + \Mockery::on(function (&$context) |
|
| 133 | + { |
|
| 127 | 134 | $context = '{ |
| 128 | 135 | "service": "service.Echo", |
| 129 | 136 | "method": "Invalid", |
@@ -135,7 +142,8 @@ discard block |
||
| 135 | 142 | )->andReturn($msg->serializeToString()); |
| 136 | 143 | |
| 137 | 144 | $w->shouldReceive('error')->once()->with( |
| 138 | - \Mockery::on(function ($out) { |
|
| 145 | + \Mockery::on(function ($out) |
|
| 146 | + { |
|
| 139 | 147 | $this->assertContains('Method `Invalid` not found', $out); |
| 140 | 148 | return true; |
| 141 | 149 | }) |
@@ -143,7 +151,8 @@ discard block |
||
| 143 | 151 | |
| 144 | 152 | // one command only |
| 145 | 153 | $w->shouldReceive('receive')->once()->with( |
| 146 | - \Mockery::on(function (&$context) { |
|
| 154 | + \Mockery::on(function (&$context) |
|
| 155 | + { |
|
| 147 | 156 | $context = null; |
| 148 | 157 | return true; |
| 149 | 158 | }) |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function testAllowServerAccess(): void |
| 40 | 40 | { |
| 41 | - $this->init(static function () { |
|
| 41 | + $this->init(static function (){ |
|
| 42 | 42 | return true; |
| 43 | 43 | }); |
| 44 | 44 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function testDenyServerAccess(): void |
| 52 | 52 | { |
| 53 | - $this->init(static function () { |
|
| 53 | + $this->init(static function (){ |
|
| 54 | 54 | return false; |
| 55 | 55 | }); |
| 56 | 56 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | public function testServerAccessWithDependency(): void |
| 64 | 64 | { |
| 65 | - $this->init(static function (ServerRequestInterface $request) { |
|
| 65 | + $this->init(static function (ServerRequestInterface $request){ |
|
| 66 | 66 | return $request instanceof ServerRequestInterface; |
| 67 | 67 | }); |
| 68 | 68 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | public function testTopicAccessOK(): void |
| 126 | 126 | { |
| 127 | - $this->init(null, function () { |
|
| 127 | + $this->init(null, function (){ |
|
| 128 | 128 | return true; |
| 129 | 129 | }); |
| 130 | 130 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | public function testTopicWildcardAccessFail(): void |
| 138 | 138 | { |
| 139 | - $this->init(null, function () { |
|
| 139 | + $this->init(null, function (){ |
|
| 140 | 140 | return true; |
| 141 | 141 | }); |
| 142 | 142 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $this->init( |
| 152 | 152 | null, |
| 153 | 153 | null, |
| 154 | - function () { |
|
| 154 | + function (){ |
|
| 155 | 155 | return true; |
| 156 | 156 | } |
| 157 | 157 | ); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | $this->init( |
| 168 | 168 | null, |
| 169 | 169 | null, |
| 170 | - function ($id) { |
|
| 170 | + function ($id){ |
|
| 171 | 171 | return $id === '1'; |
| 172 | 172 | } |
| 173 | 173 | ); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $this->init( |
| 184 | 184 | null, |
| 185 | 185 | null, |
| 186 | - function ($id) { |
|
| 186 | + function ($id){ |
|
| 187 | 187 | return $id === '1'; |
| 188 | 188 | } |
| 189 | 189 | ); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | 'CYCLE_AUTH' => true, |
| 205 | 205 | 'RR_BROADCAST_PATH' => '/ws/', |
| 206 | 206 | 'WS_SERVER_CALLBACK' => null, |
| 207 | - 'WS_TOPIC_CALLBACK' => function (AuthContextInterface $authContext) { |
|
| 207 | + 'WS_TOPIC_CALLBACK' => function (AuthContextInterface $authContext){ |
|
| 208 | 208 | return $authContext->getToken() !== null; |
| 209 | 209 | }, |
| 210 | 210 | 'WS_TOPIC_WILDCARD_CALLBACK' => null, |
@@ -38,7 +38,8 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function testAllowServerAccess(): void |
| 40 | 40 | { |
| 41 | - $this->init(static function () { |
|
| 41 | + $this->init(static function () |
|
| 42 | + { |
|
| 42 | 43 | return true; |
| 43 | 44 | }); |
| 44 | 45 | |
@@ -50,7 +51,8 @@ discard block |
||
| 50 | 51 | |
| 51 | 52 | public function testDenyServerAccess(): void |
| 52 | 53 | { |
| 53 | - $this->init(static function () { |
|
| 54 | + $this->init(static function () |
|
| 55 | + { |
|
| 54 | 56 | return false; |
| 55 | 57 | }); |
| 56 | 58 | |
@@ -62,7 +64,8 @@ discard block |
||
| 62 | 64 | |
| 63 | 65 | public function testServerAccessWithDependency(): void |
| 64 | 66 | { |
| 65 | - $this->init(static function (ServerRequestInterface $request) { |
|
| 67 | + $this->init(static function (ServerRequestInterface $request) |
|
| 68 | + { |
|
| 66 | 69 | return $request instanceof ServerRequestInterface; |
| 67 | 70 | }); |
| 68 | 71 | |
@@ -124,7 +127,8 @@ discard block |
||
| 124 | 127 | |
| 125 | 128 | public function testTopicAccessOK(): void |
| 126 | 129 | { |
| 127 | - $this->init(null, function () { |
|
| 130 | + $this->init(null, function () |
|
| 131 | + { |
|
| 128 | 132 | return true; |
| 129 | 133 | }); |
| 130 | 134 | |
@@ -136,7 +140,8 @@ discard block |
||
| 136 | 140 | |
| 137 | 141 | public function testTopicWildcardAccessFail(): void |
| 138 | 142 | { |
| 139 | - $this->init(null, function () { |
|
| 143 | + $this->init(null, function () |
|
| 144 | + { |
|
| 140 | 145 | return true; |
| 141 | 146 | }); |
| 142 | 147 | |
@@ -151,7 +156,8 @@ discard block |
||
| 151 | 156 | $this->init( |
| 152 | 157 | null, |
| 153 | 158 | null, |
| 154 | - function () { |
|
| 159 | + function () |
|
| 160 | + { |
|
| 155 | 161 | return true; |
| 156 | 162 | } |
| 157 | 163 | ); |
@@ -167,7 +173,8 @@ discard block |
||
| 167 | 173 | $this->init( |
| 168 | 174 | null, |
| 169 | 175 | null, |
| 170 | - function ($id) { |
|
| 176 | + function ($id) |
|
| 177 | + { |
|
| 171 | 178 | return $id === '1'; |
| 172 | 179 | } |
| 173 | 180 | ); |
@@ -183,7 +190,8 @@ discard block |
||
| 183 | 190 | $this->init( |
| 184 | 191 | null, |
| 185 | 192 | null, |
| 186 | - function ($id) { |
|
| 193 | + function ($id) |
|
| 194 | + { |
|
| 187 | 195 | return $id === '1'; |
| 188 | 196 | } |
| 189 | 197 | ); |
@@ -204,7 +212,8 @@ discard block |
||
| 204 | 212 | 'CYCLE_AUTH' => true, |
| 205 | 213 | 'RR_BROADCAST_PATH' => '/ws/', |
| 206 | 214 | 'WS_SERVER_CALLBACK' => null, |
| 207 | - 'WS_TOPIC_CALLBACK' => function (AuthContextInterface $authContext) { |
|
| 215 | + 'WS_TOPIC_CALLBACK' => function (AuthContextInterface $authContext) |
|
| 216 | + { |
|
| 208 | 217 | return $authContext->getToken() !== null; |
| 209 | 218 | }, |
| 210 | 219 | 'WS_TOPIC_WILDCARD_CALLBACK' => null, |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | array $headers = [] |
| 46 | 46 | ): ResponseInterface { |
| 47 | 47 | $r = $this->request($uri, 'GET', [], $headers, []); |
| 48 | - foreach ($attributes as $k => $v) { |
|
| 48 | + foreach ($attributes as $k => $v){ |
|
| 49 | 49 | $r = $r->withAttribute($k, $v); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | protected function fetchCookies(array $header) |
| 87 | 87 | { |
| 88 | 88 | $result = []; |
| 89 | - foreach ($header as $line) { |
|
| 89 | + foreach ($header as $line){ |
|
| 90 | 90 | $cookie = explode('=', $line); |
| 91 | 91 | $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';'))); |
| 92 | 92 | } |
@@ -45,7 +45,8 @@ discard block |
||
| 45 | 45 | array $headers = [] |
| 46 | 46 | ): ResponseInterface { |
| 47 | 47 | $r = $this->request($uri, 'GET', [], $headers, []); |
| 48 | - foreach ($attributes as $k => $v) { |
|
| 48 | + foreach ($attributes as $k => $v) |
|
| 49 | + { |
|
| 49 | 50 | $r = $r->withAttribute($k, $v); |
| 50 | 51 | } |
| 51 | 52 | |
@@ -86,7 +87,8 @@ discard block |
||
| 86 | 87 | protected function fetchCookies(array $header) |
| 87 | 88 | { |
| 88 | 89 | $result = []; |
| 89 | - foreach ($header as $line) { |
|
| 90 | + foreach ($header as $line) |
|
| 91 | + { |
|
| 90 | 92 | $cookie = explode('=', $line); |
| 91 | 93 | $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';'))); |
| 92 | 94 | } |