Passed
Pull Request — master (#1196)
by Abdul Malik
11:01
created
rector.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@
 block discarded – undo
120 120
         PreferPHPUnitThisCallRector::class,
121 121
     ])
122 122
     ->withPhpSets(php81: true)
123
-    ->withPreparedSets(deadCode: true, phpunitCodeQuality: true, instanceOf: true)
123
+    ->withPreparedSets(deadCode: true, phpunitCodeQuality: true, instanceof: true)
124 124
     ->withComposerBased(phpunit: true)
125 125
     ->withConfiguredRule(ClassPropertyAssignToConstructorPromotionRector::class, [
126 126
         ClassPropertyAssignToConstructorPromotionRector::RENAME_PROPERTY => false,
Please login to merge, or discard this patch.
src/Console/src/Command.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function execute(InputInterface $input, OutputInterface $output): int
85 85
     {
86
-        if (!$this->container instanceof \Psr\Container\ContainerInterface) {
86
+        if (!$this->container instanceof \Psr\Container\ContainerInterface){
87 87
             throw new ScopeException('Container is not set');
88 88
         }
89 89
 
90 90
         $method = method_exists($this, 'perform') ? 'perform' : '__invoke';
91 91
 
92
-        try {
92
+        try{
93 93
             [$this->input, $this->output] = [$this->prepareInput($input), $this->prepareOutput($input, $output)];
94 94
 
95 95
             $this->eventDispatcher?->dispatch(new CommandStarting($this, $this->input, $this->output));
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             $this->eventDispatcher?->dispatch(new CommandFinished($this, $code, $this->input, $this->output));
123 123
 
124 124
             return $code;
125
-        } finally {
125
+        }finally{
126 126
             [$this->input, $this->output] = [null, null];
127 127
         }
128 128
     }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     /**
131 131
      * @deprecated This method will be removed in v4.0.
132 132
      */
133
-    protected function buildCore(): CoreInterface|HandlerInterface
133
+    protected function buildCore(): CoreInterface | HandlerInterface
134 134
     {
135 135
         /** @var InvokerInterface $invoker */
136 136
         $invoker = $this->container->get(InvokerInterface::class);
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -83,13 +83,15 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function execute(InputInterface $input, OutputInterface $output): int
85 85
     {
86
-        if (!$this->container instanceof \Psr\Container\ContainerInterface) {
86
+        if (!$this->container instanceof \Psr\Container\ContainerInterface)
87
+        {
87 88
             throw new ScopeException('Container is not set');
88 89
         }
89 90
 
90 91
         $method = method_exists($this, 'perform') ? 'perform' : '__invoke';
91 92
 
92
-        try {
93
+        try
94
+        {
93 95
             [$this->input, $this->output] = [$this->prepareInput($input), $this->prepareOutput($input, $output)];
94 96
 
95 97
             $this->eventDispatcher?->dispatch(new CommandStarting($this, $this->input, $this->output));
@@ -122,7 +124,9 @@  discard block
 block discarded – undo
122 124
             $this->eventDispatcher?->dispatch(new CommandFinished($this, $code, $this->input, $this->output));
123 125
 
124 126
             return $code;
125
-        } finally {
127
+        }
128
+        finally
129
+        {
126 130
             [$this->input, $this->output] = [null, null];
127 131
         }
128 132
     }
Please login to merge, or discard this patch.
src/Console/src/Console.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         #[Proxy] private readonly ContainerInterface $container = new Container(),
39 39
         private readonly ScopeInterface $scope = new Container(),
40 40
         private readonly ?EventDispatcherInterface $dispatcher = null,
41
-    ) {
41
+    ){
42 42
     }
43 43
 
44 44
     /**
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function run(
65 65
         ?string $command,
66
-        array|InputInterface $input = [],
66
+        array | InputInterface $input = [],
67 67
         OutputInterface $output = new BufferedOutput(),
68 68
     ): CommandOutput {
69 69
         $input = \is_array($input) ? new ArrayInput($input) : $input;
70 70
 
71 71
         $this->configureIO($input, $output);
72 72
 
73
-        if ($command !== null) {
73
+        if ($command !== null){
74 74
             $input = new InputProxy($input, ['firstArgument' => $command]);
75 75
         }
76 76
 
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function getApplication(): Application
99 99
     {
100
-        if ($this->application instanceof \Symfony\Component\Console\Application) {
100
+        if ($this->application instanceof \Symfony\Component\Console\Application){
101 101
             return $this->application;
102 102
         }
103 103
 
104 104
         $this->application = new Application($this->config->getName(), $this->config->getVersion());
105 105
         $this->application->setCatchExceptions(false);
106 106
         $this->application->setAutoExit(false);
107
-        if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) {
107
+        if ($this->dispatcher instanceof SymfonyEventDispatcherInterface){
108 108
             $this->application->setDispatcher($this->dispatcher);
109 109
         }
110 110
 
111
-        if ($this->locator instanceof \Spiral\Console\LocatorInterface) {
111
+        if ($this->locator instanceof \Spiral\Console\LocatorInterface){
112 112
             $this->addCommands($this->locator->locateCommands());
113 113
         }
114 114
 
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $interceptors = $this->config->getInterceptors();
130 130
 
131
-        foreach ($commands as $command) {
132
-            if ($command instanceof Command) {
131
+        foreach ($commands as $command){
132
+            if ($command instanceof Command){
133 133
                 $command->setContainer($this->container);
134 134
                 $command->setInterceptors($interceptors);
135 135
             }
136 136
 
137
-            if ($this->dispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface && $command instanceof EventDispatcherAwareInterface) {
137
+            if ($this->dispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface && $command instanceof EventDispatcherAwareInterface){
138 138
                 $command->setEventDispatcher($this->dispatcher);
139 139
             }
140 140
 
@@ -149,22 +149,22 @@  discard block
 block discarded – undo
149 149
      */
150 150
     private function configureIO(InputInterface $input, OutputInterface $output): void
151 151
     {
152
-        if ($input->hasParameterOption(['--ansi'], true)) {
152
+        if ($input->hasParameterOption(['--ansi'], true)){
153 153
             $output->setDecorated(true);
154
-        } elseif ($input->hasParameterOption(['--no-ansi'], true)) {
154
+        } elseif ($input->hasParameterOption(['--no-ansi'], true)){
155 155
             $output->setDecorated(false);
156 156
         }
157 157
 
158
-        if ($input->hasParameterOption(['--no-interaction', '-n'], true)) {
158
+        if ($input->hasParameterOption(['--no-interaction', '-n'], true)){
159 159
             $input->setInteractive(false);
160
-        } elseif (\function_exists('posix_isatty')) {
160
+        } elseif (\function_exists('posix_isatty')){
161 161
             $inputStream = null;
162 162
 
163
-            if ($input instanceof StreamableInputInterface) {
163
+            if ($input instanceof StreamableInputInterface){
164 164
                 $inputStream = $input->getStream();
165 165
             }
166 166
 
167
-            if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
167
+            if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')){
168 168
                 $input->setInteractive(false);
169 169
             }
170 170
         }
@@ -177,22 +177,22 @@  discard block
 block discarded – undo
177 177
             default => $shellVerbosity = 0
178 178
         };
179 179
 
180
-        if ($input->hasParameterOption(['--quiet', '-q'], true)) {
180
+        if ($input->hasParameterOption(['--quiet', '-q'], true)){
181 181
             $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
182 182
             $shellVerbosity = -1;
183
-        } else {
183
+        }else{
184 184
             if (
185 185
                 $input->hasParameterOption('-vvv', true)
186 186
                 || $input->hasParameterOption('--verbose=3', true)
187 187
                 || 3 === $input->getParameterOption('--verbose', false, true)
188
-            ) {
188
+            ){
189 189
                 $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
190 190
                 $shellVerbosity = 3;
191 191
             } elseif (
192 192
                 $input->hasParameterOption('-vv', true)
193 193
                 || $input->hasParameterOption('--verbose=2', true)
194 194
                 || 2 === $input->getParameterOption('--verbose', false, true)
195
-            ) {
195
+            ){
196 196
                 $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
197 197
                 $shellVerbosity = 2;
198 198
             } elseif (
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
                 || $input->hasParameterOption('--verbose=1', true)
201 201
                 || $input->hasParameterOption('--verbose', true)
202 202
                 || $input->getParameterOption('--verbose', false, true)
203
-            ) {
203
+            ){
204 204
                 $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
205 205
                 $shellVerbosity = 1;
206 206
             }
207 207
         }
208 208
 
209
-        if (-1 === $shellVerbosity) {
209
+        if (-1 === $shellVerbosity){
210 210
             $input->setInteractive(false);
211 211
         }
212 212
 
213
-        \putenv('SHELL_VERBOSITY=' . $shellVerbosity);
213
+        \putenv('SHELL_VERBOSITY='.$shellVerbosity);
214 214
         $_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
215 215
         $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
216 216
     }
Please login to merge, or discard this patch.
Braces   +39 added lines, -18 removed lines patch added patch discarded remove patch
@@ -70,7 +70,8 @@  discard block
 block discarded – undo
70 70
 
71 71
         $this->configureIO($input, $output);
72 72
 
73
-        if ($command !== null) {
73
+        if ($command !== null)
74
+        {
74 75
             $input = new InputProxy($input, ['firstArgument' => $command]);
75 76
         }
76 77
 
@@ -97,18 +98,21 @@  discard block
 block discarded – undo
97 98
      */
98 99
     public function getApplication(): Application
99 100
     {
100
-        if ($this->application instanceof \Symfony\Component\Console\Application) {
101
+        if ($this->application instanceof \Symfony\Component\Console\Application)
102
+        {
101 103
             return $this->application;
102 104
         }
103 105
 
104 106
         $this->application = new Application($this->config->getName(), $this->config->getVersion());
105 107
         $this->application->setCatchExceptions(false);
106 108
         $this->application->setAutoExit(false);
107
-        if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) {
109
+        if ($this->dispatcher instanceof SymfonyEventDispatcherInterface)
110
+        {
108 111
             $this->application->setDispatcher($this->dispatcher);
109 112
         }
110 113
 
111
-        if ($this->locator instanceof \Spiral\Console\LocatorInterface) {
114
+        if ($this->locator instanceof \Spiral\Console\LocatorInterface)
115
+        {
112 116
             $this->addCommands($this->locator->locateCommands());
113 117
         }
114 118
 
@@ -128,13 +132,16 @@  discard block
 block discarded – undo
128 132
     {
129 133
         $interceptors = $this->config->getInterceptors();
130 134
 
131
-        foreach ($commands as $command) {
132
-            if ($command instanceof Command) {
135
+        foreach ($commands as $command)
136
+        {
137
+            if ($command instanceof Command)
138
+            {
133 139
                 $command->setContainer($this->container);
134 140
                 $command->setInterceptors($interceptors);
135 141
             }
136 142
 
137
-            if ($this->dispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface && $command instanceof EventDispatcherAwareInterface) {
143
+            if ($this->dispatcher instanceof \Psr\EventDispatcher\EventDispatcherInterface && $command instanceof EventDispatcherAwareInterface)
144
+            {
138 145
                 $command->setEventDispatcher($this->dispatcher);
139 146
             }
140 147
 
@@ -149,22 +156,30 @@  discard block
 block discarded – undo
149 156
      */
150 157
     private function configureIO(InputInterface $input, OutputInterface $output): void
151 158
     {
152
-        if ($input->hasParameterOption(['--ansi'], true)) {
159
+        if ($input->hasParameterOption(['--ansi'], true))
160
+        {
153 161
             $output->setDecorated(true);
154
-        } elseif ($input->hasParameterOption(['--no-ansi'], true)) {
162
+        }
163
+        elseif ($input->hasParameterOption(['--no-ansi'], true))
164
+        {
155 165
             $output->setDecorated(false);
156 166
         }
157 167
 
158
-        if ($input->hasParameterOption(['--no-interaction', '-n'], true)) {
168
+        if ($input->hasParameterOption(['--no-interaction', '-n'], true))
169
+        {
159 170
             $input->setInteractive(false);
160
-        } elseif (\function_exists('posix_isatty')) {
171
+        }
172
+        elseif (\function_exists('posix_isatty'))
173
+        {
161 174
             $inputStream = null;
162 175
 
163
-            if ($input instanceof StreamableInputInterface) {
176
+            if ($input instanceof StreamableInputInterface)
177
+            {
164 178
                 $inputStream = $input->getStream();
165 179
             }
166 180
 
167
-            if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
181
+            if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE'))
182
+            {
168 183
                 $input->setInteractive(false);
169 184
             }
170 185
         }
@@ -177,10 +192,13 @@  discard block
 block discarded – undo
177 192
             default => $shellVerbosity = 0
178 193
         };
179 194
 
180
-        if ($input->hasParameterOption(['--quiet', '-q'], true)) {
195
+        if ($input->hasParameterOption(['--quiet', '-q'], true))
196
+        {
181 197
             $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
182 198
             $shellVerbosity = -1;
183
-        } else {
199
+        }
200
+        else
201
+        {
184 202
             if (
185 203
                 $input->hasParameterOption('-vvv', true)
186 204
                 || $input->hasParameterOption('--verbose=3', true)
@@ -188,14 +206,16 @@  discard block
 block discarded – undo
188 206
             ) {
189 207
                 $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
190 208
                 $shellVerbosity = 3;
191
-            } elseif (
209
+            }
210
+            elseif (
192 211
                 $input->hasParameterOption('-vv', true)
193 212
                 || $input->hasParameterOption('--verbose=2', true)
194 213
                 || 2 === $input->getParameterOption('--verbose', false, true)
195 214
             ) {
196 215
                 $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
197 216
                 $shellVerbosity = 2;
198
-            } elseif (
217
+            }
218
+            elseif (
199 219
                 $input->hasParameterOption('-v', true)
200 220
                 || $input->hasParameterOption('--verbose=1', true)
201 221
                 || $input->hasParameterOption('--verbose', true)
@@ -206,7 +226,8 @@  discard block
 block discarded – undo
206 226
             }
207 227
         }
208 228
 
209
-        if (-1 === $shellVerbosity) {
229
+        if (-1 === $shellVerbosity)
230
+        {
210 231
             $input->setInteractive(false);
211 232
         }
212 233
 
Please login to merge, or discard this patch.
src/Console/src/Configurator/Attribute/Parser.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 {
25 25
     public function __construct(
26 26
         private readonly ReaderInterface $reader = new AttributeReader()
27
-    ) {
27
+    ){
28 28
     }
29 29
 
30 30
     public function hasCommandAttribute(\ReflectionClass $reflection): bool
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     {
38 38
         $attribute = $this->reader->firstClassMetadata($reflection, AsCommand::class);
39 39
 
40
-        if ($attribute === null) {
40
+        if ($attribute === null){
41 41
             $attribute = $reflection->getAttributes(SymfonyAsCommand::class)[0]->newInstance();
42 42
         }
43 43
 
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
     {
55 55
         $reflection = new \ReflectionClass($command);
56 56
 
57
-        foreach ($reflection->getProperties() as $property) {
57
+        foreach ($reflection->getProperties() as $property){
58 58
             $attribute = $this->reader->firstPropertyMetadata($property, Argument::class);
59
-            if ($attribute === null) {
59
+            if ($attribute === null){
60 60
                 continue;
61 61
             }
62 62
 
63
-            if ($input->hasArgument($attribute->name ?? $property->getName())) {
63
+            if ($input->hasArgument($attribute->name ?? $property->getName())){
64 64
                 $property->setValue(
65 65
                     $command,
66 66
                     $this->typecast($input->getArgument($attribute->name ?? $property->getName()), $property)
@@ -68,16 +68,16 @@  discard block
 block discarded – undo
68 68
             }
69 69
         }
70 70
 
71
-        foreach ($reflection->getProperties() as $property) {
71
+        foreach ($reflection->getProperties() as $property){
72 72
             $attribute = $this->reader->firstPropertyMetadata($property, Option::class);
73
-            if ($attribute === null) {
73
+            if ($attribute === null){
74 74
                 continue;
75 75
             }
76 76
 
77
-            if ($input->hasOption($attribute->name ?? $property->getName())) {
77
+            if ($input->hasOption($attribute->name ?? $property->getName())){
78 78
                 $value = $this->typecast($input->getOption($attribute->name ?? $property->getName()), $property);
79 79
 
80
-                if ($value !== null || $this->getPropertyType($property)->allowsNull()) {
80
+                if ($value !== null || $this->getPropertyType($property)->allowsNull()){
81 81
                     $property->setValue($command, $value);
82 82
                 }
83 83
             }
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
     {
89 89
         $result = [];
90 90
         $arrayArgument = null;
91
-        foreach ($reflection->getProperties() as $property) {
91
+        foreach ($reflection->getProperties() as $property){
92 92
             $attribute = $this->reader->firstPropertyMetadata($property, Argument::class);
93
-            if ($attribute === null) {
93
+            if ($attribute === null){
94 94
                 continue;
95 95
             }
96 96
 
@@ -108,24 +108,24 @@  discard block
 block discarded – undo
108 108
             $argument = new InputArgument(
109 109
                 name: $attribute->name ?? $property->getName(),
110 110
                 mode: $mode,
111
-                description: (string) $attribute->description,
111
+                description: (string)$attribute->description,
112 112
                 default: $property->hasDefaultValue() ? $property->getDefaultValue() : null,
113
-                suggestedValues: $attribute->suggestedValues
113
+                suggestedValues : $attribute->suggestedValues
114 114
             );
115 115
 
116
-            if ($arrayArgument instanceof \Symfony\Component\Console\Input\InputArgument && $isArray) {
116
+            if ($arrayArgument instanceof \Symfony\Component\Console\Input\InputArgument && $isArray){
117 117
                 throw new ConfiguratorException('There must be only one array argument!');
118 118
             }
119 119
 
120 120
             // It must be used at the end of the argument list.
121
-            if ($isArray) {
121
+            if ($isArray){
122 122
                 $arrayArgument = $argument;
123 123
                 continue;
124 124
             }
125 125
             $result[] = $argument;
126 126
         }
127 127
 
128
-        if ($arrayArgument instanceof \Symfony\Component\Console\Input\InputArgument) {
128
+        if ($arrayArgument instanceof \Symfony\Component\Console\Input\InputArgument){
129 129
             $result[] = $arrayArgument;
130 130
         }
131 131
 
@@ -135,21 +135,21 @@  discard block
 block discarded – undo
135 135
     private function parseOptions(\ReflectionClass $reflection): array
136 136
     {
137 137
         $result = [];
138
-        foreach ($reflection->getProperties() as $property) {
138
+        foreach ($reflection->getProperties() as $property){
139 139
             $attribute = $this->reader->firstPropertyMetadata($property, Option::class);
140
-            if ($attribute === null) {
140
+            if ($attribute === null){
141 141
                 continue;
142 142
             }
143 143
 
144 144
             $type = $this->getPropertyType($property);
145 145
             $mode = $attribute->mode;
146 146
 
147
-            if ($mode === null) {
147
+            if ($mode === null){
148 148
                 $mode = $this->guessOptionMode($type, $property);
149 149
             }
150 150
 
151
-            if ($mode === InputOption::VALUE_NONE || $mode === InputOption::VALUE_NEGATABLE) {
152
-                if ($type->getName() !== 'bool') {
151
+            if ($mode === InputOption::VALUE_NONE || $mode === InputOption::VALUE_NEGATABLE){
152
+                if ($type->getName() !== 'bool'){
153 153
                     throw new ConfiguratorException(
154 154
                         'Options properties with mode `VALUE_NONE` or `VALUE_NEGATABLE` must be bool!'
155 155
                     );
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
                 name: $attribute->name ?? $property->getName(),
163 163
                 shortcut: $attribute->shortcut,
164 164
                 mode: $mode,
165
-                description: (string) $attribute->description,
165
+                description: (string)$attribute->description,
166 166
                 default: $hasDefaultValue ? $property->getDefaultValue() : null,
167
-                suggestedValues: $attribute->suggestedValues
167
+                suggestedValues : $attribute->suggestedValues
168 168
             );
169 169
         }
170 170
 
@@ -175,37 +175,37 @@  discard block
 block discarded – undo
175 175
     {
176 176
         $type = $property->hasType() ? $property->getType() : null;
177 177
 
178
-        if (!$type instanceof \ReflectionNamedType || $value === null) {
178
+        if (!$type instanceof \ReflectionNamedType || $value === null){
179 179
             return $value;
180 180
         }
181 181
 
182
-        if (!$type->isBuiltin() && \enum_exists($type->getName())) {
183
-            try {
182
+        if (!$type->isBuiltin() && \enum_exists($type->getName())){
183
+            try{
184 184
                 /** @var class-string<\BackedEnum> $enum */
185 185
                 $enum = $type->getName();
186 186
 
187 187
                 return $enum::from($value);
188
-            } catch (\Throwable) {
188
+            }catch (\Throwable){
189 189
                 throw new ConfiguratorException(\sprintf('Wrong option value. Allowed options: `%s`.', \implode(
190 190
                     '`, `',
191
-                    \array_map(static fn (\BackedEnum $item): string => (string) $item->value, $enum::cases())
191
+                    \array_map(static fn (\BackedEnum $item): string => (string)$item->value, $enum::cases())
192 192
                 )));
193 193
             }
194 194
         }
195 195
 
196 196
         return match ($type->getName()) {
197
-            'int' => (int) $value,
198
-            'string' => (string) $value,
199
-            'bool' => (bool) $value,
200
-            'float' => (float) $value,
201
-            'array' => (array) $value,
197
+            'int' => (int)$value,
198
+            'string' => (string)$value,
199
+            'bool' => (bool)$value,
200
+            'float' => (float)$value,
201
+            'array' => (array)$value,
202 202
             default => $value
203 203
         };
204 204
     }
205 205
 
206 206
     private function getPropertyType(\ReflectionProperty $property): \ReflectionNamedType
207 207
     {
208
-        if (!$property->hasType()) {
208
+        if (!$property->hasType()){
209 209
             throw new ConfiguratorException(
210 210
                 \sprintf('Please, specify the type for the `%s` property!', $property->getName())
211 211
             );
@@ -213,23 +213,23 @@  discard block
 block discarded – undo
213 213
 
214 214
         $type = $property->getType();
215 215
 
216
-        if ($type instanceof \ReflectionIntersectionType) {
216
+        if ($type instanceof \ReflectionIntersectionType){
217 217
             throw new ConfiguratorException(\sprintf('Invalid type for the `%s` property.', $property->getName()));
218 218
         }
219 219
 
220
-        if ($type instanceof \ReflectionUnionType) {
221
-            foreach ($type->getTypes() as $type) {
222
-                if ($type instanceof \ReflectionNamedType && $type->isBuiltin()) {
220
+        if ($type instanceof \ReflectionUnionType){
221
+            foreach ($type->getTypes() as $type){
222
+                if ($type instanceof \ReflectionNamedType && $type->isBuiltin()){
223 223
                     return $type;
224 224
                 }
225 225
             }
226 226
         }
227 227
 
228
-        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin() && \enum_exists($type->getName())) {
228
+        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin() && \enum_exists($type->getName())){
229 229
             return $type;
230 230
         }
231 231
 
232
-        if ($type instanceof \ReflectionNamedType && $type->isBuiltin() && $type->getName() !== 'object') {
232
+        if ($type instanceof \ReflectionNamedType && $type->isBuiltin() && $type->getName() !== 'object'){
233 233
             return $type;
234 234
         }
235 235
 
Please login to merge, or discard this patch.
Braces   +59 added lines, -29 removed lines patch added patch discarded remove patch
@@ -37,7 +37,8 @@  discard block
 block discarded – undo
37 37
     {
38 38
         $attribute = $this->reader->firstClassMetadata($reflection, AsCommand::class);
39 39
 
40
-        if ($attribute === null) {
40
+        if ($attribute === null)
41
+        {
41 42
             $attribute = $reflection->getAttributes(SymfonyAsCommand::class)[0]->newInstance();
42 43
         }
43 44
 
@@ -54,13 +55,16 @@  discard block
 block discarded – undo
54 55
     {
55 56
         $reflection = new \ReflectionClass($command);
56 57
 
57
-        foreach ($reflection->getProperties() as $property) {
58
+        foreach ($reflection->getProperties() as $property)
59
+        {
58 60
             $attribute = $this->reader->firstPropertyMetadata($property, Argument::class);
59
-            if ($attribute === null) {
61
+            if ($attribute === null)
62
+            {
60 63
                 continue;
61 64
             }
62 65
 
63
-            if ($input->hasArgument($attribute->name ?? $property->getName())) {
66
+            if ($input->hasArgument($attribute->name ?? $property->getName()))
67
+            {
64 68
                 $property->setValue(
65 69
                     $command,
66 70
                     $this->typecast($input->getArgument($attribute->name ?? $property->getName()), $property)
@@ -68,16 +72,20 @@  discard block
 block discarded – undo
68 72
             }
69 73
         }
70 74
 
71
-        foreach ($reflection->getProperties() as $property) {
75
+        foreach ($reflection->getProperties() as $property)
76
+        {
72 77
             $attribute = $this->reader->firstPropertyMetadata($property, Option::class);
73
-            if ($attribute === null) {
78
+            if ($attribute === null)
79
+            {
74 80
                 continue;
75 81
             }
76 82
 
77
-            if ($input->hasOption($attribute->name ?? $property->getName())) {
83
+            if ($input->hasOption($attribute->name ?? $property->getName()))
84
+            {
78 85
                 $value = $this->typecast($input->getOption($attribute->name ?? $property->getName()), $property);
79 86
 
80
-                if ($value !== null || $this->getPropertyType($property)->allowsNull()) {
87
+                if ($value !== null || $this->getPropertyType($property)->allowsNull())
88
+                {
81 89
                     $property->setValue($command, $value);
82 90
                 }
83 91
             }
@@ -88,9 +96,11 @@  discard block
 block discarded – undo
88 96
     {
89 97
         $result = [];
90 98
         $arrayArgument = null;
91
-        foreach ($reflection->getProperties() as $property) {
99
+        foreach ($reflection->getProperties() as $property)
100
+        {
92 101
             $attribute = $this->reader->firstPropertyMetadata($property, Argument::class);
93
-            if ($attribute === null) {
102
+            if ($attribute === null)
103
+            {
94 104
                 continue;
95 105
             }
96 106
 
@@ -113,19 +123,22 @@  discard block
 block discarded – undo
113 123
                 suggestedValues: $attribute->suggestedValues
114 124
             );
115 125
 
116
-            if ($arrayArgument instanceof \Symfony\Component\Console\Input\InputArgument && $isArray) {
126
+            if ($arrayArgument instanceof \Symfony\Component\Console\Input\InputArgument && $isArray)
127
+            {
117 128
                 throw new ConfiguratorException('There must be only one array argument!');
118 129
             }
119 130
 
120 131
             // It must be used at the end of the argument list.
121
-            if ($isArray) {
132
+            if ($isArray)
133
+            {
122 134
                 $arrayArgument = $argument;
123 135
                 continue;
124 136
             }
125 137
             $result[] = $argument;
126 138
         }
127 139
 
128
-        if ($arrayArgument instanceof \Symfony\Component\Console\Input\InputArgument) {
140
+        if ($arrayArgument instanceof \Symfony\Component\Console\Input\InputArgument)
141
+        {
129 142
             $result[] = $arrayArgument;
130 143
         }
131 144
 
@@ -135,21 +148,26 @@  discard block
 block discarded – undo
135 148
     private function parseOptions(\ReflectionClass $reflection): array
136 149
     {
137 150
         $result = [];
138
-        foreach ($reflection->getProperties() as $property) {
151
+        foreach ($reflection->getProperties() as $property)
152
+        {
139 153
             $attribute = $this->reader->firstPropertyMetadata($property, Option::class);
140
-            if ($attribute === null) {
154
+            if ($attribute === null)
155
+            {
141 156
                 continue;
142 157
             }
143 158
 
144 159
             $type = $this->getPropertyType($property);
145 160
             $mode = $attribute->mode;
146 161
 
147
-            if ($mode === null) {
162
+            if ($mode === null)
163
+            {
148 164
                 $mode = $this->guessOptionMode($type, $property);
149 165
             }
150 166
 
151
-            if ($mode === InputOption::VALUE_NONE || $mode === InputOption::VALUE_NEGATABLE) {
152
-                if ($type->getName() !== 'bool') {
167
+            if ($mode === InputOption::VALUE_NONE || $mode === InputOption::VALUE_NEGATABLE)
168
+            {
169
+                if ($type->getName() !== 'bool')
170
+                {
153 171
                     throw new ConfiguratorException(
154 172
                         'Options properties with mode `VALUE_NONE` or `VALUE_NEGATABLE` must be bool!'
155 173
                     );
@@ -175,17 +193,22 @@  discard block
 block discarded – undo
175 193
     {
176 194
         $type = $property->hasType() ? $property->getType() : null;
177 195
 
178
-        if (!$type instanceof \ReflectionNamedType || $value === null) {
196
+        if (!$type instanceof \ReflectionNamedType || $value === null)
197
+        {
179 198
             return $value;
180 199
         }
181 200
 
182
-        if (!$type->isBuiltin() && \enum_exists($type->getName())) {
183
-            try {
201
+        if (!$type->isBuiltin() && \enum_exists($type->getName()))
202
+        {
203
+            try
204
+            {
184 205
                 /** @var class-string<\BackedEnum> $enum */
185 206
                 $enum = $type->getName();
186 207
 
187 208
                 return $enum::from($value);
188
-            } catch (\Throwable) {
209
+            }
210
+            catch (\Throwable)
211
+            {
189 212
                 throw new ConfiguratorException(\sprintf('Wrong option value. Allowed options: `%s`.', \implode(
190 213
                     '`, `',
191 214
                     \array_map(static fn (\BackedEnum $item): string => (string) $item->value, $enum::cases())
@@ -205,7 +228,8 @@  discard block
 block discarded – undo
205 228
 
206 229
     private function getPropertyType(\ReflectionProperty $property): \ReflectionNamedType
207 230
     {
208
-        if (!$property->hasType()) {
231
+        if (!$property->hasType())
232
+        {
209 233
             throw new ConfiguratorException(
210 234
                 \sprintf('Please, specify the type for the `%s` property!', $property->getName())
211 235
             );
@@ -213,23 +237,29 @@  discard block
 block discarded – undo
213 237
 
214 238
         $type = $property->getType();
215 239
 
216
-        if ($type instanceof \ReflectionIntersectionType) {
240
+        if ($type instanceof \ReflectionIntersectionType)
241
+        {
217 242
             throw new ConfiguratorException(\sprintf('Invalid type for the `%s` property.', $property->getName()));
218 243
         }
219 244
 
220
-        if ($type instanceof \ReflectionUnionType) {
221
-            foreach ($type->getTypes() as $type) {
222
-                if ($type instanceof \ReflectionNamedType && $type->isBuiltin()) {
245
+        if ($type instanceof \ReflectionUnionType)
246
+        {
247
+            foreach ($type->getTypes() as $type)
248
+            {
249
+                if ($type instanceof \ReflectionNamedType && $type->isBuiltin())
250
+                {
223 251
                     return $type;
224 252
                 }
225 253
             }
226 254
         }
227 255
 
228
-        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin() && \enum_exists($type->getName())) {
256
+        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin() && \enum_exists($type->getName()))
257
+        {
229 258
             return $type;
230 259
         }
231 260
 
232
-        if ($type instanceof \ReflectionNamedType && $type->isBuiltin() && $type->getName() !== 'object') {
261
+        if ($type instanceof \ReflectionNamedType && $type->isBuiltin() && $type->getName() !== 'object')
262
+        {
233 263
             return $type;
234 264
         }
235 265
 
Please login to merge, or discard this patch.
src/Streams/src/StreamWrapper.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function stream_eof(): bool
45 45
     {
46
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
46
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface){
47 47
             throw new WrapperException('Stream is not opened.');
48 48
         }
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool
57 57
     {
58
-        if (!isset(self::$uris[$path])) {
58
+        if (!isset(self::$uris[$path])){
59 59
             return false;
60 60
         }
61 61
 
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
     /**
71 71
      * Read data from StreamInterface.
72 72
      */
73
-    public function stream_read(int $length): string|false
73
+    public function stream_read(int $length): string | false
74 74
     {
75
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
75
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface){
76 76
             throw new WrapperException('Stream is not opened.');
77 77
         }
78 78
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function stream_seek(int $offset, int $whence = SEEK_SET): bool
86 86
     {
87
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
87
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface){
88 88
             throw new WrapperException('Stream is not opened.');
89 89
         }
90 90
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function stream_stat(): array
104 104
     {
105
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
105
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface){
106 106
             throw new WrapperException('Stream is not opened.');
107 107
         }
108 108
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function stream_tell(): int
116 116
     {
117
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
117
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface){
118 118
             throw new WrapperException('Stream is not opened.');
119 119
         }
120 120
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function stream_write(string $data): int
130 130
     {
131
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
131
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface){
132 132
             throw new WrapperException('Stream is not opened.');
133 133
         }
134 134
 
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
      *
141 141
      * @see stat()
142 142
      */
143
-    public function url_stat(string $path, int $flag): array|false
143
+    public function url_stat(string $path, int $flag): array | false
144 144
     {
145
-        try {
146
-            if (isset(self::$uris[$path])) {
145
+        try{
146
+            if (isset(self::$uris[$path])){
147 147
                 return $this->getStreamStats(self::$uris[$path]);
148 148
             }
149
-        } catch (\Throwable $e) {
150
-            if (($flag & \STREAM_URL_STAT_QUIET) === \STREAM_URL_STAT_QUIET) {
149
+        }catch (\Throwable $e){
150
+            if (($flag & \STREAM_URL_STAT_QUIET) === \STREAM_URL_STAT_QUIET){
151 151
                 return false;
152 152
             }
153 153
             \trigger_error($e->getMessage(), \E_USER_ERROR);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public static function register(): void
163 163
     {
164
-        if (self::$registered) {
164
+        if (self::$registered){
165 165
             return;
166 166
         }
167 167
 
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
     /**
174 174
      * Check if given uri or stream has been allocated.
175 175
      */
176
-    public static function has(StreamInterface|string $file): bool
176
+    public static function has(StreamInterface | string $file): bool
177 177
     {
178
-        if ($file instanceof StreamInterface) {
179
-            $file = 'spiral://' . \spl_object_hash($file);
178
+        if ($file instanceof StreamInterface){
179
+            $file = 'spiral://'.\spl_object_hash($file);
180 180
         }
181 181
 
182 182
         return isset(self::$uris[$file]);
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
     public static function getResource(StreamInterface $stream)
192 192
     {
193 193
         $mode = null;
194
-        if ($stream->isReadable()) {
194
+        if ($stream->isReadable()){
195 195
             $mode = 'r';
196 196
         }
197 197
 
198
-        if ($stream->isWritable()) {
198
+        if ($stream->isWritable()){
199 199
             $mode = !empty($mode) ? 'r+' : 'w';
200 200
         }
201 201
 
202
-        if (empty($mode)) {
202
+        if (empty($mode)){
203 203
             throw new WrapperException('Stream is not available in read or write modes');
204 204
         }
205 205
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     {
214 214
         self::register();
215 215
 
216
-        $uri = 'spiral://' . \spl_object_hash($stream);
216
+        $uri = 'spiral://'.\spl_object_hash($stream);
217 217
         self::$uris[$uri] = $stream;
218 218
 
219 219
         return $uri;
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
      *
226 226
      * @param string|StreamInterface $file String uri or StreamInterface.
227 227
      */
228
-    public static function release(StreamInterface|string $file): void
228
+    public static function release(StreamInterface | string $file): void
229 229
     {
230
-        if ($file instanceof StreamInterface) {
231
-            $file = 'spiral://' . \spl_object_hash($file);
230
+        if ($file instanceof StreamInterface){
231
+            $file = 'spiral://'.\spl_object_hash($file);
232 232
         }
233 233
 
234 234
         unset(self::$uris[$file]);
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
     private function getStreamStats(StreamInterface $stream): array
241 241
     {
242 242
         $mode = $this->mode;
243
-        if (empty($mode)) {
244
-            if ($stream->isReadable()) {
243
+        if (empty($mode)){
244
+            if ($stream->isReadable()){
245 245
                 $mode = 'r';
246 246
             }
247 247
 
248
-            if ($stream->isWritable()) {
248
+            if ($stream->isWritable()){
249 249
                 $mode = !empty($mode) ? 'r+' : 'w';
250 250
             }
251 251
         }
Please login to merge, or discard this patch.
Braces   +41 added lines, -20 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function stream_eof(): bool
45 45
     {
46
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
46
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface)
47
+        {
47 48
             throw new WrapperException('Stream is not opened.');
48 49
         }
49 50
 
@@ -55,7 +56,8 @@  discard block
 block discarded – undo
55 56
      */
56 57
     public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool
57 58
     {
58
-        if (!isset(self::$uris[$path])) {
59
+        if (!isset(self::$uris[$path]))
60
+        {
59 61
             return false;
60 62
         }
61 63
 
@@ -72,7 +74,8 @@  discard block
 block discarded – undo
72 74
      */
73 75
     public function stream_read(int $length): string|false
74 76
     {
75
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
77
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface)
78
+        {
76 79
             throw new WrapperException('Stream is not opened.');
77 80
         }
78 81
 
@@ -84,7 +87,8 @@  discard block
 block discarded – undo
84 87
      */
85 88
     public function stream_seek(int $offset, int $whence = SEEK_SET): bool
86 89
     {
87
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
90
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface)
91
+        {
88 92
             throw new WrapperException('Stream is not opened.');
89 93
         }
90 94
 
@@ -102,7 +106,8 @@  discard block
 block discarded – undo
102 106
      */
103 107
     public function stream_stat(): array
104 108
     {
105
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
109
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface)
110
+        {
106 111
             throw new WrapperException('Stream is not opened.');
107 112
         }
108 113
 
@@ -114,7 +119,8 @@  discard block
 block discarded – undo
114 119
      */
115 120
     public function stream_tell(): int
116 121
     {
117
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
122
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface)
123
+        {
118 124
             throw new WrapperException('Stream is not opened.');
119 125
         }
120 126
 
@@ -128,7 +134,8 @@  discard block
 block discarded – undo
128 134
      */
129 135
     public function stream_write(string $data): int
130 136
     {
131
-        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface) {
137
+        if (!$this->stream instanceof \Psr\Http\Message\StreamInterface)
138
+        {
132 139
             throw new WrapperException('Stream is not opened.');
133 140
         }
134 141
 
@@ -142,12 +149,17 @@  discard block
 block discarded – undo
142 149
      */
143 150
     public function url_stat(string $path, int $flag): array|false
144 151
     {
145
-        try {
146
-            if (isset(self::$uris[$path])) {
152
+        try
153
+        {
154
+            if (isset(self::$uris[$path]))
155
+            {
147 156
                 return $this->getStreamStats(self::$uris[$path]);
148 157
             }
149
-        } catch (\Throwable $e) {
150
-            if (($flag & \STREAM_URL_STAT_QUIET) === \STREAM_URL_STAT_QUIET) {
158
+        }
159
+        catch (\Throwable $e)
160
+        {
161
+            if (($flag & \STREAM_URL_STAT_QUIET) === \STREAM_URL_STAT_QUIET)
162
+            {
151 163
                 return false;
152 164
             }
153 165
             \trigger_error($e->getMessage(), \E_USER_ERROR);
@@ -161,7 +173,8 @@  discard block
 block discarded – undo
161 173
      */
162 174
     public static function register(): void
163 175
     {
164
-        if (self::$registered) {
176
+        if (self::$registered)
177
+        {
165 178
             return;
166 179
         }
167 180
 
@@ -175,7 +188,8 @@  discard block
 block discarded – undo
175 188
      */
176 189
     public static function has(StreamInterface|string $file): bool
177 190
     {
178
-        if ($file instanceof StreamInterface) {
191
+        if ($file instanceof StreamInterface)
192
+        {
179 193
             $file = 'spiral://' . \spl_object_hash($file);
180 194
         }
181 195
 
@@ -191,15 +205,18 @@  discard block
 block discarded – undo
191 205
     public static function getResource(StreamInterface $stream)
192 206
     {
193 207
         $mode = null;
194
-        if ($stream->isReadable()) {
208
+        if ($stream->isReadable())
209
+        {
195 210
             $mode = 'r';
196 211
         }
197 212
 
198
-        if ($stream->isWritable()) {
213
+        if ($stream->isWritable())
214
+        {
199 215
             $mode = !empty($mode) ? 'r+' : 'w';
200 216
         }
201 217
 
202
-        if (empty($mode)) {
218
+        if (empty($mode))
219
+        {
203 220
             throw new WrapperException('Stream is not available in read or write modes');
204 221
         }
205 222
 
@@ -227,7 +244,8 @@  discard block
 block discarded – undo
227 244
      */
228 245
     public static function release(StreamInterface|string $file): void
229 246
     {
230
-        if ($file instanceof StreamInterface) {
247
+        if ($file instanceof StreamInterface)
248
+        {
231 249
             $file = 'spiral://' . \spl_object_hash($file);
232 250
         }
233 251
 
@@ -240,12 +258,15 @@  discard block
 block discarded – undo
240 258
     private function getStreamStats(StreamInterface $stream): array
241 259
     {
242 260
         $mode = $this->mode;
243
-        if (empty($mode)) {
244
-            if ($stream->isReadable()) {
261
+        if (empty($mode))
262
+        {
263
+            if ($stream->isReadable())
264
+            {
245 265
                 $mode = 'r';
246 266
             }
247 267
 
248
-            if ($stream->isWritable()) {
268
+            if ($stream->isWritable())
269
+            {
249 270
                 $mode = !empty($mode) ? 'r+' : 'w';
250 271
             }
251 272
         }
Please login to merge, or discard this patch.
src/Router/src/Router.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
         private readonly ContainerInterface $container,
53 53
         private readonly ?EventDispatcherInterface $eventDispatcher = null,
54 54
         ?TracerInterface $tracer = null,
55
-    ) {
55
+    ){
56 56
         $this->tracer = $tracer ?? new NullTracer();
57
-        $this->basePath = '/' . \ltrim($basePath, '/');
57
+        $this->basePath = '/'.\ltrim($basePath, '/');
58 58
     }
59 59
 
60 60
     /**
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
         return $this->tracer->trace(
69 69
             name: 'Routing',
70 70
             callback: function (SpanInterface $span) use ($request): ResponseInterface {
71
-                try {
71
+                try{
72 72
                     $route = $this->matchRoute($request, $routeName);
73
-                } catch (RouteException $e) {
73
+                }catch (RouteException $e){
74 74
                     throw new RouterException('Invalid route definition', $e->getCode(), $e);
75 75
                 }
76 76
 
77
-                if (!$route instanceof \Spiral\Router\RouteInterface) {
77
+                if (!$route instanceof \Spiral\Router\RouteInterface){
78 78
                     $this->eventDispatcher?->dispatch(new RouteNotFound($request));
79 79
                     throw new RouteNotFoundException($request->getUri());
80 80
                 }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
     public function getRoute(string $name): RouteInterface
111 111
     {
112
-        if (isset($this->routes[$name])) {
112
+        if (isset($this->routes[$name])){
113 113
             return $this->routes[$name];
114 114
         }
115 115
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
     public function getRoutes(): array
120 120
     {
121
-        if ($this->default instanceof \Spiral\Router\RouteInterface) {
121
+        if ($this->default instanceof \Spiral\Router\RouteInterface){
122 122
             return $this->routes + [null => $this->default];
123 123
         }
124 124
 
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 
128 128
     public function uri(string $route, iterable $parameters = []): UriInterface
129 129
     {
130
-        try {
130
+        try{
131 131
             return $this->getRoute($route)->uri($parameters);
132
-        } catch (UndefinedRouteException) {
132
+        }catch (UndefinedRouteException){
133 133
             //In some cases route name can be provided as controller:action pair, we can try to
134 134
             //generate such route automatically based on our default/fallback route
135 135
             return $this->castRoute($route)->uri($parameters);
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
         /** @var GroupRegistry $groups */
142 142
         $groups = $this->container->get(GroupRegistry::class);
143 143
 
144
-        foreach ($routes->getCollection() as $name => $configurator) {
144
+        foreach ($routes->getCollection() as $name => $configurator){
145 145
             $target = $configurator->target;
146
-            if ($configurator->core !== null && $target instanceof AbstractTarget) {
146
+            if ($configurator->core !== null && $target instanceof AbstractTarget){
147 147
                 $target = $target->withCore($configurator->core);
148 148
             }
149 149
 
@@ -152,21 +152,21 @@  discard block
 block discarded – undo
152 152
                 : \ltrim($configurator->pattern, '/');
153 153
             $route = new Route($pattern, $target, $configurator->defaults);
154 154
 
155
-            if ($configurator->middleware !== null) {
155
+            if ($configurator->middleware !== null){
156 156
                 $route = $route->withMiddleware(...$configurator->middleware);
157 157
             }
158 158
 
159
-            if ($configurator->methods !== null) {
159
+            if ($configurator->methods !== null){
160 160
                 $route = $route->withVerbs(...$configurator->methods);
161 161
             }
162 162
 
163
-            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) {
163
+            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME){
164 164
                 $group = $groups->getGroup($configurator->group ?? $groups->getDefaultGroup());
165 165
                 $group->setPrefix($configurator->prefix);
166 166
                 $group->addRoute($name, $route);
167 167
             }
168 168
 
169
-            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) {
169
+            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME){
170 170
                 $this->setDefault($route);
171 171
             }
172 172
         }
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
      */
178 178
     protected function matchRoute(ServerRequestInterface $request, ?string &$routeName = null): ?RouteInterface
179 179
     {
180
-        foreach ($this->routes as $name => $route) {
180
+        foreach ($this->routes as $name => $route){
181 181
             // Matched route will return new route instance with matched parameters
182 182
             $matched = $route->match($request);
183 183
 
184
-            if ($matched !== null) {
184
+            if ($matched !== null){
185 185
                 $routeName = $name;
186 186
                 return $matched;
187 187
             }
188 188
         }
189 189
 
190
-        if ($this->default instanceof \Spiral\Router\RouteInterface) {
190
+        if ($this->default instanceof \Spiral\Router\RouteInterface){
191 191
             return $this->default->match($request);
192 192
         }
193 193
 
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
      */
201 201
     protected function configure(RouteInterface $route): RouteInterface
202 202
     {
203
-        if ($route instanceof ContainerizedInterface && !$route->hasContainer()) {
203
+        if ($route instanceof ContainerizedInterface && !$route->hasContainer()){
204 204
             // isolating route in a given container
205 205
             $route = $route->withContainer($this->container);
206 206
         }
207 207
 
208
-        try {
208
+        try{
209 209
             $uriHandler = $route->getUriHandler();
210
-        } catch (\Throwable) {
210
+        }catch (\Throwable){
211 211
             $uriHandler = $this->uriHandler;
212 212
         }
213 213
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                 $route,
231 231
                 $matches
232 232
             )
233
-        ) {
233
+        ){
234 234
             throw new UndefinedRouteException(
235 235
                 "Unable to locate route or use default route with 'name/controller:action' pattern"
236 236
             );
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
         /**
240 240
          * @var Matches $matches
241 241
          */
242
-        if (!empty($matches['name'])) {
242
+        if (!empty($matches['name'])){
243 243
             $routeObject = $this->getRoute($matches['name']);
244
-        } elseif ($this->default instanceof \Spiral\Router\RouteInterface) {
244
+        } elseif ($this->default instanceof \Spiral\Router\RouteInterface){
245 245
             $routeObject = $this->default;
246
-        } else {
246
+        }else{
247 247
             throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route));
248 248
         }
249 249
 
Please login to merge, or discard this patch.
Braces   +49 added lines, -22 removed lines patch added patch discarded remove patch
@@ -68,13 +68,17 @@  discard block
 block discarded – undo
68 68
         return $this->tracer->trace(
69 69
             name: 'Routing',
70 70
             callback: function (SpanInterface $span) use ($request): ResponseInterface {
71
-                try {
71
+                try
72
+                {
72 73
                     $route = $this->matchRoute($request, $routeName);
73
-                } catch (RouteException $e) {
74
+                }
75
+                catch (RouteException $e)
76
+                {
74 77
                     throw new RouterException('Invalid route definition', $e->getCode(), $e);
75 78
                 }
76 79
 
77
-                if (!$route instanceof \Spiral\Router\RouteInterface) {
80
+                if (!$route instanceof \Spiral\Router\RouteInterface)
81
+                {
78 82
                     $this->eventDispatcher?->dispatch(new RouteNotFound($request));
79 83
                     throw new RouteNotFoundException($request->getUri());
80 84
                 }
@@ -109,7 +113,8 @@  discard block
 block discarded – undo
109 113
 
110 114
     public function getRoute(string $name): RouteInterface
111 115
     {
112
-        if (isset($this->routes[$name])) {
116
+        if (isset($this->routes[$name]))
117
+        {
113 118
             return $this->routes[$name];
114 119
         }
115 120
 
@@ -118,7 +123,8 @@  discard block
 block discarded – undo
118 123
 
119 124
     public function getRoutes(): array
120 125
     {
121
-        if ($this->default instanceof \Spiral\Router\RouteInterface) {
126
+        if ($this->default instanceof \Spiral\Router\RouteInterface)
127
+        {
122 128
             return $this->routes + [null => $this->default];
123 129
         }
124 130
 
@@ -127,9 +133,12 @@  discard block
 block discarded – undo
127 133
 
128 134
     public function uri(string $route, iterable $parameters = []): UriInterface
129 135
     {
130
-        try {
136
+        try
137
+        {
131 138
             return $this->getRoute($route)->uri($parameters);
132
-        } catch (UndefinedRouteException) {
139
+        }
140
+        catch (UndefinedRouteException)
141
+        {
133 142
             //In some cases route name can be provided as controller:action pair, we can try to
134 143
             //generate such route automatically based on our default/fallback route
135 144
             return $this->castRoute($route)->uri($parameters);
@@ -141,9 +150,11 @@  discard block
 block discarded – undo
141 150
         /** @var GroupRegistry $groups */
142 151
         $groups = $this->container->get(GroupRegistry::class);
143 152
 
144
-        foreach ($routes->getCollection() as $name => $configurator) {
153
+        foreach ($routes->getCollection() as $name => $configurator)
154
+        {
145 155
             $target = $configurator->target;
146
-            if ($configurator->core !== null && $target instanceof AbstractTarget) {
156
+            if ($configurator->core !== null && $target instanceof AbstractTarget)
157
+            {
147 158
                 $target = $target->withCore($configurator->core);
148 159
             }
149 160
 
@@ -152,21 +163,25 @@  discard block
 block discarded – undo
152 163
                 : \ltrim($configurator->pattern, '/');
153 164
             $route = new Route($pattern, $target, $configurator->defaults);
154 165
 
155
-            if ($configurator->middleware !== null) {
166
+            if ($configurator->middleware !== null)
167
+            {
156 168
                 $route = $route->withMiddleware(...$configurator->middleware);
157 169
             }
158 170
 
159
-            if ($configurator->methods !== null) {
171
+            if ($configurator->methods !== null)
172
+            {
160 173
                 $route = $route->withVerbs(...$configurator->methods);
161 174
             }
162 175
 
163
-            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME) {
176
+            if (!isset($this->routes[$name]) && $name !== RoutingConfigurator::DEFAULT_ROUTE_NAME)
177
+            {
164 178
                 $group = $groups->getGroup($configurator->group ?? $groups->getDefaultGroup());
165 179
                 $group->setPrefix($configurator->prefix);
166 180
                 $group->addRoute($name, $route);
167 181
             }
168 182
 
169
-            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME) {
183
+            if ($name === RoutingConfigurator::DEFAULT_ROUTE_NAME)
184
+            {
170 185
                 $this->setDefault($route);
171 186
             }
172 187
         }
@@ -177,17 +192,20 @@  discard block
 block discarded – undo
177 192
      */
178 193
     protected function matchRoute(ServerRequestInterface $request, ?string &$routeName = null): ?RouteInterface
179 194
     {
180
-        foreach ($this->routes as $name => $route) {
195
+        foreach ($this->routes as $name => $route)
196
+        {
181 197
             // Matched route will return new route instance with matched parameters
182 198
             $matched = $route->match($request);
183 199
 
184
-            if ($matched !== null) {
200
+            if ($matched !== null)
201
+            {
185 202
                 $routeName = $name;
186 203
                 return $matched;
187 204
             }
188 205
         }
189 206
 
190
-        if ($this->default instanceof \Spiral\Router\RouteInterface) {
207
+        if ($this->default instanceof \Spiral\Router\RouteInterface)
208
+        {
191 209
             return $this->default->match($request);
192 210
         }
193 211
 
@@ -200,14 +218,18 @@  discard block
 block discarded – undo
200 218
      */
201 219
     protected function configure(RouteInterface $route): RouteInterface
202 220
     {
203
-        if ($route instanceof ContainerizedInterface && !$route->hasContainer()) {
221
+        if ($route instanceof ContainerizedInterface && !$route->hasContainer())
222
+        {
204 223
             // isolating route in a given container
205 224
             $route = $route->withContainer($this->container);
206 225
         }
207 226
 
208
-        try {
227
+        try
228
+        {
209 229
             $uriHandler = $route->getUriHandler();
210
-        } catch (\Throwable) {
230
+        }
231
+        catch (\Throwable)
232
+        {
211 233
             $uriHandler = $this->uriHandler;
212 234
         }
213 235
 
@@ -239,11 +261,16 @@  discard block
 block discarded – undo
239 261
         /**
240 262
          * @var Matches $matches
241 263
          */
242
-        if (!empty($matches['name'])) {
264
+        if (!empty($matches['name']))
265
+        {
243 266
             $routeObject = $this->getRoute($matches['name']);
244
-        } elseif ($this->default instanceof \Spiral\Router\RouteInterface) {
267
+        }
268
+        elseif ($this->default instanceof \Spiral\Router\RouteInterface)
269
+        {
245 270
             $routeObject = $this->default;
246
-        } else {
271
+        }
272
+        else
273
+        {
247 274
             throw new UndefinedRouteException(\sprintf('Unable to locate route candidate for `%s`', $route));
248 275
         }
249 276
 
Please login to merge, or discard this patch.
src/Router/src/Route.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function __construct(
53 53
         string $pattern,
54
-        string|callable|RequestHandlerInterface|TargetInterface $target,
54
+        string | callable | RequestHandlerInterface | TargetInterface $target,
55 55
         array $defaults = []
56
-    ) {
56
+    ){
57 57
         parent::__construct(
58 58
             $pattern,
59 59
             $target instanceof TargetInterface
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function withUriHandler(UriHandler $uriHandler): static
71 71
     {
72
-        if ($this->target instanceof TargetInterface) {
72
+        if ($this->target instanceof TargetInterface){
73 73
             $uriHandler = $uriHandler->withConstrains(
74 74
                 $this->target->getConstrains(),
75 75
                 $this->defaults,
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $route = clone $this;
88 88
         $route->container = $container;
89 89
 
90
-        if ($route->target instanceof TargetInterface) {
90
+        if ($route->target instanceof TargetInterface){
91 91
             $route->target = clone $route->target;
92 92
         }
93 93
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function handle(ServerRequestInterface $request): ResponseInterface
116 116
     {
117
-        if (!$this->requestHandler instanceof \Psr\Http\Server\RequestHandlerInterface) {
117
+        if (!$this->requestHandler instanceof \Psr\Http\Server\RequestHandlerInterface){
118 118
             $this->requestHandler = $this->requestHandler();
119 119
         }
120 120
 
@@ -134,25 +134,25 @@  discard block
 block discarded – undo
134 134
             'Unable to configure route pipeline without associated container.',
135 135
         );
136 136
 
137
-        if ($this->target instanceof TargetInterface) {
138
-            try {
137
+        if ($this->target instanceof TargetInterface){
138
+            try{
139 139
                 \assert($this->matches !== null);
140 140
                 return $this->target->getHandler($this->container, $this->matches);
141
-            } catch (TargetException $e) {
141
+            }catch (TargetException $e){
142 142
                 throw new RouteException('Invalid target resolution', $e->getCode(), $e);
143 143
             }
144 144
         }
145 145
 
146
-        if ($this->target instanceof RequestHandlerInterface) {
146
+        if ($this->target instanceof RequestHandlerInterface){
147 147
             return $this->target;
148 148
         }
149 149
 
150
-        try {
150
+        try{
151 151
             $target = \is_string($this->target)
152 152
                 ? $this->container->get($this->target)
153 153
                 : $this->target;
154 154
 
155
-            if ($target instanceof RequestHandlerInterface) {
155
+            if ($target instanceof RequestHandlerInterface){
156 156
                 return $target;
157 157
             }
158 158
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 $target,
161 161
                 $this->container->get(ResponseFactoryInterface::class)
162 162
             );
163
-        } catch (ContainerExceptionInterface $e) {
163
+        }catch (ContainerExceptionInterface $e){
164 164
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
165 165
         }
166 166
     }
Please login to merge, or discard this patch.
Braces   +22 added lines, -10 removed lines patch added patch discarded remove patch
@@ -69,7 +69,8 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function withUriHandler(UriHandler $uriHandler): static
71 71
     {
72
-        if ($this->target instanceof TargetInterface) {
72
+        if ($this->target instanceof TargetInterface)
73
+        {
73 74
             $uriHandler = $uriHandler->withConstrains(
74 75
                 $this->target->getConstrains(),
75 76
                 $this->defaults,
@@ -87,7 +88,8 @@  discard block
 block discarded – undo
87 88
         $route = clone $this;
88 89
         $route->container = $container;
89 90
 
90
-        if ($route->target instanceof TargetInterface) {
91
+        if ($route->target instanceof TargetInterface)
92
+        {
91 93
             $route->target = clone $route->target;
92 94
         }
93 95
 
@@ -114,7 +116,8 @@  discard block
 block discarded – undo
114 116
      */
115 117
     public function handle(ServerRequestInterface $request): ResponseInterface
116 118
     {
117
-        if (!$this->requestHandler instanceof \Psr\Http\Server\RequestHandlerInterface) {
119
+        if (!$this->requestHandler instanceof \Psr\Http\Server\RequestHandlerInterface)
120
+        {
118 121
             $this->requestHandler = $this->requestHandler();
119 122
         }
120 123
 
@@ -134,25 +137,32 @@  discard block
 block discarded – undo
134 137
             'Unable to configure route pipeline without associated container.',
135 138
         );
136 139
 
137
-        if ($this->target instanceof TargetInterface) {
138
-            try {
140
+        if ($this->target instanceof TargetInterface)
141
+        {
142
+            try
143
+            {
139 144
                 \assert($this->matches !== null);
140 145
                 return $this->target->getHandler($this->container, $this->matches);
141
-            } catch (TargetException $e) {
146
+            }
147
+            catch (TargetException $e)
148
+            {
142 149
                 throw new RouteException('Invalid target resolution', $e->getCode(), $e);
143 150
             }
144 151
         }
145 152
 
146
-        if ($this->target instanceof RequestHandlerInterface) {
153
+        if ($this->target instanceof RequestHandlerInterface)
154
+        {
147 155
             return $this->target;
148 156
         }
149 157
 
150
-        try {
158
+        try
159
+        {
151 160
             $target = \is_string($this->target)
152 161
                 ? $this->container->get($this->target)
153 162
                 : $this->target;
154 163
 
155
-            if ($target instanceof RequestHandlerInterface) {
164
+            if ($target instanceof RequestHandlerInterface)
165
+            {
156 166
                 return $target;
157 167
             }
158 168
 
@@ -160,7 +170,9 @@  discard block
 block discarded – undo
160 170
                 $target,
161 171
                 $this->container->get(ResponseFactoryInterface::class)
162 172
             );
163
-        } catch (ContainerExceptionInterface $e) {
173
+        }
174
+        catch (ContainerExceptionInterface $e)
175
+        {
164 176
             throw new RouteException($e->getMessage(), $e->getCode(), $e);
165 177
         }
166 178
     }
Please login to merge, or discard this patch.
src/Router/src/Target/AbstractTarget.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     // Automatically prepend HTTP verb to all action names.
28 28
     public const RESTFUL = 1;
29 29
 
30
-    private HandlerInterface|CoreInterface|null $pipeline = null;
30
+    private HandlerInterface | CoreInterface | null $pipeline = null;
31 31
     private ?CoreHandler $handler = null;
32 32
     private bool $verbActions;
33 33
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         private array $constrains,
37 37
         int $options = 0,
38 38
         private string $defaultAction = 'index'
39
-    ) {
39
+    ){
40 40
         $this->verbActions = ($options & self::RESTFUL) === self::RESTFUL;
41 41
     }
42 42
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * @mutation-free
55 55
      * @deprecated Use {@see withHandler()} instead.
56 56
      */
57
-    public function withCore(HandlerInterface|CoreInterface $core): TargetInterface
57
+    public function withCore(HandlerInterface | CoreInterface $core): TargetInterface
58 58
     {
59 59
         $target = clone $this;
60 60
         $target->pipeline = $core;
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 
87 87
     protected function coreHandler(ContainerInterface $container): CoreHandler
88 88
     {
89
-        if ($this->handler instanceof \Spiral\Router\CoreHandler) {
89
+        if ($this->handler instanceof \Spiral\Router\CoreHandler){
90 90
             return $this->handler;
91 91
         }
92 92
 
93 93
         $scope = Proxy::create(new \ReflectionClass(ScopeInterface::class), null, new \Spiral\Core\Attribute\Proxy());
94 94
 
95
-        try {
95
+        try{
96 96
             // construct on demand
97 97
             $this->handler = new CoreHandler(
98 98
                 match (false) {
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             );
107 107
 
108 108
             return $this->handler;
109
-        } catch (ContainerExceptionInterface $e) {
109
+        }catch (ContainerExceptionInterface $e){
110 110
             throw new TargetException($e->getMessage(), $e->getCode(), $e);
111 111
         }
112 112
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,13 +86,15 @@  discard block
 block discarded – undo
86 86
 
87 87
     protected function coreHandler(ContainerInterface $container): CoreHandler
88 88
     {
89
-        if ($this->handler instanceof \Spiral\Router\CoreHandler) {
89
+        if ($this->handler instanceof \Spiral\Router\CoreHandler)
90
+        {
90 91
             return $this->handler;
91 92
         }
92 93
 
93 94
         $scope = Proxy::create(new \ReflectionClass(ScopeInterface::class), null, new \Spiral\Core\Attribute\Proxy());
94 95
 
95
-        try {
96
+        try
97
+        {
96 98
             // construct on demand
97 99
             $this->handler = new CoreHandler(
98 100
                 match (false) {
@@ -106,7 +108,9 @@  discard block
 block discarded – undo
106 108
             );
107 109
 
108 110
             return $this->handler;
109
-        } catch (ContainerExceptionInterface $e) {
111
+        }
112
+        catch (ContainerExceptionInterface $e)
113
+        {
110 114
             throw new TargetException($e->getMessage(), $e->getCode(), $e);
111 115
         }
112 116
     }
Please login to merge, or discard this patch.
src/Auth/src/AuthContext.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     public function __construct(
19 19
         private readonly ActorProviderInterface $actorProvider,
20 20
         private readonly ?EventDispatcherInterface $eventDispatcher = null
21
-    ) {
21
+    ){
22 22
     }
23 23
 
24 24
     public function start(TokenInterface $token, ?string $transport = null): void
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 
44 44
     public function getActor(): ?object
45 45
     {
46
-        if ($this->closed) {
46
+        if ($this->closed){
47 47
             return null;
48 48
         }
49 49
 
50
-        if ($this->actor === null && $this->token instanceof \Spiral\Auth\TokenInterface) {
50
+        if ($this->actor === null && $this->token instanceof \Spiral\Auth\TokenInterface){
51 51
             $this->actor = $this->actorProvider->getActor($this->token);
52 52
         }
53 53
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,11 +43,13 @@
 block discarded – undo
43 43
 
44 44
     public function getActor(): ?object
45 45
     {
46
-        if ($this->closed) {
46
+        if ($this->closed)
47
+        {
47 48
             return null;
48 49
         }
49 50
 
50
-        if ($this->actor === null && $this->token instanceof \Spiral\Auth\TokenInterface) {
51
+        if ($this->actor === null && $this->token instanceof \Spiral\Auth\TokenInterface)
52
+        {
51 53
             $this->actor = $this->actorProvider->getActor($this->token);
52 54
         }
53 55
 
Please login to merge, or discard this patch.