fixes for normalising accompanying periods in docgen context

This commit is contained in:
2024-06-12 16:30:02 +02:00
parent 31b541d12f
commit 98f47ac512
3 changed files with 4 additions and 4 deletions

View File

@@ -42,7 +42,7 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac
throw new UnexpectedValueException('Object cannot be null or empty when format is json');
}
if ('docgen' === $format && !($object instanceof AccompanyingPeriodWork || null === $object)) {
throw new UnexpectedValueException(sprintf('Object must be an instanceof AccompanyingPeriodWork or null when format is docgen, %s given', is_object($object) ? get_class($object) : gettype($object)));
throw new UnexpectedValueException(sprintf('Object must be an instanceof AccompanyingPeriodWork or null when format is docgen, %s given', get_debug_type($object)));
}
$cleanContext = array_filter($context, fn (string|int $key) => !in_array($key, ['docgen:expects', self::IGNORE_WORK], true), ARRAY_FILTER_USE_KEY);
@@ -134,7 +134,7 @@ class AccompanyingPeriodWorkNormalizer implements ContextAwareNormalizerInterfac
{
return match ($format) {
'json' => $data instanceof AccompanyingPeriodWork && ($context[self::IGNORE_WORK] ?? null) !== spl_object_hash($data),
'docgen' => ($data instanceof AccompanyingPeriodWork || ($context['docgen:expects'] ?? null) === AccompanyingPeriodWork::class)
'docgen' => ($data instanceof AccompanyingPeriodWork || (null === $data && ($context['docgen:expects'] ?? null) === AccompanyingPeriodWork::class))
&& !array_key_exists(self::IGNORE_WORK, $context),
default => false,
};