Passed
Pull Request — master (#225)
by Anton
02:54
created
src/Broadcast/Middleware/WebsocketsMiddleware.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         ScopeInterface $scope,
51 51
         ResolverInterface $resolver,
52 52
         ResponseFactoryInterface $responseFactory
53
-    ) {
53
+    ){
54 54
         $this->config = $config;
55 55
         $this->scope = $scope;
56 56
         $this->resolver = $resolver;
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
68 68
     {
69
-        if ($request->getUri()->getPath() !== $this->config->getPath()) {
69
+        if ($request->getUri()->getPath() !== $this->config->getPath()){
70 70
             return $handler->handle($request);
71 71
         }
72 72
 
73 73
         // server authorization
74
-        if ($request->getAttribute('ws:joinServer', null) !== null) {
75
-            if (!$this->authorizeServer($request)) {
74
+        if ($request->getAttribute('ws:joinServer', null) !== null){
75
+            if (!$this->authorizeServer($request)){
76 76
                 return $this->responseFactory->createResponse(403);
77 77
             }
78 78
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         }
81 81
 
82 82
         // topic authorization
83
-        if (is_string($request->getAttribute('ws:joinTopics', null))) {
83
+        if (is_string($request->getAttribute('ws:joinTopics', null))){
84 84
             $topics = explode(',', $request->getAttribute('ws:joinTopics'));
85
-            if (!$this->authorizeTopics($request, $topics)) {
85
+            if (!$this->authorizeTopics($request, $topics)){
86 86
                 return $this->responseFactory->createResponse(403);
87 87
             }
88 88
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     private function authorizeServer(ServerRequestInterface $request): bool
102 102
     {
103 103
         $callback = $this->config->getServerCallback();
104
-        if ($callback === null) {
104
+        if ($callback === null){
105 105
             return true;
106 106
         }
107 107
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     private function authorizeTopics(ServerRequestInterface $request, array $topics): bool
117 117
     {
118
-        foreach ($topics as $topic) {
118
+        foreach ($topics as $topic){
119 119
             // todo: match
120 120
             return false;
121 121
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     {
134 134
         /** @var \ReflectionFunctionAbstract $call */
135 135
         $call = null;
136
-        switch (true) {
136
+        switch (true){
137 137
             case $callback instanceof \Closure || is_string($callback):
138 138
                 $call = new \ReflectionFunction($callback);
139 139
                 break;
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -66,13 +66,16 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
68 68
     {
69
-        if ($request->getUri()->getPath() !== $this->config->getPath()) {
69
+        if ($request->getUri()->getPath() !== $this->config->getPath())
70
+        {
70 71
             return $handler->handle($request);
71 72
         }
72 73
 
73 74
         // server authorization
74
-        if ($request->getAttribute('ws:joinServer', null) !== null) {
75
-            if (!$this->authorizeServer($request)) {
75
+        if ($request->getAttribute('ws:joinServer', null) !== null)
76
+        {
77
+            if (!$this->authorizeServer($request))
78
+            {
76 79
                 return $this->responseFactory->createResponse(403);
77 80
             }
78 81
 
@@ -80,9 +83,11 @@  discard block
 block discarded – undo
80 83
         }
81 84
 
82 85
         // topic authorization
83
-        if (is_string($request->getAttribute('ws:joinTopics', null))) {
86
+        if (is_string($request->getAttribute('ws:joinTopics', null)))
87
+        {
84 88
             $topics = explode(',', $request->getAttribute('ws:joinTopics'));
85
-            if (!$this->authorizeTopics($request, $topics)) {
89
+            if (!$this->authorizeTopics($request, $topics))
90
+            {
86 91
                 return $this->responseFactory->createResponse(403);
87 92
             }
88 93
 
@@ -101,7 +106,8 @@  discard block
 block discarded – undo
101 106
     private function authorizeServer(ServerRequestInterface $request): bool
102 107
     {
103 108
         $callback = $this->config->getServerCallback();
104
-        if ($callback === null) {
109
+        if ($callback === null)
110
+        {
105 111
             return true;
106 112
         }
107 113
 
@@ -115,7 +121,8 @@  discard block
 block discarded – undo
115 121
      */
116 122
     private function authorizeTopics(ServerRequestInterface $request, array $topics): bool
117 123
     {
118
-        foreach ($topics as $topic) {
124
+        foreach ($topics as $topic)
125
+        {
119 126
             // todo: match
120 127
             return false;
121 128
         }
@@ -133,7 +140,8 @@  discard block
 block discarded – undo
133 140
     {
134 141
         /** @var \ReflectionFunctionAbstract $call */
135 142
         $call = null;
136
-        switch (true) {
143
+        switch (true)
144
+        {
137 145
             case $callback instanceof \Closure || is_string($callback):
138 146
                 $call = new \ReflectionFunction($callback);
139 147
                 break;
@@ -151,7 +159,8 @@  discard block
 block discarded – undo
151 159
             [
152 160
                 ServerRequestInterface::class => $request
153 161
             ],
154
-            function () use ($call, $parameters) {
162
+            function () use ($call, $parameters)
163
+            {
155 164
                 $arguments = $this->resolver->resolveArguments($call, $parameters);
156 165
                 return $call->invokeArgs($arguments);
157 166
             }
Please login to merge, or discard this patch.
src/Bootloader/Http/WebsocketsBootloader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@
 block discarded – undo
49 49
     {
50 50
         $this->config->setDefaults('websockets', [
51 51
             'path'            => $env->get('RR_BROADCAST_PATH', null),
52
-            'authorizeServer' => static function () {
52
+            'authorizeServer' => static function (){
53 53
                 return true;
54 54
             },
55 55
             'authorizeTopics' => []
56 56
         ]);
57 57
 
58
-        if ($env->get('RR_BROADCAST_PATH', null) !== null) {
58
+        if ($env->get('RR_BROADCAST_PATH', null) !== null){
59 59
             $http->addMiddleware(WebsocketsMiddleware::class);
60 60
         }
61 61
     }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,13 +49,15 @@
 block discarded – undo
49 49
     {
50 50
         $this->config->setDefaults('websockets', [
51 51
             'path'            => $env->get('RR_BROADCAST_PATH', null),
52
-            'authorizeServer' => static function () {
52
+            'authorizeServer' => static function ()
53
+            {
53 54
                 return true;
54 55
             },
55 56
             'authorizeTopics' => []
56 57
         ]);
57 58
 
58
-        if ($env->get('RR_BROADCAST_PATH', null) !== null) {
59
+        if ($env->get('RR_BROADCAST_PATH', null) !== null)
60
+        {
59 61
             $http->addMiddleware(WebsocketsMiddleware::class);
60 62
         }
61 63
     }
Please login to merge, or discard this patch.
tests/Framework/Http/WebsocketsTest.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
     public function testAllowServerAccess(): void
37 37
     {
38
-        $this->init(static function () {
38
+        $this->init(static function (){
39 39
             return true;
40 40
         });
41 41
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
     public function testDenyServerAccess(): void
49 49
     {
50
-        $this->init(static function () {
50
+        $this->init(static function (){
51 51
             return false;
52 52
         });
53 53
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
     public function testServerAccessWithDependency(): void
61 61
     {
62
-        $this->init(static function (ServerRequestInterface $request) {
62
+        $this->init(static function (ServerRequestInterface $request){
63 63
             return $request instanceof ServerRequestInterface;
64 64
         });
65 65
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,7 +35,8 @@  discard block
 block discarded – undo
35 35
 
36 36
     public function testAllowServerAccess(): void
37 37
     {
38
-        $this->init(static function () {
38
+        $this->init(static function ()
39
+        {
39 40
             return true;
40 41
         });
41 42
 
@@ -47,7 +48,8 @@  discard block
 block discarded – undo
47 48
 
48 49
     public function testDenyServerAccess(): void
49 50
     {
50
-        $this->init(static function () {
51
+        $this->init(static function ()
52
+        {
51 53
             return false;
52 54
         });
53 55
 
@@ -59,7 +61,8 @@  discard block
 block discarded – undo
59 61
 
60 62
     public function testServerAccessWithDependency(): void
61 63
     {
62
-        $this->init(static function (ServerRequestInterface $request) {
64
+        $this->init(static function (ServerRequestInterface $request)
65
+        {
63 66
             return $request instanceof ServerRequestInterface;
64 67
         });
65 68
 
Please login to merge, or discard this patch.
tests/Framework/GRPC/DispatcherTest.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             })
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
             })
Please login to merge, or discard this patch.
tests/Framework/HttpTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         array $attributes
45 45
     ): ResponseInterface {
46 46
         $r = $this->request($uri, 'GET', [], [], []);
47
-        foreach ($attributes as $k => $v) {
47
+        foreach ($attributes as $k => $v){
48 48
             $r = $r->withAttribute($k, $v);
49 49
         }
50 50
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     protected function fetchCookies(array $header)
86 86
     {
87 87
         $result = [];
88
-        foreach ($header as $line) {
88
+        foreach ($header as $line){
89 89
             $cookie = explode('=', $line);
90 90
             $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';')));
91 91
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,8 @@  discard block
 block discarded – undo
44 44
         array $attributes
45 45
     ): ResponseInterface {
46 46
         $r = $this->request($uri, 'GET', [], [], []);
47
-        foreach ($attributes as $k => $v) {
47
+        foreach ($attributes as $k => $v)
48
+        {
48 49
             $r = $r->withAttribute($k, $v);
49 50
         }
50 51
 
@@ -85,7 +86,8 @@  discard block
 block discarded – undo
85 86
     protected function fetchCookies(array $header)
86 87
     {
87 88
         $result = [];
88
-        foreach ($header as $line) {
89
+        foreach ($header as $line)
90
+        {
89 91
             $cookie = explode('=', $line);
90 92
             $result[$cookie[0]] = rawurldecode(substr($cookie[1], 0, strpos($cookie[1], ';')));
91 93
         }
Please login to merge, or discard this patch.
tests/app/src/Bootloader/WSBootloader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,17 +21,17 @@
 block discarded – undo
21 21
 
22 22
     public function boot(WebsocketsBootloader $ws, EnvironmentInterface $env): void
23 23
     {
24
-        if ($env->get('RR_BROADCAST_PATH') === null) {
24
+        if ($env->get('RR_BROADCAST_PATH') === null){
25 25
             return;
26 26
         }
27 27
 
28 28
         $ws->setServerCallback($env->get('WS_SERVER_CALLBACK'));
29 29
 
30
-        if ($env->get('WS_TOPIC_CALLBACK') !== null) {
30
+        if ($env->get('WS_TOPIC_CALLBACK') !== null){
31 31
             $ws->addTopicCallback('topic', $env->get('WS_TOPIC_CALLBACK'));
32 32
         }
33 33
 
34
-        if ($env->get('WS_TOPIC_WILDCARD_CALLBACK') !== null) {
34
+        if ($env->get('WS_TOPIC_WILDCARD_CALLBACK') !== null){
35 35
             $ws->addTopicCallback('wildcard.{id}', $env->get('WS_TOPIC_WILDCARD_CALLBACK'));
36 36
         }
37 37
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,17 +21,20 @@
 block discarded – undo
21 21
 
22 22
     public function boot(WebsocketsBootloader $ws, EnvironmentInterface $env): void
23 23
     {
24
-        if ($env->get('RR_BROADCAST_PATH') === null) {
24
+        if ($env->get('RR_BROADCAST_PATH') === null)
25
+        {
25 26
             return;
26 27
         }
27 28
 
28 29
         $ws->setServerCallback($env->get('WS_SERVER_CALLBACK'));
29 30
 
30
-        if ($env->get('WS_TOPIC_CALLBACK') !== null) {
31
+        if ($env->get('WS_TOPIC_CALLBACK') !== null)
32
+        {
31 33
             $ws->addTopicCallback('topic', $env->get('WS_TOPIC_CALLBACK'));
32 34
         }
33 35
 
34
-        if ($env->get('WS_TOPIC_WILDCARD_CALLBACK') !== null) {
36
+        if ($env->get('WS_TOPIC_WILDCARD_CALLBACK') !== null)
37
+        {
35 38
             $ws->addTopicCallback('wildcard.{id}', $env->get('WS_TOPIC_WILDCARD_CALLBACK'));
36 39
         }
37 40
     }
Please login to merge, or discard this patch.