Passed
Push — master ( d279ac...d3d8e1 )
by Anton
02:34
created
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->assertStringContainsString('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->assertStringContainsString('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/Cycle/MigrateTest.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,13 +53,13 @@
 block discarded – undo
53 53
         $output = $this->runCommandDebug('cycle:migrate', ['-r' => true]);
54 54
         $this->assertStringContainsString('default.users', $output);
55 55
 
56
-        $user = file_get_contents(__DIR__ . '/../../app/src/User/User.php');
57
-        unlink(__DIR__ . '/../../app/src/User/User.php');
58
-        try {
56
+        $user = file_get_contents(__DIR__.'/../../app/src/User/User.php');
57
+        unlink(__DIR__.'/../../app/src/User/User.php');
58
+        try{
59 59
             $output = $this->runCommandDebug('cycle:migrate', ['-r' => true]);
60 60
             $this->assertStringContainsString('drop foreign key', $output);
61
-        } finally {
62
-            file_put_contents(__DIR__ . '/../../app/src/User/User.php', $user);
61
+        }finally{
62
+            file_put_contents(__DIR__.'/../../app/src/User/User.php', $user);
63 63
         }
64 64
     }
65 65
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,10 +55,13 @@
 block discarded – undo
55 55
 
56 56
         $user = file_get_contents(__DIR__ . '/../../app/src/User/User.php');
57 57
         unlink(__DIR__ . '/../../app/src/User/User.php');
58
-        try {
58
+        try
59
+        {
59 60
             $output = $this->runCommandDebug('cycle:migrate', ['-r' => true]);
60 61
             $this->assertStringContainsString('drop foreign key', $output);
61
-        } finally {
62
+        }
63
+        finally
64
+        {
62 65
             file_put_contents(__DIR__ . '/../../app/src/User/User.php', $user);
63 66
         }
64 67
     }
Please login to merge, or discard this patch.
tests/Framework/Http/CookiesTest.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function testHasCookie(): void
38 38
     {
39
-        $this->http->setHandler(function () {
40
-            return (int) $this->cookies()->has('a');
39
+        $this->http->setHandler(function (){
40
+            return (int)$this->cookies()->has('a');
41 41
         });
42 42
 
43 43
         $result = $this->get('/');
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
         ]);
55 55
         $this->http = $this->app->get(Http::class);
56 56
 
57
-        $this->http->setHandler(function () {
58
-            return (int) $this->cookies()->has('a');
57
+        $this->http->setHandler(function (){
58
+            return (int)$this->cookies()->has('a');
59 59
         });
60 60
 
61 61
         $result = $this->get('/', [], [], [
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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';
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,7 +36,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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';
Please login to merge, or discard this patch.
tests/Framework/Http/RrTest.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
65 65
         );
66 66
 
67 67
         $psr->shouldReceive('respond')->once()->with(
68
-            \Mockery::on(function ($r) {
68
+            \Mockery::on(function ($r){
69 69
                 $this->assertStringContainsString('500', (string)$r->getBody());
70 70
                 return true;
71 71
             })
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
103 103
         );
104 104
 
105 105
         $psr->shouldReceive('respond')->once()->with(
106
-            \Mockery::on(function ($r) {
106
+            \Mockery::on(function ($r){
107 107
                 $this->assertStringContainsString('undefined', (string)$r->getBody());
108 108
                 return true;
109 109
             })
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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->assertStringContainsString('500', (string)$r->getBody());
70 72
                 return true;
71 73
             })
@@ -103,7 +105,8 @@  discard block
 block discarded – undo
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->assertStringContainsString('undefined', (string)$r->getBody());
108 111
                 return true;
109 112
             })
Please login to merge, or discard this patch.
tests/Framework/Framework/ExtensionsCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
     {
20 20
         $output = $this->runCommand('php:extensions');
21 21
 
22
-        foreach (get_loaded_extensions() as $extension) {
22
+        foreach (get_loaded_extensions() as $extension){
23 23
             $this->assertStringContainsString($extension, $output);
24 24
         }
25 25
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,8 @@
 block discarded – undo
19 19
     {
20 20
         $output = $this->runCommand('php:extensions');
21 21
 
22
-        foreach (get_loaded_extensions() as $extension) {
22
+        foreach (get_loaded_extensions() as $extension)
23
+        {
23 24
             $this->assertStringContainsString($extension, $output);
24 25
         }
25 26
     }
Please login to merge, or discard this patch.
tests/Framework/Views/CompileTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
          */
39 39
         $dirs = $this->app->get(DirectoriesInterface::class);
40 40
         $fs = $this->app->get(FilesInterface::class);
41
-        $fs->write($dirs->get('cache') . '/views/test.php', 'test', null, true);
41
+        $fs->write($dirs->get('cache').'/views/test.php', 'test', null, true);
42 42
 
43 43
         $out = $this->runCommandDebug('views:reset');
44 44
         $this->assertStringContainsString('test.php', $out);
Please login to merge, or discard this patch.
src/Domain/FilterInterceptor.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
51 51
     {
52
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
53
-            if (isset($parameters[$parameter])) {
52
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){
53
+            if (isset($parameters[$parameter])){
54 54
                 continue;
55 55
             }
56 56
 
57 57
             /** @var FilterInterface $filter */
58 58
             $filter = $this->container->get($filterClass);
59 59
 
60
-            if (isset($parameters['@context'])) {
60
+            if (isset($parameters['@context'])){
61 61
                 // other interceptors can define the validation contex
62 62
                 $filter->setContext($parameters['@context']);
63 63
             }
64 64
 
65
-            if (!$filter->isValid()) {
65
+            if (!$filter->isValid()){
66 66
                 return $this->renderInvalid($filter);
67 67
             }
68 68
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     protected function renderInvalid(FilterInterface $filter)
82 82
     {
83
-        switch ($this->strategy) {
83
+        switch ($this->strategy){
84 84
             case self::STRATEGY_JSON_RESPONSE:
85 85
                 return [
86 86
                     'status' => 400,
@@ -99,23 +99,23 @@  discard block
 block discarded – undo
99 99
     private function getDeclaredFilters(string $controller, string $action): array
100 100
     {
101 101
         $key = sprintf('%s:%s', $controller, $action);
102
-        if (array_key_exists($key, $this->cache)) {
102
+        if (array_key_exists($key, $this->cache)){
103 103
             return $this->cache[$key];
104 104
         }
105 105
 
106 106
         $this->cache[$key] = [];
107
-        try {
107
+        try{
108 108
             $method = new \ReflectionMethod($controller, $action);
109
-        } catch (\ReflectionException $e) {
109
+        }catch (\ReflectionException $e){
110 110
             return [];
111 111
         }
112 112
 
113
-        foreach ($method->getParameters() as $parameter) {
114
-            if ($parameter->getClass() === null) {
113
+        foreach ($method->getParameters() as $parameter){
114
+            if ($parameter->getClass() === null){
115 115
                 continue;
116 116
             }
117 117
 
118
-            if ($parameter->getClass()->implementsInterface(FilterInterface::class)) {
118
+            if ($parameter->getClass()->implementsInterface(FilterInterface::class)){
119 119
                 $this->cache[$key][$parameter->getName()] = $parameter->getClass()->getName();
120 120
             }
121 121
         }
Please login to merge, or discard this patch.
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -49,20 +49,24 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
51 51
     {
52
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
53
-            if (isset($parameters[$parameter])) {
52
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass)
53
+        {
54
+            if (isset($parameters[$parameter]))
55
+            {
54 56
                 continue;
55 57
             }
56 58
 
57 59
             /** @var FilterInterface $filter */
58 60
             $filter = $this->container->get($filterClass);
59 61
 
60
-            if (isset($parameters['@context'])) {
62
+            if (isset($parameters['@context']))
63
+            {
61 64
                 // other interceptors can define the validation contex
62 65
                 $filter->setContext($parameters['@context']);
63 66
             }
64 67
 
65
-            if (!$filter->isValid()) {
68
+            if (!$filter->isValid())
69
+            {
66 70
                 return $this->renderInvalid($filter);
67 71
             }
68 72
 
@@ -80,7 +84,8 @@  discard block
 block discarded – undo
80 84
      */
81 85
     protected function renderInvalid(FilterInterface $filter)
82 86
     {
83
-        switch ($this->strategy) {
87
+        switch ($this->strategy)
88
+        {
84 89
             case self::STRATEGY_JSON_RESPONSE:
85 90
                 return [
86 91
                     'status' => 400,
@@ -99,23 +104,30 @@  discard block
 block discarded – undo
99 104
     private function getDeclaredFilters(string $controller, string $action): array
100 105
     {
101 106
         $key = sprintf('%s:%s', $controller, $action);
102
-        if (array_key_exists($key, $this->cache)) {
107
+        if (array_key_exists($key, $this->cache))
108
+        {
103 109
             return $this->cache[$key];
104 110
         }
105 111
 
106 112
         $this->cache[$key] = [];
107
-        try {
113
+        try
114
+        {
108 115
             $method = new \ReflectionMethod($controller, $action);
109
-        } catch (\ReflectionException $e) {
116
+        }
117
+        catch (\ReflectionException $e)
118
+        {
110 119
             return [];
111 120
         }
112 121
 
113
-        foreach ($method->getParameters() as $parameter) {
114
-            if ($parameter->getClass() === null) {
122
+        foreach ($method->getParameters() as $parameter)
123
+        {
124
+            if ($parameter->getClass() === null)
125
+            {
115 126
                 continue;
116 127
             }
117 128
 
118
-            if ($parameter->getClass()->implementsInterface(FilterInterface::class)) {
129
+            if ($parameter->getClass()->implementsInterface(FilterInterface::class))
130
+            {
119 131
                 $this->cache[$key][$parameter->getName()] = $parameter->getClass()->getName();
120 132
             }
121 133
         }
Please login to merge, or discard this patch.
src/Domain/CycleInterceptor.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
         $entities = $this->getDeclaredEntities($controller, $action);
47 47
 
48 48
         $contextCandidates = [];
49
-        foreach ($entities as $parameter => $role) {
49
+        foreach ($entities as $parameter => $role){
50 50
             $value = $this->getParameter($parameter, $parameters, count($entities) === 1);
51
-            if ($value === null) {
51
+            if ($value === null){
52 52
                 throw new ControllerException(
53 53
                     "Entity `{$parameter}` can not be found",
54 54
                     ControllerException::NOT_FOUND
55 55
                 );
56 56
             }
57 57
 
58
-            if (is_object($value)) {
59
-                if ($this->orm->getHeap()->has($value)) {
58
+            if (is_object($value)){
59
+                if ($this->orm->getHeap()->has($value)){
60 60
                     $contextCandidates[] = $value;
61 61
                 }
62 62
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             }
66 66
 
67 67
             $entity = $this->resolveEntity($role, $value);
68
-            if ($entity === null) {
68
+            if ($entity === null){
69 69
                 throw new ControllerException(
70 70
                     "Entity `{$parameter}` can not be found",
71 71
                     ControllerException::NOT_FOUND
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             $contextCandidates[] = $value;
77 77
         }
78 78
 
79
-        if (!isset($parameters['@context']) && count($contextCandidates) === 1) {
79
+        if (!isset($parameters['@context']) && count($contextCandidates) === 1){
80 80
             $parameters['@context'] = current($contextCandidates);
81 81
         }
82 82
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function getParameter(string $role, array $parameters, bool $useDefault = false)
93 93
     {
94
-        if (!$useDefault) {
94
+        if (!$useDefault){
95 95
             return $parameters[$role] ?? null;
96 96
         }
97 97
 
@@ -116,23 +116,23 @@  discard block
 block discarded – undo
116 116
     private function getDeclaredEntities(string $controller, string $action): array
117 117
     {
118 118
         $key = sprintf('%s:%s', $controller, $action);
119
-        if (array_key_exists($key, $this->cache)) {
119
+        if (array_key_exists($key, $this->cache)){
120 120
             return $this->cache[$key];
121 121
         }
122 122
 
123 123
         $this->cache[$key] = [];
124
-        try {
124
+        try{
125 125
             $method = new \ReflectionMethod($controller, $action);
126
-        } catch (\ReflectionException $e) {
126
+        }catch (\ReflectionException $e){
127 127
             return [];
128 128
         }
129 129
 
130
-        foreach ($method->getParameters() as $parameter) {
131
-            if ($parameter->getClass() === null) {
130
+        foreach ($method->getParameters() as $parameter){
131
+            if ($parameter->getClass() === null){
132 132
                 continue;
133 133
             }
134 134
 
135
-            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) {
135
+            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())){
136 136
                 $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($parameter->getClass()->getName());
137 137
             }
138 138
         }
Please login to merge, or discard this patch.
Braces   +27 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,17 +46,21 @@  discard block
 block discarded – undo
46 46
         $entities = $this->getDeclaredEntities($controller, $action);
47 47
 
48 48
         $contextCandidates = [];
49
-        foreach ($entities as $parameter => $role) {
49
+        foreach ($entities as $parameter => $role)
50
+        {
50 51
             $value = $this->getParameter($parameter, $parameters, count($entities) === 1);
51
-            if ($value === null) {
52
+            if ($value === null)
53
+            {
52 54
                 throw new ControllerException(
53 55
                     "Entity `{$parameter}` can not be found",
54 56
                     ControllerException::NOT_FOUND
55 57
                 );
56 58
             }
57 59
 
58
-            if (is_object($value)) {
59
-                if ($this->orm->getHeap()->has($value)) {
60
+            if (is_object($value))
61
+            {
62
+                if ($this->orm->getHeap()->has($value))
63
+                {
60 64
                     $contextCandidates[] = $value;
61 65
                 }
62 66
 
@@ -65,7 +69,8 @@  discard block
 block discarded – undo
65 69
             }
66 70
 
67 71
             $entity = $this->resolveEntity($role, $value);
68
-            if ($entity === null) {
72
+            if ($entity === null)
73
+            {
69 74
                 throw new ControllerException(
70 75
                     "Entity `{$parameter}` can not be found",
71 76
                     ControllerException::NOT_FOUND
@@ -76,7 +81,8 @@  discard block
 block discarded – undo
76 81
             $contextCandidates[] = $value;
77 82
         }
78 83
 
79
-        if (!isset($parameters['@context']) && count($contextCandidates) === 1) {
84
+        if (!isset($parameters['@context']) && count($contextCandidates) === 1)
85
+        {
80 86
             $parameters['@context'] = current($contextCandidates);
81 87
         }
82 88
 
@@ -91,7 +97,8 @@  discard block
 block discarded – undo
91 97
      */
92 98
     protected function getParameter(string $role, array $parameters, bool $useDefault = false)
93 99
     {
94
-        if (!$useDefault) {
100
+        if (!$useDefault)
101
+        {
95 102
             return $parameters[$role] ?? null;
96 103
         }
97 104
 
@@ -116,23 +123,30 @@  discard block
 block discarded – undo
116 123
     private function getDeclaredEntities(string $controller, string $action): array
117 124
     {
118 125
         $key = sprintf('%s:%s', $controller, $action);
119
-        if (array_key_exists($key, $this->cache)) {
126
+        if (array_key_exists($key, $this->cache))
127
+        {
120 128
             return $this->cache[$key];
121 129
         }
122 130
 
123 131
         $this->cache[$key] = [];
124
-        try {
132
+        try
133
+        {
125 134
             $method = new \ReflectionMethod($controller, $action);
126
-        } catch (\ReflectionException $e) {
135
+        }
136
+        catch (\ReflectionException $e)
137
+        {
127 138
             return [];
128 139
         }
129 140
 
130
-        foreach ($method->getParameters() as $parameter) {
131
-            if ($parameter->getClass() === null) {
141
+        foreach ($method->getParameters() as $parameter)
142
+        {
143
+            if ($parameter->getClass() === null)
144
+            {
132 145
                 continue;
133 146
             }
134 147
 
135
-            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) {
148
+            if ($this->orm->getSchema()->defines($parameter->getClass()->getName()))
149
+            {
136 150
                 $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($parameter->getClass()->getName());
137 151
             }
138 152
         }
Please login to merge, or discard this patch.