Passed
Pull Request — master (#737)
by Vadim
08:14
created
src/Dumper/src/helpers.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 use Spiral\Debug\Dumper;
13 13
 
14
-if (!function_exists('dump')) {
14
+if (!function_exists('dump')){
15 15
     /**
16 16
      * Dump value.
17 17
      *
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
      */
23 23
     function dump($value, int $output = Dumper::OUTPUT): ?string
24 24
     {
25
-        if (!class_exists(\Spiral\Core\ContainerScope::class)) {
25
+        if (!class_exists(\Spiral\Core\ContainerScope::class)){
26 26
             return (new Dumper())->dump($value, $output);
27 27
         }
28 28
 
29 29
         $container = \Spiral\Core\ContainerScope::getContainer();
30
-        if (is_null($container) || !$container->has(Dumper::class)) {
30
+        if (is_null($container) || !$container->has(Dumper::class)){
31 31
             $dumper = new Dumper();
32 32
 
33 33
             return $dumper->dump($value, $output);
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,7 +11,8 @@  discard block
 block discarded – undo
11 11
 
12 12
 use Spiral\Debug\Dumper;
13 13
 
14
-if (!function_exists('dump')) {
14
+if (!function_exists('dump'))
15
+{
15 16
     /**
16 17
      * Dump value.
17 18
      *
@@ -22,12 +23,14 @@  discard block
 block discarded – undo
22 23
      */
23 24
     function dump($value, int $output = Dumper::OUTPUT): ?string
24 25
     {
25
-        if (!class_exists(\Spiral\Core\ContainerScope::class)) {
26
+        if (!class_exists(\Spiral\Core\ContainerScope::class))
27
+        {
26 28
             return (new Dumper())->dump($value, $output);
27 29
         }
28 30
 
29 31
         $container = \Spiral\Core\ContainerScope::getContainer();
30
-        if (is_null($container) || !$container->has(Dumper::class)) {
32
+        if (is_null($container) || !$container->has(Dumper::class))
33
+        {
31 34
             $dumper = new Dumper();
32 35
 
33 36
             return $dumper->dump($value, $output);
Please login to merge, or discard this patch.
src/Reactor/src/Traits/AccessTrait.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
             AbstractDeclaration::ACCESS_PROTECTED,
39 39
             AbstractDeclaration::ACCESS_PUBLIC,
40 40
             ], true)
41
-        ) {
41
+        ){
42 42
             throw new ReactorException("Invalid declaration level '{$access}'");
43 43
         }
44 44
 
Please login to merge, or discard this patch.
src/Framework/Http/Middleware/ErrorHandlerMiddleware.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         RendererInterface $renderer,
60 60
         ResponseFactoryInterface $responseFactory,
61 61
         ContainerInterface $container
62
-    ) {
62
+    ){
63 63
         $this->suppressErrors = $suppressErrors;
64 64
         $this->renderer = $renderer;
65 65
         $this->responseFactory = $responseFactory;
@@ -73,22 +73,22 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function process(Request $request, Handler $handler): Response
75 75
     {
76
-        try {
76
+        try{
77 77
             return $handler->handle($request);
78
-        } catch (ClientException | RouterException $e) {
79
-            if ($e instanceof ClientException) {
78
+        }catch (ClientException | RouterException $e){
79
+            if ($e instanceof ClientException){
80 80
                 $code = $e->getCode();
81
-            } else {
81
+            }else{
82 82
                 $code = 404;
83 83
             }
84
-        } catch (\Throwable $e) {
84
+        }catch (\Throwable $e){
85 85
             $snapshotter = $this->getOptional(SnapshotterInterface::class);
86
-            if ($snapshotter !== null) {
86
+            if ($snapshotter !== null){
87 87
                 /** @var SnapshotterInterface $snapshotter */
88 88
                 $snapshotter->register($e);
89 89
             }
90 90
 
91
-            if (!$this->suppressErrors->suppressed()) {
91
+            if (!$this->suppressErrors->suppressed()){
92 92
                 return $this->renderError($request, $e);
93 93
             }
94 94
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     {
112 112
         $response = $this->responseFactory->createResponse(500);
113 113
 
114
-        if ($request->getHeaderLine('Accept') === 'application/json') {
114
+        if ($request->getHeaderLine('Accept') === 'application/json'){
115 115
             $response = $response->withHeader('Content-Type', 'application/json');
116 116
             $handler = new JsonHandler();
117 117
             $response->getBody()->write(
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
                     )
124 124
                 )
125 125
             );
126
-        } else {
126
+        }else{
127 127
             $handler = new HtmlHandler();
128 128
             $state = $this->getOptional(StateInterface::class);
129
-            if ($state !== null) {
129
+            if ($state !== null){
130 130
                 $handler = $handler->withState($state);
131 131
             }
132 132
 
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
      */
163 163
     private function getOptional(string $class)
164 164
     {
165
-        try {
165
+        try{
166 166
             return $this->container->get($class);
167
-        } catch (\Throwable | ContainerExceptionInterface $se) {
167
+        }catch (\Throwable | ContainerExceptionInterface $se){
168 168
             return null;
169 169
         }
170 170
     }
Please login to merge, or discard this patch.
Braces   +29 added lines, -12 removed lines patch added patch discarded remove patch
@@ -73,22 +73,32 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function process(Request $request, Handler $handler): Response
75 75
     {
76
-        try {
76
+        try
77
+        {
77 78
             return $handler->handle($request);
78
-        } catch (ClientException | RouterException $e) {
79
-            if ($e instanceof ClientException) {
79
+        }
80
+        catch (ClientException | RouterException $e)
81
+        {
82
+            if ($e instanceof ClientException)
83
+            {
80 84
                 $code = $e->getCode();
81
-            } else {
85
+            }
86
+            else
87
+            {
82 88
                 $code = 404;
83 89
             }
84
-        } catch (\Throwable $e) {
90
+        }
91
+        catch (\Throwable $e)
92
+        {
85 93
             $snapshotter = $this->getOptional(SnapshotterInterface::class);
86
-            if ($snapshotter !== null) {
94
+            if ($snapshotter !== null)
95
+            {
87 96
                 /** @var SnapshotterInterface $snapshotter */
88 97
                 $snapshotter->register($e);
89 98
             }
90 99
 
91
-            if (!$this->suppressErrors->suppressed()) {
100
+            if (!$this->suppressErrors->suppressed())
101
+            {
92 102
                 return $this->renderError($request, $e);
93 103
             }
94 104
 
@@ -111,7 +121,8 @@  discard block
 block discarded – undo
111 121
     {
112 122
         $response = $this->responseFactory->createResponse(500);
113 123
 
114
-        if ($request->getHeaderLine('Accept') === 'application/json') {
124
+        if ($request->getHeaderLine('Accept') === 'application/json')
125
+        {
115 126
             $response = $response->withHeader('Content-Type', 'application/json');
116 127
             $handler = new JsonHandler();
117 128
             $response->getBody()->write(
@@ -123,10 +134,13 @@  discard block
 block discarded – undo
123 134
                     )
124 135
                 )
125 136
             );
126
-        } else {
137
+        }
138
+        else
139
+        {
127 140
             $handler = new HtmlHandler();
128 141
             $state = $this->getOptional(StateInterface::class);
129
-            if ($state !== null) {
142
+            if ($state !== null)
143
+            {
130 144
                 $handler = $handler->withState($state);
131 145
             }
132 146
 
@@ -162,9 +176,12 @@  discard block
 block discarded – undo
162 176
      */
163 177
     private function getOptional(string $class)
164 178
     {
165
-        try {
179
+        try
180
+        {
166 181
             return $this->container->get($class);
167
-        } catch (\Throwable | ContainerExceptionInterface $se) {
182
+        }
183
+        catch (\Throwable | ContainerExceptionInterface $se)
184
+        {
168 185
             return null;
169 186
         }
170 187
     }
Please login to merge, or discard this patch.
src/Scaffolder/src/Command/ControllerCommand.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,11 +54,11 @@
 block discarded – undo
54 54
         /** @var ControllerDeclaration $declaration */
55 55
         $declaration = $this->createDeclaration();
56 56
 
57
-        foreach ($this->option('action') as $action) {
57
+        foreach ($this->option('action') as $action){
58 58
             $declaration->addAction($action);
59 59
         }
60 60
 
61
-        if ((bool)$this->option('prototype')) {
61
+        if ((bool)$this->option('prototype')){
62 62
             $declaration->addPrototypeTrait();
63 63
         }
64 64
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,11 +54,13 @@
 block discarded – undo
54 54
         /** @var ControllerDeclaration $declaration */
55 55
         $declaration = $this->createDeclaration();
56 56
 
57
-        foreach ($this->option('action') as $action) {
57
+        foreach ($this->option('action') as $action)
58
+        {
58 59
             $declaration->addAction($action);
59 60
         }
60 61
 
61
-        if ((bool)$this->option('prototype')) {
62
+        if ((bool)$this->option('prototype'))
63
+        {
62 64
             $declaration->addPrototypeTrait();
63 65
         }
64 66
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Command/MigrationCommand.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,10 +60,10 @@
 block discarded – undo
60 60
         /** @var MigrationDeclaration $declaration */
61 61
         $declaration = $this->createDeclaration();
62 62
 
63
-        if (!empty($this->option('table'))) {
63
+        if (!empty($this->option('table'))){
64 64
             $fields = [];
65
-            foreach ($this->option('field') as $field) {
66
-                if (strpos($field, ':') === false) {
65
+            foreach ($this->option('field') as $field){
66
+                if (strpos($field, ':') === false){
67 67
                     throw new ScaffolderException("Field definition must in 'name:type' form");
68 68
                 }
69 69
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,10 +60,13 @@
 block discarded – undo
60 60
         /** @var MigrationDeclaration $declaration */
61 61
         $declaration = $this->createDeclaration();
62 62
 
63
-        if (!empty($this->option('table'))) {
63
+        if (!empty($this->option('table')))
64
+        {
64 65
             $fields = [];
65
-            foreach ($this->option('field') as $field) {
66
-                if (strpos($field, ':') === false) {
66
+            foreach ($this->option('field') as $field)
67
+            {
68
+                if (strpos($field, ':') === false)
69
+                {
67 70
                     throw new ScaffolderException("Field definition must in 'name:type' form");
68 71
                 }
69 72
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Command/AbstractCommand.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
         FilesInterface $files,
52 52
         ContainerInterface $container,
53 53
         FactoryInterface $factory
54
-    ) {
54
+    ){
55 55
         $this->config = $config;
56 56
         $this->files = $files;
57 57
         $this->factory = $factory;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         $filename = $this->config->classFilename($type, (string)$this->argument('name'));
111 111
         $filename = $this->files->normalizePath($filename);
112 112
 
113
-        if ($this->files->exists($filename)) {
113
+        if ($this->files->exists($filename)){
114 114
             $this->writeln(
115 115
                 "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, "
116 116
                 . "file '<comment>{$filename}</comment>' already exists.</fg=red>"
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,8 @@
 block discarded – undo
110 110
         $filename = $this->config->classFilename($type, (string)$this->argument('name'));
111 111
         $filename = $this->files->normalizePath($filename);
112 112
 
113
-        if ($this->files->exists($filename)) {
113
+        if ($this->files->exists($filename))
114
+        {
114 115
             $this->writeln(
115 116
                 "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, "
116 117
                 . "file '<comment>{$filename}</comment>' already exists.</fg=red>"
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@
 block discarded – undo
114 114
         $this->files->write(
115 115
             $filename,
116 116
             $file->render(),
117
-            FilesInterface::READONLY,
117
+            FilesInterface::readonly,
118 118
             true
119 119
         );
120 120
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Command/CommandCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
         ['name', InputArgument::REQUIRED, 'Command name'],
27 27
         ['alias', InputArgument::OPTIONAL, 'Command id/alias'],
28 28
     ];
29
-    protected const OPTIONS     = [
29
+    protected const OPTIONS = [
30 30
         [
31 31
             'description',
32 32
             'd',
Please login to merge, or discard this patch.
src/Scaffolder/src/Config/ScaffolderConfig.php 2 patches
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,11 +69,13 @@  discard block
 block discarded – undo
69 69
         $localNamespace = trim($this->getOption($element, 'namespace', ''), '\\');
70 70
         ['namespace' => $namespace] = $this->parseName($name);
71 71
 
72
-        if (!empty($namespace)) {
72
+        if (!empty($namespace))
73
+        {
73 74
             $localNamespace .= '\\' . $this->classify($namespace);
74 75
         }
75 76
 
76
-        if (empty($this->baseNamespace())) {
77
+        if (empty($this->baseNamespace()))
78
+        {
77 79
             return $localNamespace;
78 80
         }
79 81
 
@@ -106,7 +108,8 @@  discard block
 block discarded – undo
106 108
     {
107 109
         $class = $this->getOption($element, 'class');
108 110
 
109
-        if (empty($class)) {
111
+        if (empty($class))
112
+        {
110 113
             throw new ScaffolderException(
111 114
                 "Unable to scaffold '{$element}', no declaration class found"
112 115
             );
@@ -143,11 +146,13 @@  discard block
 block discarded – undo
143 146
      */
144 147
     private function getOption(string $element, string $section, $default = null)
145 148
     {
146
-        if (!isset($this->config['declarations'][$element])) {
149
+        if (!isset($this->config['declarations'][$element]))
150
+        {
147 151
             throw new ScaffolderException("Undefined declaration '{$element}'.");
148 152
         }
149 153
 
150
-        if (array_key_exists($section, $this->config['declarations'][$element])) {
154
+        if (array_key_exists($section, $this->config['declarations'][$element]))
155
+        {
151 156
             return $this->config['declarations'][$element][$section];
152 157
         }
153 158
 
@@ -164,7 +169,8 @@  discard block
 block discarded – undo
164 169
     {
165 170
         $name = str_replace('/', '\\', $name);
166 171
 
167
-        if (strpos($name, '\\') !== false) {
172
+        if (strpos($name, '\\') !== false)
173
+        {
168 174
             $names = explode('\\', $name);
169 175
             $class = array_pop($names);
170 176
 
@@ -192,11 +198,15 @@  discard block
 block discarded – undo
192 198
     {
193 199
         $firstChunkIterated = false;
194 200
         $joinedPath = '';
195
-        foreach ($chunks as $chunk) {
196
-            if (!$firstChunkIterated) {
201
+        foreach ($chunks as $chunk)
202
+        {
203
+            if (!$firstChunkIterated)
204
+            {
197 205
                 $firstChunkIterated = true;
198 206
                 $joinedPath = $chunk;
199
-            } else {
207
+            }
208
+            else
209
+            {
200 210
                 $joinedPath = rtrim($joinedPath, $joint) . $joint . ltrim($chunk, $joint);
201 211
             }
202 212
         }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
         ['name' => $name] = $this->parseName($name);
47 47
 
48
-        return $this->classify($name) . $this->elementPostfix($element);
48
+        return $this->classify($name).$this->elementPostfix($element);
49 49
     }
50 50
 
51 51
     public function classNamespace(string $element, string $name = ''): string
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
         $localNamespace = trim($this->getOption($element, 'namespace', ''), '\\');
54 54
         ['namespace' => $namespace] = $this->parseName($name);
55 55
 
56
-        if (!empty($namespace)) {
57
-            $localNamespace .= '\\' . $this->classify($namespace);
56
+        if (!empty($namespace)){
57
+            $localNamespace .= '\\'.$this->classify($namespace);
58 58
         }
59 59
 
60
-        if (empty($this->baseNamespace())) {
60
+        if (empty($this->baseNamespace())){
61 61
             return $localNamespace;
62 62
         }
63 63
 
64
-        return trim($this->baseNamespace() . '\\' . $localNamespace, '\\');
64
+        return trim($this->baseNamespace().'\\'.$localNamespace, '\\');
65 65
     }
66 66
 
67 67
     public function classFilename(string $element, string $name): string
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         return $this->joinPathChunks([
73 73
             $this->baseDirectory(),
74 74
             str_replace('\\', '/', $namespace),
75
-            $this->className($element, $name) . '.php',
75
+            $this->className($element, $name).'.php',
76 76
         ], '/');
77 77
     }
78 78
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     {
84 84
         $class = $this->getOption($element, 'class');
85 85
 
86
-        if (empty($class)) {
86
+        if (empty($class)){
87 87
             throw new ScaffolderException(
88 88
                 "Unable to scaffold '{$element}', no declaration class found"
89 89
             );
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
      */
112 112
     private function getOption(string $element, string $section, $default = null)
113 113
     {
114
-        if (!isset($this->config['declarations'][$element])) {
114
+        if (!isset($this->config['declarations'][$element])){
115 115
             throw new ScaffolderException("Undefined declaration '{$element}'.");
116 116
         }
117 117
 
118
-        if (array_key_exists($section, $this->config['declarations'][$element])) {
118
+        if (array_key_exists($section, $this->config['declarations'][$element])){
119 119
             return $this->config['declarations'][$element][$section];
120 120
         }
121 121
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     {
132 132
         $name = str_replace('/', '\\', $name);
133 133
 
134
-        if (strpos($name, '\\') !== false) {
134
+        if (strpos($name, '\\') !== false){
135 135
             $names = explode('\\', $name);
136 136
             $class = array_pop($names);
137 137
 
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
     {
152 152
         $firstChunkIterated = false;
153 153
         $joinedPath = '';
154
-        foreach ($chunks as $chunk) {
155
-            if (!$firstChunkIterated) {
154
+        foreach ($chunks as $chunk){
155
+            if (!$firstChunkIterated){
156 156
                 $firstChunkIterated = true;
157 157
                 $joinedPath = $chunk;
158
-            } else {
159
-                $joinedPath = rtrim($joinedPath, $joint) . $joint . ltrim($chunk, $joint);
158
+            }else{
159
+                $joinedPath = rtrim($joinedPath, $joint).$joint.ltrim($chunk, $joint);
160 160
             }
161 161
         }
162 162
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
     private function classify(string $name): string
167 167
     {
168
-        return ( new InflectorFactory() )
168
+        return (new InflectorFactory())
169 169
             ->build()
170 170
             ->classify($name);
171 171
     }
Please login to merge, or discard this patch.
src/Scaffolder/src/Declaration/Database/AbstractEntityDeclaration.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,11 +96,13 @@
 block discarded – undo
96 96
     {
97 97
         $property = $this->property($name);
98 98
         $property->setComment("@var {$this->variableType($type)}");
99
-        if ($accessibility) {
99
+        if ($accessibility)
100
+        {
100 101
             $property->setAccess($accessibility);
101 102
         }
102 103
 
103
-        if ($property->getAccess() !== self::ACCESS_PUBLIC) {
104
+        if ($property->getAccess() !== self::ACCESS_PUBLIC)
105
+        {
104 106
             $this->declareAccessors($name, $type);
105 107
         }
106 108
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $property = $this->property($name);
78 78
         $property->setComment("@var {$this->variableType($type)}");
79
-        if ($accessibility) {
79
+        if ($accessibility){
80 80
             $property->setAccess($accessibility);
81 81
         }
82 82
 
83
-        if ($property->getAccess() !== self::ACCESS_PUBLIC) {
83
+        if ($property->getAccess() !== self::ACCESS_PUBLIC){
84 84
             $this->declareAccessors($name, $type);
85 85
         }
86 86
 
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
 
97 97
     private function variableType(string $type): string
98 98
     {
99
-        return $this->isNullableType($type) ? (substr($type, 1) . '|null') : $type;
99
+        return $this->isNullableType($type) ? (substr($type, 1).'|null') : $type;
100 100
     }
101 101
 
102 102
     private function declareAccessors(string $field, string $type): void
103 103
     {
104
-        $setter = $this->method('set' . $this->classify($field));
104
+        $setter = $this->method('set'.$this->classify($field));
105 105
         $setter->setPublic();
106 106
         $setter->parameter('value')->setType($type);
107 107
         $setter->setSource("\$this->$field = \$value;");
108 108
 
109
-        $getter = $this->method('get' . $this->classify($field));
109
+        $getter = $this->method('get'.$this->classify($field));
110 110
         $getter->setPublic();
111 111
         $getter->setSource("return \$this->$field;");
112 112
     }
113 113
 
114 114
     private function classify(string $name): string
115 115
     {
116
-        return ( new InflectorFactory() )
116
+        return (new InflectorFactory())
117 117
             ->build()
118 118
             ->classify($name);
119 119
     }
Please login to merge, or discard this patch.