Passed
Pull Request — master (#961)
by Maxim
09:18
created
src/Filters/src/Model/Mapper/SetterRegistry.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
     public function __construct(array $setters = [])
13 13
     {
14
-        foreach ($setters as $setter) {
14
+        foreach ($setters as $setter){
15 15
             $this->register($setter);
16 16
         }
17 17
     }
Please login to merge, or discard this patch.
src/Filters/src/Model/Mapper/Uuid.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function supports(\ReflectionNamedType $type): bool
15 15
     {
16
-        if ($this->interfaceExists === null) {
16
+        if ($this->interfaceExists === null){
17 17
             $this->interfaceExists = \interface_exists(UuidInterface::class);
18 18
         }
19 19
 
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 
28 28
     private function implements(string $haystack, string $interface): bool
29 29
     {
30
-        if ($haystack === $interface) {
30
+        if ($haystack === $interface){
31 31
             return true;
32 32
         }
33 33
 
34
-        foreach ((array)\class_implements($haystack) as $implements) {
35
-            if ($implements === $interface) {
34
+        foreach ((array)\class_implements($haystack) as $implements){
35
+            if ($implements === $interface){
36 36
                 return true;
37 37
             }
38 38
 
39
-            if (self::implements($implements, $interface)) {
39
+            if (self::implements($implements, $interface)){
40 40
                 return true;
41 41
             }
42 42
         }
Please login to merge, or discard this patch.
src/Filters/src/Model/Schema/Builder.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function makeSchema(string $name, array $schema): array
44 44
     {
45
-        if (empty($schema)) {
45
+        if (empty($schema)){
46 46
             throw new SchemaException(\sprintf('Filter `%s` does not define any schema', $name));
47 47
         }
48 48
 
49 49
         $result = [];
50
-        foreach ($schema as $field => $definition) {
50
+        foreach ($schema as $field => $definition){
51 51
             $optional = false;
52 52
 
53 53
             // short definition
54
-            if (\is_string($definition)) {
54
+            if (\is_string($definition)){
55 55
                 // simple scalar field definition
56
-                if (!\class_exists($definition)) {
56
+                if (!\class_exists($definition)){
57 57
                     [$source, $origin] = $this->parseDefinition($field, $definition);
58 58
                     $result[$field] = [
59 59
                         self::SCHEMA_SOURCE => $source,
@@ -74,25 +74,25 @@  discard block
 block discarded – undo
74 74
                 continue;
75 75
             }
76 76
 
77
-            if (!\is_array($definition) || $definition === []) {
77
+            if (!\is_array($definition) || $definition === []){
78 78
                 throw new SchemaException(
79 79
                     \sprintf('Invalid schema definition at `%s`->`%s`', $name, $field)
80 80
                 );
81 81
             }
82 82
 
83 83
             // complex definition
84
-            if (!empty($definition[self::ORIGIN])) {
84
+            if (!empty($definition[self::ORIGIN])){
85 85
                 $origin = $definition[self::ORIGIN];
86 86
 
87 87
                 // [class, 'data:something.*'] vs [class, 'data:something']
88 88
                 $iterate = \str_contains((string)$origin, '.*') || !empty($definition[self::ITERATE]);
89 89
                 $origin = \rtrim($origin, '.*');
90
-            } else {
90
+            }else{
91 91
                 $origin = $field;
92 92
                 $iterate = true;
93 93
             }
94 94
 
95
-            if (!empty($definition[self::OPTIONAL])) {
95
+            if (!empty($definition[self::OPTIONAL])){
96 96
                 $optional = true;
97 97
             }
98 98
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                 self::SCHEMA_OPTIONAL => $optional,
106 106
             ];
107 107
 
108
-            if ($iterate) {
108
+            if ($iterate){
109 109
                 [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin);
110 110
 
111 111
                 $map[self::SCHEMA_ITERATE_SOURCE] = $source;
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
             'path',
138 138
             'remoteAddress',
139 139
             'uri',
140
-        ], true)) {
140
+        ], true)){
141 141
             return [$definition, $field];
142 142
         }
143 143
 
144
-        if (!\str_contains($definition, ':')) {
144
+        if (!\str_contains($definition, ':')){
145 145
             return ['data', empty($definition) ? $field : $definition];
146 146
         }
147 147
 
Please login to merge, or discard this patch.
src/Framework/Bootloader/Security/FiltersBootloader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         private readonly ContainerInterface $container,
44 44
         private readonly BinderInterface $binder,
45 45
         private readonly ConfiguratorInterface $config
46
-    ) {
46
+    ){
47 47
     }
48 48
 
49 49
     /**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         ?EventDispatcherInterface $dispatcher = null
94 94
     ): FilterProvider {
95 95
         $core = new InterceptableCore(new Core(), $dispatcher);
96
-        foreach ($config->getInterceptors() as $interceptor) {
96
+        foreach ($config->getInterceptors() as $interceptor){
97 97
             $core->addInterceptor($container->get($interceptor));
98 98
         }
99 99
 
Please login to merge, or discard this patch.
src/Filters/src/Model/FilterProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         private readonly ContainerInterface $container,
24 24
         private readonly ResolverInterface $resolver,
25 25
         private readonly CoreInterface $core
26
-    ) {
26
+    ){
27 27
     }
28 28
 
29 29
     public function createFilter(string $name, InputInterface $input): FilterInterface
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $filter = $this->createFilterInstance($name);
35 35
         [$mappingSchema, $errors, $setters, $optionalFilters] = $attributeMapper->map($filter, $input);
36 36
 
37
-        if ($filter instanceof HasFilterDefinition) {
37
+        if ($filter instanceof HasFilterDefinition){
38 38
             $mappingSchema = \array_merge(
39 39
                 $mappingSchema,
40 40
                 $filter->filterDefinition()->mappingSchema()
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         \assert($schemaBuilder instanceof Builder);
49 49
 
50 50
         $schema = $schemaBuilder->makeSchema($name, $mappingSchema);
51
-        foreach ($optionalFilters as $optionalFilter) {
51
+        foreach ($optionalFilters as $optionalFilter){
52 52
             $schema[$optionalFilter][Builder::SCHEMA_OPTIONAL] = true;
53 53
         }
54 54
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $class = new \ReflectionClass($name);
67 67
 
68 68
         $args = [];
69
-        if ($constructor = $class->getConstructor()) {
69
+        if ($constructor = $class->getConstructor()){
70 70
             $args = $this->resolver->resolveArguments($constructor);
71 71
         }
72 72
 
Please login to merge, or discard this patch.
src/Filters/src/Model/Mapper/Mapper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function __construct(
15 15
         private readonly SetterRegistryInterface $registry
16
-    ) {
16
+    ){
17 17
     }
18 18
 
19 19
     /**
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     public function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
23 23
     {
24 24
         $type = $property->getType();
25
-        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
26
-            foreach ($this->registry->getSetters() as $setter) {
27
-                if ($setter->supports($type)) {
25
+        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()){
26
+            foreach ($this->registry->getSetters() as $setter){
27
+                if ($setter->supports($type)){
28 28
                     $setter->setValue($filter, $property, $value);
29 29
                     return;
30 30
                 }
Please login to merge, or discard this patch.
src/Filters/src/Model/Schema/AttributeMapper.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
         private readonly FilterProviderInterface $provider,
22 22
         private readonly ReaderInterface $reader,
23 23
         private readonly Mapper $mapper
24
-    ) {
24
+    ){
25 25
     }
26 26
 
27 27
     /**
@@ -35,53 +35,53 @@  discard block
 block discarded – undo
35 35
         $optionalFilters = [];
36 36
         $class = new \ReflectionClass($filter);
37 37
 
38
-        foreach ($class->getProperties() as $property) {
38
+        foreach ($class->getProperties() as $property){
39 39
             /** @var object $attribute */
40
-            foreach ($this->reader->getPropertyMetadata($property) as $attribute) {
41
-                if ($attribute instanceof AbstractInput) {
40
+            foreach ($this->reader->getPropertyMetadata($property) as $attribute){
41
+                if ($attribute instanceof AbstractInput){
42 42
                     $this->setValue($filter, $property, $attribute->getValue($input, $property));
43 43
                     $schema[$property->getName()] = $attribute->getSchema($property);
44
-                } elseif ($attribute instanceof NestedFilter) {
44
+                } elseif ($attribute instanceof NestedFilter){
45 45
                     $prefix = $attribute->prefix ?? $property->name;
46
-                    try {
46
+                    try{
47 47
                         $value = $this->provider->createFilter(
48 48
                             $attribute->class,
49 49
                             $input->withPrefix($prefix)
50 50
                         );
51 51
 
52 52
                         $this->setValue($filter, $property, $value);
53
-                    } catch (ValidationException $e) {
54
-                        if ($this->allowsNull($property)) {
53
+                    }catch (ValidationException $e){
54
+                        if ($this->allowsNull($property)){
55 55
                             $this->setValue($filter, $property, null);
56 56
                             $optionalFilters[] = $property->getName();
57
-                        } else {
57
+                        }else{
58 58
                             $errors[$prefix] = $e->errors;
59 59
                         }
60 60
                     }
61 61
 
62 62
                     $schema[$property->getName()] = $attribute->getSchema($property);
63
-                } elseif ($attribute instanceof NestedArray) {
63
+                } elseif ($attribute instanceof NestedArray){
64 64
                     $values = $attribute->getValue($input, $property);
65 65
                     $propertyValues = [];
66 66
 
67 67
                     $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName();
68 68
 
69
-                    if (\is_array($values)) {
70
-                        foreach (\array_keys($values) as $key) {
71
-                            try {
69
+                    if (\is_array($values)){
70
+                        foreach (\array_keys($values) as $key){
71
+                            try{
72 72
                                 $propertyValues[$key] = $this->provider->createFilter(
73 73
                                     $attribute->class,
74
-                                    $input->withPrefix($prefix . '.' . $key)
74
+                                    $input->withPrefix($prefix.'.'.$key)
75 75
                                 );
76
-                            } catch (ValidationException $e) {
76
+                            }catch (ValidationException $e){
77 77
                                 $errors[$property->getName()][$key] = $e->errors;
78 78
                             }
79 79
                         }
80 80
                     }
81 81
 
82 82
                     $this->setValue($filter, $property, $propertyValues);
83
-                    $schema[$property->getName()] = [$attribute->class, $prefix . '.*'];
84
-                } elseif ($attribute instanceof Setter) {
83
+                    $schema[$property->getName()] = [$attribute->class, $prefix.'.*'];
84
+                } elseif ($attribute instanceof Setter){
85 85
                     $setters[$property->getName()][] = $attribute;
86 86
                 }
87 87
             }
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 
93 93
     private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
94 94
     {
95
-        if ($value === null) {
95
+        if ($value === null){
96 96
             return;
97 97
         }
98 98
 
99 99
         $setters = $this->reader->getPropertyMetadata($property, Setter::class);
100 100
 
101
-        foreach ($setters as $setter) {
101
+        foreach ($setters as $setter){
102 102
             $value = $setter->updateValue($value);
103 103
         }
104 104
 
Please login to merge, or discard this patch.
src/Filters/src/Model/Schema/InputMapper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function __construct(
15 15
         private readonly FilterProviderInterface $provider
16
-    ) {
16
+    ){
17 17
     }
18 18
 
19 19
     public function map(array $mappingSchema, InputInterface $input, array $setters = []): array
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
         $errors = [];
22 22
         $result = [];
23 23
 
24
-        foreach ($mappingSchema as $field => $map) {
25
-            if (empty($map[Builder::SCHEMA_FILTER])) {
24
+        foreach ($mappingSchema as $field => $map){
25
+            if (empty($map[Builder::SCHEMA_FILTER])){
26 26
                 $value = $input->getValue($map[Builder::SCHEMA_SOURCE], $map[Builder::SCHEMA_ORIGIN]);
27 27
 
28
-                if ($value !== null) {
28
+                if ($value !== null){
29 29
                     /** @var Setter $setter */
30
-                    foreach ($setters[$field] ?? [] as $setter) {
30
+                    foreach ($setters[$field] ?? [] as $setter){
31 31
                         $value = $setter->updateValue($value);
32 32
                     }
33 33
 
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
             }
38 38
 
39 39
             $nested = $map[Builder::SCHEMA_FILTER];
40
-            if (empty($map[Builder::SCHEMA_ARRAY])) {
40
+            if (empty($map[Builder::SCHEMA_ARRAY])){
41 41
                 // slicing down
42
-                try {
42
+                try{
43 43
                     $result[$field] = $this->provider->createFilter($nested, $input->withPrefix($map[Builder::SCHEMA_ORIGIN]));
44
-                } catch (ValidationException $e) {
45
-                    if ($map[Builder::SCHEMA_OPTIONAL]) {
44
+                }catch (ValidationException $e){
45
+                    if ($map[Builder::SCHEMA_OPTIONAL]){
46 46
                         $result[$field] = null;
47 47
                         continue;
48 48
                     }
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
             $values = [];
55 55
 
56 56
             // List of "key" => "location in request"
57
-            foreach ($this->iterate($map, $input) as $index => $origin) {
58
-                try {
57
+            foreach ($this->iterate($map, $input) as $index => $origin){
58
+                try{
59 59
                     $values[$index] = $this->provider->createFilter($nested, $input->withPrefix($origin));
60
-                } catch (ValidationException $e) {
60
+                }catch (ValidationException $e){
61 61
                     $errors[$field][$index] = $e->errors;
62 62
                 }
63 63
             }
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
             $schema[Builder::SCHEMA_ITERATE_ORIGIN]
79 79
         );
80 80
 
81
-        if (empty($values) || !\is_array($values)) {
81
+        if (empty($values) || !\is_array($values)){
82 82
             return [];
83 83
         }
84 84
 
85
-        foreach (\array_keys($values) as $key) {
86
-            yield $key => $schema[Builder::SCHEMA_ORIGIN] . '.' . $key;
85
+        foreach (\array_keys($values) as $key){
86
+            yield $key => $schema[Builder::SCHEMA_ORIGIN].'.'.$key;
87 87
         }
88 88
     }
89 89
 }
Please login to merge, or discard this patch.