Passed
Pull Request — master (#407)
by Kirill
06:41 queued 01:48
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/Filters/src/SchemaBuilder.php 3 patches
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                     FilterProvider::SOURCE => null,
93 93
                     FilterProvider::ORIGIN => $field,
94 94
                     FilterProvider::FILTER => $definition,
95
-                    FilterProvider::ARRAY  => false,
95
+                    FilterProvider::array  => false,
96 96
                 ];
97 97
 
98 98
                 continue;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 FilterProvider::FILTER => $definition[self::NESTED],
122 122
                 FilterProvider::SOURCE => null,
123 123
                 FilterProvider::ORIGIN => $origin,
124
-                FilterProvider::ARRAY  => $iterate,
124
+                FilterProvider::array  => $iterate,
125 125
             ];
126 126
 
127 127
             if ($iterate) {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
     protected function buildMap(ReflectionEntity $filter): array
70 70
     {
71 71
         $schema = $filter->getProperty('schema', true);
72
-        if (empty($schema)) {
72
+        if (empty($schema)){
73 73
             throw new SchemaException("Filter `{$filter->getName()}` does not define any schema");
74 74
         }
75 75
 
76 76
         $result = [];
77
-        foreach ($schema as $field => $definition) {
77
+        foreach ($schema as $field => $definition){
78 78
             // short definition
79
-            if (is_string($definition)) {
79
+            if (is_string($definition)){
80 80
                 // simple scalar field definition
81
-                if (!class_exists($definition)) {
81
+                if (!class_exists($definition)){
82 82
                     [$source, $origin] = $this->parseDefinition($field, $definition);
83 83
                     $result[$field] = [
84 84
                         FilterProvider::SOURCE => $source,
@@ -98,20 +98,20 @@  discard block
 block discarded – undo
98 98
                 continue;
99 99
             }
100 100
 
101
-            if (!is_array($definition) || count($definition) === 0) {
101
+            if (!is_array($definition) || count($definition) === 0){
102 102
                 throw new SchemaException(
103 103
                     "Invalid schema definition at `{$filter->getName()}`->`{$field}`"
104 104
                 );
105 105
             }
106 106
 
107 107
             // complex definition
108
-            if (!empty($definition[self::ORIGIN])) {
108
+            if (!empty($definition[self::ORIGIN])){
109 109
                 $origin = $definition[self::ORIGIN];
110 110
 
111 111
                 // [class, 'data:something.*'] vs [class, 'data:something']
112 112
                 $iterate = strpos($origin, '.*') !== false || !empty($definition[self::ITERATE]);
113 113
                 $origin = rtrim($origin, '.*');
114
-            } else {
114
+            }else{
115 115
                 $origin = $field;
116 116
                 $iterate = true;
117 117
             }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                 FilterProvider::ARRAY  => $iterate,
125 125
             ];
126 126
 
127
-            if ($iterate) {
127
+            if ($iterate){
128 128
                 [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin);
129 129
 
130 130
                 $map[FilterProvider::ITERATE_SOURCE] = $source;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     private function parseDefinition(string $field, string $definition): array
152 152
     {
153
-        if (strpos($definition, ':') === false) {
153
+        if (strpos($definition, ':') === false){
154 154
             return ['data', $definition ?? $field];
155 155
         }
156 156
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,16 +69,20 @@  discard block
 block discarded – undo
69 69
     protected function buildMap(ReflectionEntity $filter): array
70 70
     {
71 71
         $schema = $filter->getProperty('schema', true);
72
-        if (empty($schema)) {
72
+        if (empty($schema))
73
+        {
73 74
             throw new SchemaException("Filter `{$filter->getName()}` does not define any schema");
74 75
         }
75 76
 
76 77
         $result = [];
77
-        foreach ($schema as $field => $definition) {
78
+        foreach ($schema as $field => $definition)
79
+        {
78 80
             // short definition
79
-            if (is_string($definition)) {
81
+            if (is_string($definition))
82
+            {
80 83
                 // simple scalar field definition
81
-                if (!class_exists($definition)) {
84
+                if (!class_exists($definition))
85
+                {
82 86
                     [$source, $origin] = $this->parseDefinition($field, $definition);
83 87
                     $result[$field] = [
84 88
                         FilterProvider::SOURCE => $source,
@@ -98,20 +102,24 @@  discard block
 block discarded – undo
98 102
                 continue;
99 103
             }
100 104
 
101
-            if (!is_array($definition) || count($definition) === 0) {
105
+            if (!is_array($definition) || count($definition) === 0)
106
+            {
102 107
                 throw new SchemaException(
103 108
                     "Invalid schema definition at `{$filter->getName()}`->`{$field}`"
104 109
                 );
105 110
             }
106 111
 
107 112
             // complex definition
108
-            if (!empty($definition[self::ORIGIN])) {
113
+            if (!empty($definition[self::ORIGIN]))
114
+            {
109 115
                 $origin = $definition[self::ORIGIN];
110 116
 
111 117
                 // [class, 'data:something.*'] vs [class, 'data:something']
112 118
                 $iterate = strpos($origin, '.*') !== false || !empty($definition[self::ITERATE]);
113 119
                 $origin = rtrim($origin, '.*');
114
-            } else {
120
+            }
121
+            else
122
+            {
115 123
                 $origin = $field;
116 124
                 $iterate = true;
117 125
             }
@@ -124,7 +132,8 @@  discard block
 block discarded – undo
124 132
                 FilterProvider::ARRAY  => $iterate,
125 133
             ];
126 134
 
127
-            if ($iterate) {
135
+            if ($iterate)
136
+            {
128 137
                 [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin);
129 138
 
130 139
                 $map[FilterProvider::ITERATE_SOURCE] = $source;
@@ -150,7 +159,8 @@  discard block
 block discarded – undo
150 159
      */
151 160
     private function parseDefinition(string $field, string $definition): array
152 161
     {
153
-        if (strpos($definition, ':') === false) {
162
+        if (strpos($definition, ':') === false)
163
+        {
154 164
             return ['data', $definition ?? $field];
155 165
         }
156 166
 
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.
tests/Framework/Cycle/SchemaTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,10 +62,10 @@
 block discarded – undo
62 62
     {
63 63
         $app = TestApp::init(
64 64
             [
65
-                'root'    => __DIR__ . '/../../..',
66
-                'app'     => __DIR__ . '/../../emptyApp',
67
-                'runtime' => sys_get_temp_dir() . '/spiral',
68
-                'cache'   => sys_get_temp_dir() . '/spiral',
65
+                'root'    => __DIR__.'/../../..',
66
+                'app'     => __DIR__.'/../../emptyApp',
67
+                'runtime' => sys_get_temp_dir().'/spiral',
68
+                'cache'   => sys_get_temp_dir().'/spiral',
69 69
             ],
70 70
             new Environment(['SAFE_MIGRATIONS' => true]),
71 71
             false
Please login to merge, or discard this patch.
src/Scaffolder/src/Bootloader/ScaffolderBootloader.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
         $console->addCommand(Command\MiddlewareCommand::class);
63 63
         $console->addCommand(Command\MigrationCommand::class);
64 64
 
65
-        try {
65
+        try{
66 66
             $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName();
67
-        } catch (ReflectionException $e) {
67
+        }catch (ReflectionException $e){
68 68
             $defaultNamespace = '';
69 69
         }
70 70
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
              * Base directory for generated classes, class will be automatically localed into sub directory
84 84
              * using given namespace.
85 85
              */
86
-            'directory'    => directory('app') . 'src/',
86
+            'directory'    => directory('app').'src/',
87 87
 
88 88
             /*
89 89
              * Default namespace to be applied for every generated class. By default uses Kernel namespace
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,9 +62,12 @@
 block discarded – undo
62 62
         $console->addCommand(Command\MiddlewareCommand::class);
63 63
         $console->addCommand(Command\MigrationCommand::class);
64 64
 
65
-        try {
65
+        try
66
+        {
66 67
             $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName();
67
-        } catch (ReflectionException $e) {
68
+        }
69
+        catch (ReflectionException $e)
70
+        {
68 71
             $defaultNamespace = '';
69 72
         }
70 73
 
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 2 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.