-
-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
I have a (shortened) class like this:
class ImplantConfig {
/** psalm-param int<1,300> $ql */
public function __construct(
public int $ql=300,
public ?SlotConfig $head=null,
) {
}
}When I use the ObjectMapperCodeGenerator, it recurses into SlotConfig and further down, but only for hydration.
The generated code looks like this:
/**
* @template T of object
* @param class-string<T> $className
* @return T
*/
public function hydrateObject(string $className, array $payload): object
{
return match($className) {
'Nadybot\Modules\IMPLANT_MODULE\ImplantConfig' => $this->hydrateNadybot⚡️Modules⚡️IMPLANT_MODULE⚡️ImplantConfig($payload),
'Nadybot\Modules\IMPLANT_MODULE\SlotConfig' => $this->hydrateNadybot⚡️Modules⚡️IMPLANT_MODULE⚡️SlotConfig($payload),
'Nadybot\Modules\IMPLANT_MODULE\SymbiantSlot' => $this->hydrateNadybot⚡️Modules⚡️IMPLANT_MODULE⚡️SymbiantSlot($payload),
'Nadybot\Modules\IMPLANT_MODULE\AbilityAmount' => $this->hydrateNadybot⚡️Modules⚡️IMPLANT_MODULE⚡️AbilityAmount($payload),
default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack),
};
}In comparison, the serialization code is this:
/**
* @template T
*
* @param T $object
* @param class-string<T> $className
*/
public function serializeObjectOfType(object $object, string $className): mixed
{
try {
return match($className) {
'array' => $this->serializeValuearray($object),
'Ramsey\Uuid\UuidInterface' => $this->serializeValueRamsey⚡️Uuid⚡️UuidInterface($object),
'DateTime' => $this->serializeValueDateTime($object),
'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object),
'DateTimeInterface' => $this->serializeValueDateTimeInterface($object),
'Nadybot\Modules\IMPLANT_MODULE\ImplantConfig' => $this->serializeObjectNadybot⚡️Modules⚡️IMPLANT_MODULE⚡️ImplantConfig($object),
default => throw new \LogicException("No serialization defined for $className"),
};
} catch (\Throwable $exception) {
throw UnableToSerializeObject::dueToError($className, $exception);
}
}As you can see, it doesn't recurse, and to me, that is a bug. I'm using the latest 1.5.0 release. Am I mistaken?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels