mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-17 06:18:44 +02:00
N°9319 increase php min. version to 8.2 (#887)
* Update minimum PHP version to 8.2 * Fix previous wrong resolution of merge conflict
This commit is contained in:
@@ -105,7 +105,7 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
|
||||
try {
|
||||
$payload = $this->$payloadMapper($request, $type, $argument);
|
||||
} catch (PartialDenormalizationException $e) {
|
||||
$trans = $this->translator ? $this->translator->trans(...) : fn ($m, $p) => strtr($m, $p);
|
||||
$trans = $this->translator ? $this->translator->trans(...) : static fn ($m, $p) => strtr($m, $p);
|
||||
foreach ($e->getErrors() as $error) {
|
||||
$parameters = [];
|
||||
$template = 'This value was of an unexpected type.';
|
||||
@@ -187,7 +187,7 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
|
||||
}
|
||||
|
||||
if (\is_array($data)) {
|
||||
return $this->serializer->denormalize($data, $type, 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE);
|
||||
return $this->serializer->denormalize($data, $type, self::hasNonStringScalar($data) ? $format : 'csv', $attribute->serializationContext + self::CONTEXT_DENORMALIZE);
|
||||
}
|
||||
|
||||
if ('form' === $format) {
|
||||
@@ -202,4 +202,21 @@ class RequestPayloadValueResolver implements ValueResolverInterface, EventSubscr
|
||||
throw new HttpException(Response::HTTP_BAD_REQUEST, \sprintf('Request payload contains invalid "%s" data.', $format), $e);
|
||||
}
|
||||
}
|
||||
|
||||
private static function hasNonStringScalar(array $data): bool
|
||||
{
|
||||
$stack = [$data];
|
||||
|
||||
while ($stack) {
|
||||
foreach (array_pop($stack) as $v) {
|
||||
if (\is_array($v)) {
|
||||
$stack[] = $v;
|
||||
} elseif (!\is_string($v)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user