From 0baf038136463c46e788d5a1a3f3ed0cf9f15a50 Mon Sep 17 00:00:00 2001 From: ignace nyamagana butera Date: Thu, 30 Nov 2023 22:23:28 +0100 Subject: [PATCH] Improve documentation --- docs/9.0/reader/record-mapping.md | 4 ++-- src/Serializer/Denormalizer.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/9.0/reader/record-mapping.md b/docs/9.0/reader/record-mapping.md index 80fd71dd..840b8f86 100644 --- a/docs/9.0/reader/record-mapping.md +++ b/docs/9.0/reader/record-mapping.md @@ -153,7 +153,7 @@ The attribute can take up to three (3) arguments which are all optional: - The `column` argument tells the engine which record key to use via its numeric or name. If not present the property name or the name of the first argument of the `setter` method will be used. In such case, you are required to specify the property names information. - The `cast` argument which accept the name of a class implementing the `TypeCasting` interface and responsible for type casting the record value. If not present, the mechanism will try to resolve the typecasting based on the property or method argument type. -- The `options` argument enables controlling typecasting by providing extra arguments to the `TypeCasting` class constructor. The argument expects an associative array and relies on named arguments to inject its value to the `TypeCasting` implementing class constructor. +- The `options` argument enables controlling typecasting by providing extra arguments to `TypeCasting::setOptions` method. The argument expects an associative array and relies on named arguments to inject its value to the method.

You can use the mechanism on a CSV without a header row but it requires adding a MapCell attribute on each property or method needed for the conversion. Or you @@ -260,7 +260,7 @@ public function setPlace(mixed $place): void > if the value is null resolve the string `Abidjan` to `Place::Abidjan`. Once created, > call the method `setPlace` with the created `Place` enum filling the `$place` argument. -

Using this class with a mixed type without providing the enum parameter will trigger an exception.

+

Using this class with a mixed type without providing the className parameter will trigger an exception.

### CastToDate diff --git a/src/Serializer/Denormalizer.php b/src/Serializer/Denormalizer.php index b4173ddc..3cfca914 100644 --- a/src/Serializer/Denormalizer.php +++ b/src/Serializer/Denormalizer.php @@ -150,7 +150,7 @@ private function hydrate(object $object, array $record): void $record = array_values($record); foreach ($this->propertySetters as $propertySetter) { $value = $record[$propertySetter->offset]; - if ('' === $value && self::$emptyStringAsNull) { + if (is_string($value) && '' === trim($value) && self::$emptyStringAsNull) { $value = null; }