Passed
Pull Request — master (#1196)
by Abdul Malik
11:01
created
src/Console/src/Command.php 1 patch
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.
src/Console/src/Console.php 1 patch
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.
src/Console/src/Configurator/Attribute/Parser.php 1 patch
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.
src/Streams/src/StreamWrapper.php 1 patch
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.
src/Router/src/Router.php 1 patch
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.
src/Router/src/Route.php 1 patch
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.
src/Router/src/Target/AbstractTarget.php 1 patch
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.
src/Auth/src/AuthContext.php 1 patch
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.
src/Cache/tests/Core/CacheInjectorTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
                     'test' => $this->defaultCache,
79 79
                     'array' => new ArrayStorage(),
80 80
                 ][$name] ?? null;
81
-            if (!$result instanceof \Psr\SimpleCache\CacheInterface) {
81
+            if (!$result instanceof \Psr\SimpleCache\CacheInterface){
82 82
                 throw new NotFoundException();
83 83
             }
84 84
             return $result;
Please login to merge, or discard this patch.