Passed
Pull Request — master (#225)
by Anton
02:31
created
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/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.
src/Bootloader/Http/WebsocketsBootloader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
             'authorizeTopics' => []
54 54
         ]);
55 55
 
56
-        if ($env->get('RR_BROADCAST_PATH', null) !== null) {
56
+        if ($env->get('RR_BROADCAST_PATH', null) !== null){
57 57
             $http->addMiddleware(WebsocketsMiddleware::class);
58 58
         }
59 59
     }
Please login to merge, or discard this patch.
tests/Framework/Http/WebsocketsTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,
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
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Broadcast/Middleware/WebsocketsMiddleware.php 1 patch
Spacing   +10 added lines, -10 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;
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
69 69
     {
70
-        if ($request->getUri()->getPath() !== $this->config->getPath()) {
70
+        if ($request->getUri()->getPath() !== $this->config->getPath()){
71 71
             return $handler->handle($request);
72 72
         }
73 73
 
74 74
         // server authorization
75
-        if ($request->getAttribute('ws:joinServer', null) !== null) {
76
-            if (!$this->authorizeServer($request)) {
75
+        if ($request->getAttribute('ws:joinServer', null) !== null){
76
+            if (!$this->authorizeServer($request)){
77 77
                 return $this->responseFactory->createResponse(403);
78 78
             }
79 79
 
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
         }
82 82
 
83 83
         // topic authorization
84
-        if (is_string($request->getAttribute('ws:joinTopics', null))) {
84
+        if (is_string($request->getAttribute('ws:joinTopics', null))){
85 85
             $topics = explode(',', $request->getAttribute('ws:joinTopics'));
86
-            foreach ($topics as $topic) {
87
-                if (!$this->authorizeTopic($request, $topic)) {
86
+            foreach ($topics as $topic){
87
+                if (!$this->authorizeTopic($request, $topic)){
88 88
                     return $this->responseFactory->createResponse(403);
89 89
                 }
90 90
             }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     private function authorizeServer(ServerRequestInterface $request): bool
105 105
     {
106 106
         $callback = $this->config->getServerCallback();
107
-        if ($callback === null) {
107
+        if ($callback === null){
108 108
             return true;
109 109
         }
110 110
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         $parameters = [];
124 124
         $callback = $this->config->findTopicCallback($topic, $parameters);
125
-        if ($callback === null) {
125
+        if ($callback === null){
126 126
             return false;
127 127
         }
128 128
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     {
142 142
         /** @var \ReflectionFunctionAbstract $reflection */
143 143
         $reflection = null;
144
-        switch (true) {
144
+        switch (true){
145 145
             case $callback instanceof \Closure || is_string($callback):
146 146
                 $reflection = new \ReflectionFunction($callback);
147 147
                 break;
Please login to merge, or discard this patch.
src/Broadcast/Config/WebsocketsConfig.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
         parent::__construct($config);
36 36
 
37
-        foreach ($config['authorizeTopics'] as $topic => $callback) {
37
+        foreach ($config['authorizeTopics'] as $topic => $callback){
38 38
             $this->patterns[$this->compilePattern($topic)] = $callback;
39 39
         }
40 40
     }
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public function findTopicCallback(string $topic, array &$matches): ?callable
64 64
     {
65
-        foreach ($this->patterns as $pattern => $callback) {
66
-            if (preg_match($pattern, $topic, $matches)) {
65
+        foreach ($this->patterns as $pattern => $callback){
66
+            if (preg_match($pattern, $topic, $matches)){
67 67
                 return $callback;
68 68
             }
69 69
         }
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
     private function compilePattern(string $topic): string
79 79
     {
80 80
         $replaces = [];
81
-        if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)) {
81
+        if (preg_match_all('/\{(\w+):?(.*?)?\}/', $topic, $matches)){
82 82
             $variables = array_combine($matches[1], $matches[2]);
83
-            foreach ($variables as $key => $segment) {
84
-                $replaces['{' . $key . '}'] = '(?P<' . $key . '>[^\/\.]+)';
83
+            foreach ($variables as $key => $segment){
84
+                $replaces['{'.$key.'}'] = '(?P<'.$key.'>[^\/\.]+)';
85 85
             }
86 86
         }
87 87
 
88
-        return '/^' . strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']) . '$/iu';
88
+        return '/^'.strtr($topic, $replaces + ['/' => '\\/', '[' => '(?:', ']' => ')?', '.' => '\.']).'$/iu';
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
tests/app/src/Bootloader/AuthBootloader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         EnvironmentInterface $env,
24 24
         BootloadManager $bootloadManager
25 25
     ): void {
26
-        if ($env->get('CYCLE_AUTH')) {
26
+        if ($env->get('CYCLE_AUTH')){
27 27
             $bootloadManager->bootload([CycleTokensBootloader::class]);
28 28
             return;
29 29
         }
Please login to merge, or discard this patch.