Passed
Pull Request — master (#225)
by Anton
02:54
created
src/Broadcast/Middleware/WebsocketsMiddleware.php 1 patch
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.
src/Bootloader/Http/WebsocketsBootloader.php 1 patch
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.
tests/Framework/Http/WebsocketsTest.php 1 patch
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.
tests/Framework/GRPC/DispatcherTest.php 1 patch
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.
tests/Framework/HttpTest.php 1 patch
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.
tests/app/src/Bootloader/WSBootloader.php 1 patch
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.