| @@ -43,7 +43,7 @@ discard block | ||
| 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 | ||
| 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 | |
| @@ -23,7 +23,7 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | |
| @@ -11,7 +11,7 @@ | ||
| 11 | 11 | |
| 12 | 12 | public function __construct(array $casters = []) | 
| 13 | 13 |      { | 
| 14 | -        foreach ($casters as $caster) { | |
| 14 | +        foreach ($casters as $caster){ | |
| 15 | 15 | $this->register($caster); | 
| 16 | 16 | } | 
| 17 | 17 | } | 
| @@ -13,7 +13,7 @@ discard block | ||
| 13 | 13 |  { | 
| 14 | 14 | public function __construct( | 
| 15 | 15 | private readonly CasterRegistryInterface $registry | 
| 16 | -    ) { | |
| 16 | +    ){ | |
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | 19 | /** | 
| @@ -22,9 +22,9 @@ discard block | ||
| 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->getCasters() as $setter) { | |
| 27 | -                if ($setter->supports($type)) { | |
| 25 | +        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()){ | |
| 26 | +            foreach ($this->registry->getCasters() as $setter){ | |
| 27 | +                if ($setter->supports($type)){ | |
| 28 | 28 | $setter->setValue($filter, $property, $value); | 
| 29 | 29 | return; | 
| 30 | 30 | } | 
| @@ -31,9 +31,9 @@ | ||
| 31 | 31 | |
| 32 | 32 | public function updateValue(mixed $value): mixed | 
| 33 | 33 |      { | 
| 34 | -        try { | |
| 34 | +        try{ | |
| 35 | 35 | return ($this->filter)($value, ...$this->args); | 
| 36 | -        } catch (\Throwable $e) { | |
| 36 | +        }catch (\Throwable $e){ | |
| 37 | 37 | throw new SetterException($e); | 
| 38 | 38 | } | 
| 39 | 39 | } | 
| @@ -23,7 +23,7 @@ discard block | ||
| 23 | 23 |  { | 
| 24 | 24 | public function __construct( | 
| 25 | 25 | private readonly ContainerInterface $container | 
| 26 | -    ) { | |
| 26 | +    ){ | |
| 27 | 27 | } | 
| 28 | 28 | |
| 29 | 29 | /** | 
| @@ -34,7 +34,7 @@ discard block | ||
| 34 | 34 | $bag = $parameters['filterBag']; | 
| 35 | 35 | $filter = $core->callAction($controller, $action, $parameters); | 
| 36 | 36 | |
| 37 | -        if ($filter instanceof HasFilterDefinition) { | |
| 37 | +        if ($filter instanceof HasFilterDefinition){ | |
| 38 | 38 | $this->validateFilter( | 
| 39 | 39 | $filter->filterDefinition(), | 
| 40 | 40 | $bag, | 
| @@ -43,7 +43,7 @@ discard block | ||
| 43 | 43 | ); | 
| 44 | 44 | } | 
| 45 | 45 | |
| 46 | -        if (($bag->errors ?? []) !== []) { | |
| 46 | +        if (($bag->errors ?? []) !== []){ | |
| 47 | 47 | $errorMapper = new ErrorMapper($bag->schema); | 
| 48 | 48 | throw new ValidationException($errorMapper->mapErrors($bag->errors), $parameters['context'] ?? null); | 
| 49 | 49 | } | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 | array $errors, | 
| 58 | 58 | mixed $context | 
| 59 | 59 |      ): void { | 
| 60 | -        if ($definition instanceof ShouldBeValidated) { | |
| 60 | +        if ($definition instanceof ShouldBeValidated){ | |
| 61 | 61 | $errorMapper = new ErrorMapper($bag->schema); | 
| 62 | 62 | $validationProvider = $this->container->get(ValidationProviderInterface::class); | 
| 63 | 63 | |
| @@ -65,12 +65,12 @@ discard block | ||
| 65 | 65 | ->getValidation($definition::class) | 
| 66 | 66 | ->validate($bag, $definition->validationRules(), $context); | 
| 67 | 67 | |
| 68 | -            if (!$validator->isValid()) { | |
| 68 | +            if (!$validator->isValid()){ | |
| 69 | 69 | throw new ValidationException( | 
| 70 | 70 | $errorMapper->mapErrors(\array_merge($errors, $validator->getErrors())), | 
| 71 | 71 | $context | 
| 72 | 72 | ); | 
| 73 | -            } elseif ($errors !== []) { | |
| 73 | +            } elseif ($errors !== []){ | |
| 74 | 74 | throw new ValidationException($errorMapper->mapErrors($errors), $context); | 
| 75 | 75 | } | 
| 76 | 76 | } | 
| @@ -14,7 +14,7 @@ discard block | ||
| 14 | 14 |  { | 
| 15 | 15 | public function __construct( | 
| 16 | 16 | private readonly FilterProviderInterface $provider | 
| 17 | -    ) { | |
| 17 | +    ){ | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | 20 | public function map(array $mappingSchema, InputInterface $input, array $setters = []): array | 
| @@ -22,16 +22,16 @@ discard block | ||
| 22 | 22 | $errors = []; | 
| 23 | 23 | $result = []; | 
| 24 | 24 | |
| 25 | -        foreach ($mappingSchema as $field => $map) { | |
| 26 | -            if (empty($map[Builder::SCHEMA_FILTER])) { | |
| 25 | +        foreach ($mappingSchema as $field => $map){ | |
| 26 | +            if (empty($map[Builder::SCHEMA_FILTER])){ | |
| 27 | 27 | $value = $input->getValue($map[Builder::SCHEMA_SOURCE], $map[Builder::SCHEMA_ORIGIN]); | 
| 28 | 28 | |
| 29 | -                if ($value !== null) { | |
| 29 | +                if ($value !== null){ | |
| 30 | 30 | /** @var Setter $setter */ | 
| 31 | -                    foreach ($setters[$field] ?? [] as $setter) { | |
| 32 | -                        try { | |
| 31 | +                    foreach ($setters[$field] ?? [] as $setter){ | |
| 32 | +                        try{ | |
| 33 | 33 | $value = $setter->updateValue($value); | 
| 34 | -                        } catch (SetterException $e) { | |
| 34 | +                        }catch (SetterException $e){ | |
| 35 | 35 | $errors[$field] = $e->getMessage(); | 
| 36 | 36 | } | 
| 37 | 37 | } | 
| @@ -42,12 +42,12 @@ discard block | ||
| 42 | 42 | } | 
| 43 | 43 | |
| 44 | 44 | $nested = $map[Builder::SCHEMA_FILTER]; | 
| 45 | -            if (empty($map[Builder::SCHEMA_ARRAY])) { | |
| 45 | +            if (empty($map[Builder::SCHEMA_ARRAY])){ | |
| 46 | 46 | // slicing down | 
| 47 | -                try { | |
| 47 | +                try{ | |
| 48 | 48 | $result[$field] = $this->provider->createFilter($nested, $input->withPrefix($map[Builder::SCHEMA_ORIGIN])); | 
| 49 | -                } catch (ValidationException $e) { | |
| 50 | -                    if ($map[Builder::SCHEMA_OPTIONAL]) { | |
| 49 | +                }catch (ValidationException $e){ | |
| 50 | +                    if ($map[Builder::SCHEMA_OPTIONAL]){ | |
| 51 | 51 | $result[$field] = null; | 
| 52 | 52 | continue; | 
| 53 | 53 | } | 
| @@ -59,10 +59,10 @@ discard block | ||
| 59 | 59 | $values = []; | 
| 60 | 60 | |
| 61 | 61 | // List of "key" => "location in request" | 
| 62 | -            foreach ($this->iterate($map, $input) as $index => $origin) { | |
| 63 | -                try { | |
| 62 | +            foreach ($this->iterate($map, $input) as $index => $origin){ | |
| 63 | +                try{ | |
| 64 | 64 | $values[$index] = $this->provider->createFilter($nested, $input->withPrefix($origin)); | 
| 65 | -                } catch (ValidationException $e) { | |
| 65 | +                }catch (ValidationException $e){ | |
| 66 | 66 | $errors[$field][$index] = $e->errors; | 
| 67 | 67 | } | 
| 68 | 68 | } | 
| @@ -83,12 +83,12 @@ discard block | ||
| 83 | 83 | $schema[Builder::SCHEMA_ITERATE_ORIGIN] | 
| 84 | 84 | ); | 
| 85 | 85 | |
| 86 | -        if (empty($values) || !\is_array($values)) { | |
| 86 | +        if (empty($values) || !\is_array($values)){ | |
| 87 | 87 | return []; | 
| 88 | 88 | } | 
| 89 | 89 | |
| 90 | -        foreach (\array_keys($values) as $key) { | |
| 91 | - yield $key => $schema[Builder::SCHEMA_ORIGIN] . '.' . $key; | |
| 90 | +        foreach (\array_keys($values) as $key){ | |
| 91 | + yield $key => $schema[Builder::SCHEMA_ORIGIN].'.'.$key; | |
| 92 | 92 | } | 
| 93 | 93 | } | 
| 94 | 94 | } | 
| @@ -25,7 +25,7 @@ discard block | ||
| 25 | 25 | private readonly FilterProviderInterface $provider, | 
| 26 | 26 | private readonly ReaderInterface $reader, | 
| 27 | 27 | private readonly Mapper $mapper | 
| 28 | -    ) { | |
| 28 | +    ){ | |
| 29 | 29 | } | 
| 30 | 30 | |
| 31 | 31 | /** | 
| @@ -39,65 +39,65 @@ discard block | ||
| 39 | 39 | $optionalFilters = []; | 
| 40 | 40 | $class = new \ReflectionClass($filter); | 
| 41 | 41 | |
| 42 | -        foreach ($class->getProperties() as $property) { | |
| 42 | +        foreach ($class->getProperties() as $property){ | |
| 43 | 43 | /** @var object $attribute */ | 
| 44 | -            foreach ($this->reader->getPropertyMetadata($property) as $attribute) { | |
| 45 | -                if ($attribute instanceof AbstractInput) { | |
| 46 | -                    try { | |
| 44 | +            foreach ($this->reader->getPropertyMetadata($property) as $attribute){ | |
| 45 | +                if ($attribute instanceof AbstractInput){ | |
| 46 | +                    try{ | |
| 47 | 47 | $this->setValue($filter, $property, $attribute->getValue($input, $property)); | 
| 48 | -                    } catch (SetterException $e) { | |
| 48 | +                    }catch (SetterException $e){ | |
| 49 | 49 | $errors[$property->getName()] = $e->getMessage(); | 
| 50 | 50 | } | 
| 51 | 51 | $schema[$property->getName()] = $attribute->getSchema($property); | 
| 52 | -                } elseif ($attribute instanceof NestedFilter) { | |
| 52 | +                } elseif ($attribute instanceof NestedFilter){ | |
| 53 | 53 | $prefix = $attribute->prefix ?? $property->name; | 
| 54 | -                    try { | |
| 54 | +                    try{ | |
| 55 | 55 | $value = $this->provider->createFilter( | 
| 56 | 56 | $attribute->class, | 
| 57 | 57 | $input->withPrefix($prefix) | 
| 58 | 58 | ); | 
| 59 | 59 | |
| 60 | -                        try { | |
| 60 | +                        try{ | |
| 61 | 61 | $this->setValue($filter, $property, $value); | 
| 62 | -                        } catch (SetterException $e) { | |
| 62 | +                        }catch (SetterException $e){ | |
| 63 | 63 | $errors[$property->getName()] = $e->getMessage(); | 
| 64 | 64 | } | 
| 65 | -                    } catch (ValidationException $e) { | |
| 66 | -                        if ($this->allowsNull($property)) { | |
| 65 | +                    }catch (ValidationException $e){ | |
| 66 | +                        if ($this->allowsNull($property)){ | |
| 67 | 67 | $this->setValue($filter, $property, null); | 
| 68 | 68 | $optionalFilters[] = $property->getName(); | 
| 69 | -                        } else { | |
| 69 | +                        }else{ | |
| 70 | 70 | $errors[$prefix] = $e->errors; | 
| 71 | 71 | } | 
| 72 | 72 | } | 
| 73 | 73 | |
| 74 | 74 | $schema[$property->getName()] = $attribute->getSchema($property); | 
| 75 | -                } elseif ($attribute instanceof NestedArray) { | |
| 75 | +                } elseif ($attribute instanceof NestedArray){ | |
| 76 | 76 | $values = $attribute->getValue($input, $property); | 
| 77 | 77 | $propertyValues = []; | 
| 78 | 78 | |
| 79 | 79 | $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName(); | 
| 80 | 80 | |
| 81 | -                    if (\is_array($values)) { | |
| 82 | -                        foreach (\array_keys($values) as $key) { | |
| 83 | -                            try { | |
| 81 | +                    if (\is_array($values)){ | |
| 82 | +                        foreach (\array_keys($values) as $key){ | |
| 83 | +                            try{ | |
| 84 | 84 | $propertyValues[$key] = $this->provider->createFilter( | 
| 85 | 85 | $attribute->class, | 
| 86 | - $input->withPrefix($prefix . '.' . $key) | |
| 86 | + $input->withPrefix($prefix.'.'.$key) | |
| 87 | 87 | ); | 
| 88 | -                            } catch (ValidationException $e) { | |
| 88 | +                            }catch (ValidationException $e){ | |
| 89 | 89 | $errors[$property->getName()][$key] = $e->errors; | 
| 90 | 90 | } | 
| 91 | 91 | } | 
| 92 | 92 | } | 
| 93 | 93 | |
| 94 | -                    try { | |
| 94 | +                    try{ | |
| 95 | 95 | $this->setValue($filter, $property, $propertyValues); | 
| 96 | -                    } catch (SetterException $e) { | |
| 96 | +                    }catch (SetterException $e){ | |
| 97 | 97 | $errors[$property->getName()] = $e->getMessage(); | 
| 98 | 98 | } | 
| 99 | - $schema[$property->getName()] = [$attribute->class, $prefix . '.*']; | |
| 100 | -                } elseif ($attribute instanceof Setter) { | |
| 99 | + $schema[$property->getName()] = [$attribute->class, $prefix.'.*']; | |
| 100 | +                } elseif ($attribute instanceof Setter){ | |
| 101 | 101 | $setters[$property->getName()][] = $attribute; | 
| 102 | 102 | } | 
| 103 | 103 | } | 
| @@ -108,13 +108,13 @@ discard block | ||
| 108 | 108 | |
| 109 | 109 | private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void | 
| 110 | 110 |      { | 
| 111 | -        if ($value === null) { | |
| 111 | +        if ($value === null){ | |
| 112 | 112 | return; | 
| 113 | 113 | } | 
| 114 | 114 | |
| 115 | 115 | $setters = $this->reader->getPropertyMetadata($property, Setter::class); | 
| 116 | 116 | |
| 117 | -        foreach ($setters as $setter) { | |
| 117 | +        foreach ($setters as $setter){ | |
| 118 | 118 | $value = $setter->updateValue($value); | 
| 119 | 119 | } | 
| 120 | 120 | |