@@ -16,43 +16,43 @@ |
||
| 16 | 16 | |
| 17 | 17 | return RectorConfig::configure() |
| 18 | 18 | ->withPaths([ |
| 19 | - __DIR__ . '/src/*/src', |
|
| 19 | + __DIR__.'/src/*/src', |
|
| 20 | 20 | ]) |
| 21 | 21 | ->withParallel() |
| 22 | 22 | ->withSkip([ |
| 23 | 23 | IfIssetToCoalescingRector::class, |
| 24 | 24 | RemoveUnusedPrivatePropertyRector::class => [ |
| 25 | - __DIR__ . '/src/Scaffolder/src/Command/BootloaderCommand.php', |
|
| 26 | - __DIR__ . '/src/Scaffolder/src/Command/CommandCommand.php', |
|
| 27 | - __DIR__ . '/src/Scaffolder/src/Command/ConfigCommand.php', |
|
| 28 | - __DIR__ . '/src/Scaffolder/src/Command/ControllerCommand.php', |
|
| 29 | - __DIR__ . '/src/Scaffolder/src/Command/FilterCommand.php', |
|
| 30 | - __DIR__ . '/src/Scaffolder/src/Command/JobHandlerCommand.php', |
|
| 31 | - __DIR__ . '/src/Scaffolder/src/Command/MiddlewareCommand.php', |
|
| 25 | + __DIR__.'/src/Scaffolder/src/Command/BootloaderCommand.php', |
|
| 26 | + __DIR__.'/src/Scaffolder/src/Command/CommandCommand.php', |
|
| 27 | + __DIR__.'/src/Scaffolder/src/Command/ConfigCommand.php', |
|
| 28 | + __DIR__.'/src/Scaffolder/src/Command/ControllerCommand.php', |
|
| 29 | + __DIR__.'/src/Scaffolder/src/Command/FilterCommand.php', |
|
| 30 | + __DIR__.'/src/Scaffolder/src/Command/JobHandlerCommand.php', |
|
| 31 | + __DIR__.'/src/Scaffolder/src/Command/MiddlewareCommand.php', |
|
| 32 | 32 | ], |
| 33 | 33 | RemoveUnusedPrivateMethodRector::class => [ |
| 34 | - __DIR__ . '/src/Boot/src/Bootloader/ConfigurationBootloader.php', |
|
| 35 | - __DIR__ . '/src/Broadcasting/src/Bootloader/BroadcastingBootloader.php', |
|
| 36 | - __DIR__ . '/src/Cache/src/Bootloader/CacheBootloader.php', |
|
| 37 | - __DIR__ . '/src/Serializer/src/Bootloader/SerializerBootloader.php', |
|
| 38 | - __DIR__ . '/src/Validation/src/Bootloader/ValidationBootloader.php', |
|
| 34 | + __DIR__.'/src/Boot/src/Bootloader/ConfigurationBootloader.php', |
|
| 35 | + __DIR__.'/src/Broadcasting/src/Bootloader/BroadcastingBootloader.php', |
|
| 36 | + __DIR__.'/src/Cache/src/Bootloader/CacheBootloader.php', |
|
| 37 | + __DIR__.'/src/Serializer/src/Bootloader/SerializerBootloader.php', |
|
| 38 | + __DIR__.'/src/Validation/src/Bootloader/ValidationBootloader.php', |
|
| 39 | 39 | ], |
| 40 | 40 | RemoveUselessVarTagRector::class => [ |
| 41 | - __DIR__ . '/src/Console/src/Traits/HelpersTrait.php', |
|
| 41 | + __DIR__.'/src/Console/src/Traits/HelpersTrait.php', |
|
| 42 | 42 | ], |
| 43 | 43 | RemoveAlwaysTrueIfConditionRector::class => [ |
| 44 | - __DIR__ . '/src/Boot/src/BootloadManager/Initializer.php', |
|
| 45 | - __DIR__ . '/src/Stempler/src/Traverser.php', |
|
| 46 | - __DIR__ . '/src/Prototype/src/NodeVisitors/LocateProperties.php', |
|
| 47 | - __DIR__ . '/src/Prototype/src/NodeVisitors/RemoveTrait.php', |
|
| 48 | - __DIR__ . '/src/Logger/src/ListenerRegistry.php', |
|
| 49 | - __DIR__ . '/src/Stempler/src/Transform/Merge/ExtendsParent.php', |
|
| 44 | + __DIR__.'/src/Boot/src/BootloadManager/Initializer.php', |
|
| 45 | + __DIR__.'/src/Stempler/src/Traverser.php', |
|
| 46 | + __DIR__.'/src/Prototype/src/NodeVisitors/LocateProperties.php', |
|
| 47 | + __DIR__.'/src/Prototype/src/NodeVisitors/RemoveTrait.php', |
|
| 48 | + __DIR__.'/src/Logger/src/ListenerRegistry.php', |
|
| 49 | + __DIR__.'/src/Stempler/src/Transform/Merge/ExtendsParent.php', |
|
| 50 | 50 | ], |
| 51 | 51 | RemoveExtraParametersRector::class => [ |
| 52 | - __DIR__ . '/src/Boot/src/BootloadManager/AbstractBootloadManager.php', |
|
| 52 | + __DIR__.'/src/Boot/src/BootloadManager/AbstractBootloadManager.php', |
|
| 53 | 53 | ], |
| 54 | 54 | RemoveUnusedPrivateMethodParameterRector::class => [ |
| 55 | - __DIR__ . '/src/Core/src/Internal/Factory.php', |
|
| 55 | + __DIR__.'/src/Core/src/Internal/Factory.php', |
|
| 56 | 56 | ], |
| 57 | 57 | |
| 58 | 58 | // to be enabled later after upgrade to 1.2.4 merged |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function stream_eof(): bool |
| 45 | 45 | { |
| 46 | - if ($this->stream === null) { |
|
| 46 | + if ($this->stream === null){ |
|
| 47 | 47 | throw new WrapperException('Stream is not opened.'); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | public function stream_open(string $path, string $mode): 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 |
||
| 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 === null) { |
|
| 75 | + if ($this->stream === null){ |
|
| 76 | 76 | throw new WrapperException('Stream is not opened.'); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function stream_seek(int $offset, int $whence = SEEK_SET): bool |
| 86 | 86 | { |
| 87 | - if ($this->stream === null) { |
|
| 87 | + if ($this->stream === null){ |
|
| 88 | 88 | throw new WrapperException('Stream is not opened.'); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function stream_stat(): array |
| 104 | 104 | { |
| 105 | - if ($this->stream === null) { |
|
| 105 | + if ($this->stream === null){ |
|
| 106 | 106 | throw new WrapperException('Stream is not opened.'); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function stream_tell(): int |
| 116 | 116 | { |
| 117 | - if ($this->stream === null) { |
|
| 117 | + if ($this->stream === null){ |
|
| 118 | 118 | throw new WrapperException('Stream is not opened.'); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public function stream_write(string $data): int |
| 130 | 130 | { |
| 131 | - if ($this->stream === null) { |
|
| 131 | + if ($this->stream === null){ |
|
| 132 | 132 | throw new WrapperException('Stream is not opened.'); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -140,14 +140,14 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -43,7 +43,8 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function stream_eof(): bool |
| 45 | 45 | { |
| 46 | - if ($this->stream === null) { |
|
| 46 | + if ($this->stream === null) |
|
| 47 | + { |
|
| 47 | 48 | throw new WrapperException('Stream is not opened.'); |
| 48 | 49 | } |
| 49 | 50 | |
@@ -55,7 +56,8 @@ discard block |
||
| 55 | 56 | */ |
| 56 | 57 | public function stream_open(string $path, string $mode): 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 |
||
| 72 | 74 | */ |
| 73 | 75 | public function stream_read(int $length): string|false |
| 74 | 76 | { |
| 75 | - if ($this->stream === null) { |
|
| 77 | + if ($this->stream === null) |
|
| 78 | + { |
|
| 76 | 79 | throw new WrapperException('Stream is not opened.'); |
| 77 | 80 | } |
| 78 | 81 | |
@@ -84,7 +87,8 @@ discard block |
||
| 84 | 87 | */ |
| 85 | 88 | public function stream_seek(int $offset, int $whence = SEEK_SET): bool |
| 86 | 89 | { |
| 87 | - if ($this->stream === null) { |
|
| 90 | + if ($this->stream === null) |
|
| 91 | + { |
|
| 88 | 92 | throw new WrapperException('Stream is not opened.'); |
| 89 | 93 | } |
| 90 | 94 | |
@@ -102,7 +106,8 @@ discard block |
||
| 102 | 106 | */ |
| 103 | 107 | public function stream_stat(): array |
| 104 | 108 | { |
| 105 | - if ($this->stream === null) { |
|
| 109 | + if ($this->stream === null) |
|
| 110 | + { |
|
| 106 | 111 | throw new WrapperException('Stream is not opened.'); |
| 107 | 112 | } |
| 108 | 113 | |
@@ -114,7 +119,8 @@ discard block |
||
| 114 | 119 | */ |
| 115 | 120 | public function stream_tell(): int |
| 116 | 121 | { |
| 117 | - if ($this->stream === null) { |
|
| 122 | + if ($this->stream === null) |
|
| 123 | + { |
|
| 118 | 124 | throw new WrapperException('Stream is not opened.'); |
| 119 | 125 | } |
| 120 | 126 | |
@@ -128,7 +134,8 @@ discard block |
||
| 128 | 134 | */ |
| 129 | 135 | public function stream_write(string $data): int |
| 130 | 136 | { |
| 131 | - if ($this->stream === null) { |
|
| 137 | + if ($this->stream === null) |
|
| 138 | + { |
|
| 132 | 139 | throw new WrapperException('Stream is not opened.'); |
| 133 | 140 | } |
| 134 | 141 | |
@@ -142,12 +149,17 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | private readonly FilterProviderInterface $provider, |
| 27 | 27 | private readonly ReaderInterface $reader, |
| 28 | 28 | private readonly Mapper $mapper |
| 29 | - ) { |
|
| 29 | + ){ |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -40,54 +40,54 @@ discard block |
||
| 40 | 40 | $optionalFilters = []; |
| 41 | 41 | $class = new \ReflectionClass($filter); |
| 42 | 42 | |
| 43 | - foreach ($class->getProperties() as $property) { |
|
| 43 | + foreach ($class->getProperties() as $property){ |
|
| 44 | 44 | /** @var object $attribute */ |
| 45 | - foreach ($this->reader->getPropertyMetadata($property) as $attribute) { |
|
| 46 | - if ($attribute instanceof AbstractInput) { |
|
| 45 | + foreach ($this->reader->getPropertyMetadata($property) as $attribute){ |
|
| 46 | + if ($attribute instanceof AbstractInput){ |
|
| 47 | 47 | $value = $attribute->getValue($input, $property); |
| 48 | - try { |
|
| 48 | + try{ |
|
| 49 | 49 | $this->setValue($filter, $property, $value); |
| 50 | - } catch (SetterException $e) { |
|
| 50 | + }catch (SetterException $e){ |
|
| 51 | 51 | $errors[$property->getName()] = $this->createErrorMessage($e, $property, $value); |
| 52 | 52 | } |
| 53 | 53 | $schema[$property->getName()] = $attribute->getSchema($property); |
| 54 | - } elseif ($attribute instanceof NestedFilter) { |
|
| 54 | + } elseif ($attribute instanceof NestedFilter){ |
|
| 55 | 55 | $prefix = $attribute->prefix ?? $property->name; |
| 56 | - try { |
|
| 56 | + try{ |
|
| 57 | 57 | $value = $this->provider->createFilter( |
| 58 | 58 | $attribute->class, |
| 59 | 59 | $input->withPrefix($prefix) |
| 60 | 60 | ); |
| 61 | 61 | |
| 62 | - try { |
|
| 62 | + try{ |
|
| 63 | 63 | $this->setValue($filter, $property, $value); |
| 64 | - } catch (SetterException $e) { |
|
| 64 | + }catch (SetterException $e){ |
|
| 65 | 65 | $errors[$property->getName()] = $this->createErrorMessage($e, $property, $value); |
| 66 | 66 | } |
| 67 | - } catch (ValidationException $e) { |
|
| 68 | - if ($this->allowsNull($property)) { |
|
| 67 | + }catch (ValidationException $e){ |
|
| 68 | + if ($this->allowsNull($property)){ |
|
| 69 | 69 | $this->setValue($filter, $property, null); |
| 70 | 70 | $optionalFilters[] = $property->getName(); |
| 71 | - } else { |
|
| 71 | + }else{ |
|
| 72 | 72 | $errors[$prefix] = $e->errors; |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $schema[$property->getName()] = $attribute->getSchema(); |
| 77 | - } elseif ($attribute instanceof NestedArray) { |
|
| 77 | + } elseif ($attribute instanceof NestedArray){ |
|
| 78 | 78 | $values = $attribute->getValue($input, $property); |
| 79 | 79 | $propertyValues = []; |
| 80 | 80 | |
| 81 | 81 | $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName(); |
| 82 | 82 | |
| 83 | - if (\is_array($values)) { |
|
| 84 | - foreach (\array_keys($values) as $key) { |
|
| 85 | - try { |
|
| 83 | + if (\is_array($values)){ |
|
| 84 | + foreach (\array_keys($values) as $key){ |
|
| 85 | + try{ |
|
| 86 | 86 | $propertyValues[$key] = $this->provider->createFilter( |
| 87 | 87 | $attribute->class, |
| 88 | - $input->withPrefix($prefix . '.' . $key) |
|
| 88 | + $input->withPrefix($prefix.'.'.$key) |
|
| 89 | 89 | ); |
| 90 | - } catch (ValidationException $e) { |
|
| 90 | + }catch (ValidationException $e){ |
|
| 91 | 91 | /** @psalm-suppress InvalidArrayOffset */ |
| 92 | 92 | $errors[$property->getName()][$key] = $e->errors; |
| 93 | 93 | } |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $this->setValue($filter, $property, $propertyValues); |
| 98 | - $schema[$property->getName()] = [$attribute->class, $prefix . '.*']; |
|
| 99 | - } elseif ($attribute instanceof Setter) { |
|
| 98 | + $schema[$property->getName()] = [$attribute->class, $prefix.'.*']; |
|
| 99 | + } elseif ($attribute instanceof Setter){ |
|
| 100 | 100 | $setters[$property->getName()][] = $attribute; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void |
| 109 | 109 | { |
| 110 | - if ($value === null) { |
|
| 110 | + if ($value === null){ |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $setters = $this->reader->getPropertyMetadata($property, Setter::class); |
| 115 | 115 | |
| 116 | - foreach ($setters as $setter) { |
|
| 116 | + foreach ($setters as $setter){ |
|
| 117 | 117 | $value = $setter->updateValue($value); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | ): string { |
| 135 | 135 | $attribute = $this->reader->firstPropertyMetadata($property, CastingErrorMessage::class); |
| 136 | 136 | |
| 137 | - if ($attribute === null) { |
|
| 137 | + if ($attribute === null){ |
|
| 138 | 138 | return $exception->getMessage(); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -40,54 +40,78 @@ discard block |
||
| 40 | 40 | $optionalFilters = []; |
| 41 | 41 | $class = new \ReflectionClass($filter); |
| 42 | 42 | |
| 43 | - foreach ($class->getProperties() as $property) { |
|
| 43 | + foreach ($class->getProperties() as $property) |
|
| 44 | + { |
|
| 44 | 45 | /** @var object $attribute */ |
| 45 | - foreach ($this->reader->getPropertyMetadata($property) as $attribute) { |
|
| 46 | - if ($attribute instanceof AbstractInput) { |
|
| 46 | + foreach ($this->reader->getPropertyMetadata($property) as $attribute) |
|
| 47 | + { |
|
| 48 | + if ($attribute instanceof AbstractInput) |
|
| 49 | + { |
|
| 47 | 50 | $value = $attribute->getValue($input, $property); |
| 48 | - try { |
|
| 51 | + try |
|
| 52 | + { |
|
| 49 | 53 | $this->setValue($filter, $property, $value); |
| 50 | - } catch (SetterException $e) { |
|
| 54 | + } |
|
| 55 | + catch (SetterException $e) |
|
| 56 | + { |
|
| 51 | 57 | $errors[$property->getName()] = $this->createErrorMessage($e, $property, $value); |
| 52 | 58 | } |
| 53 | 59 | $schema[$property->getName()] = $attribute->getSchema($property); |
| 54 | - } elseif ($attribute instanceof NestedFilter) { |
|
| 60 | + } |
|
| 61 | + elseif ($attribute instanceof NestedFilter) |
|
| 62 | + { |
|
| 55 | 63 | $prefix = $attribute->prefix ?? $property->name; |
| 56 | - try { |
|
| 64 | + try |
|
| 65 | + { |
|
| 57 | 66 | $value = $this->provider->createFilter( |
| 58 | 67 | $attribute->class, |
| 59 | 68 | $input->withPrefix($prefix) |
| 60 | 69 | ); |
| 61 | 70 | |
| 62 | - try { |
|
| 71 | + try |
|
| 72 | + { |
|
| 63 | 73 | $this->setValue($filter, $property, $value); |
| 64 | - } catch (SetterException $e) { |
|
| 74 | + } |
|
| 75 | + catch (SetterException $e) |
|
| 76 | + { |
|
| 65 | 77 | $errors[$property->getName()] = $this->createErrorMessage($e, $property, $value); |
| 66 | 78 | } |
| 67 | - } catch (ValidationException $e) { |
|
| 68 | - if ($this->allowsNull($property)) { |
|
| 79 | + } |
|
| 80 | + catch (ValidationException $e) |
|
| 81 | + { |
|
| 82 | + if ($this->allowsNull($property)) |
|
| 83 | + { |
|
| 69 | 84 | $this->setValue($filter, $property, null); |
| 70 | 85 | $optionalFilters[] = $property->getName(); |
| 71 | - } else { |
|
| 86 | + } |
|
| 87 | + else |
|
| 88 | + { |
|
| 72 | 89 | $errors[$prefix] = $e->errors; |
| 73 | 90 | } |
| 74 | 91 | } |
| 75 | 92 | |
| 76 | 93 | $schema[$property->getName()] = $attribute->getSchema(); |
| 77 | - } elseif ($attribute instanceof NestedArray) { |
|
| 94 | + } |
|
| 95 | + elseif ($attribute instanceof NestedArray) |
|
| 96 | + { |
|
| 78 | 97 | $values = $attribute->getValue($input, $property); |
| 79 | 98 | $propertyValues = []; |
| 80 | 99 | |
| 81 | 100 | $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName(); |
| 82 | 101 | |
| 83 | - if (\is_array($values)) { |
|
| 84 | - foreach (\array_keys($values) as $key) { |
|
| 85 | - try { |
|
| 102 | + if (\is_array($values)) |
|
| 103 | + { |
|
| 104 | + foreach (\array_keys($values) as $key) |
|
| 105 | + { |
|
| 106 | + try |
|
| 107 | + { |
|
| 86 | 108 | $propertyValues[$key] = $this->provider->createFilter( |
| 87 | 109 | $attribute->class, |
| 88 | 110 | $input->withPrefix($prefix . '.' . $key) |
| 89 | 111 | ); |
| 90 | - } catch (ValidationException $e) { |
|
| 112 | + } |
|
| 113 | + catch (ValidationException $e) |
|
| 114 | + { |
|
| 91 | 115 | /** @psalm-suppress InvalidArrayOffset */ |
| 92 | 116 | $errors[$property->getName()][$key] = $e->errors; |
| 93 | 117 | } |
@@ -96,7 +120,9 @@ discard block |
||
| 96 | 120 | |
| 97 | 121 | $this->setValue($filter, $property, $propertyValues); |
| 98 | 122 | $schema[$property->getName()] = [$attribute->class, $prefix . '.*']; |
| 99 | - } elseif ($attribute instanceof Setter) { |
|
| 123 | + } |
|
| 124 | + elseif ($attribute instanceof Setter) |
|
| 125 | + { |
|
| 100 | 126 | $setters[$property->getName()][] = $attribute; |
| 101 | 127 | } |
| 102 | 128 | } |
@@ -107,13 +133,15 @@ discard block |
||
| 107 | 133 | |
| 108 | 134 | private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void |
| 109 | 135 | { |
| 110 | - if ($value === null) { |
|
| 136 | + if ($value === null) |
|
| 137 | + { |
|
| 111 | 138 | return; |
| 112 | 139 | } |
| 113 | 140 | |
| 114 | 141 | $setters = $this->reader->getPropertyMetadata($property, Setter::class); |
| 115 | 142 | |
| 116 | - foreach ($setters as $setter) { |
|
| 143 | + foreach ($setters as $setter) |
|
| 144 | + { |
|
| 117 | 145 | $value = $setter->updateValue($value); |
| 118 | 146 | } |
| 119 | 147 | |
@@ -134,7 +162,8 @@ discard block |
||
| 134 | 162 | ): string { |
| 135 | 163 | $attribute = $this->reader->firstPropertyMetadata($property, CastingErrorMessage::class); |
| 136 | 164 | |
| 137 | - if ($attribute === null) { |
|
| 165 | + if ($attribute === null) |
|
| 166 | + { |
|
| 138 | 167 | return $exception->getMessage(); |
| 139 | 168 | } |
| 140 | 169 | |
@@ -29,12 +29,12 @@ |
||
| 29 | 29 | public function __construct( |
| 30 | 30 | public readonly string $class, |
| 31 | 31 | public readonly ?string $prefix = null |
| 32 | - ) { |
|
| 32 | + ){ |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function getSchema(): string|array |
|
| 35 | + public function getSchema(): string | array |
|
| 36 | 36 | { |
| 37 | - if ($this->prefix) { |
|
| 37 | + if ($this->prefix){ |
|
| 38 | 38 | return [$this->class, $this->prefix]; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -34,7 +34,8 @@ |
||
| 34 | 34 | |
| 35 | 35 | public function getSchema(): string|array |
| 36 | 36 | { |
| 37 | - if ($this->prefix) { |
|
| 37 | + if ($this->prefix) |
|
| 38 | + { |
|
| 38 | 39 | return [$this->class, $this->prefix]; |
| 39 | 40 | } |
| 40 | 41 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public readonly string $class, |
| 37 | 37 | public readonly AbstractInput $input, |
| 38 | 38 | public readonly ?string $prefix = null |
| 39 | - ) { |
|
| 39 | + ){ |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function getValue(InputInterface $input, \ReflectionProperty $property): mixed |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function getSchema(): array |
| 48 | 48 | { |
| 49 | - if ($this->prefix) { |
|
| 49 | + if ($this->prefix){ |
|
| 50 | 50 | return [$this->class, $this->prefix]; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -46,7 +46,8 @@ |
||
| 46 | 46 | |
| 47 | 47 | public function getSchema(): array |
| 48 | 48 | { |
| 49 | - if ($this->prefix) { |
|
| 49 | + if ($this->prefix) |
|
| 50 | + { |
|
| 50 | 51 | return [$this->class, $this->prefix]; |
| 51 | 52 | } |
| 52 | 53 | |