Skip to content

Conversation

@mtarld
Copy link
Contributor

@mtarld mtarld commented Mar 5, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

Add support to BcMath\Number and GMP value objects. And, add support for union of value objects and other types (which was not working before).

Plus, this PR fixes the order of property metadata loaders decoration to make "attribute property metadata loader" acting first, and "value object property metadata loader" last.

$nativeToStreamValueTransformers = $this->nativeToStreamValueTransformers;

$nativeToStreamValueTransformers[] = $nativeToStreamValueTransformer;
$nativeToStreamValueTransformers = array_values(array_unique($nativeToStreamValueTransformers));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop trying to make value transformers unique, as it does not add any value, and didn't work anyway because \Closure aren't castable to string.

@mtarld mtarld force-pushed the feat/json-streamer-number branch 3 times, most recently from 003a6f0 to 4926638 Compare March 5, 2025 14:31
@mtarld mtarld force-pushed the feat/json-streamer-number branch from 4926638 to 47788ad Compare March 6, 2025 09:46
@mtarld mtarld changed the title [JsonStreamer] Add wider value object support [JsonStreamer] Add number object support Mar 6, 2025
@mtarld mtarld force-pushed the feat/json-streamer-number branch from 47788ad to 687104b Compare March 6, 2025 10:09
@mtarld mtarld force-pushed the feat/json-streamer-number branch from 687104b to 6a02953 Compare March 6, 2025 11:10
use Symfony\Component\TypeInfo\Type\UnionType;

/**
* Transforms value object to scalar.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Transforms value object to scalar.
* Transforms value objects to scalars.

*
* @internal
*/
final class ValueObjectTypePropertyMetadataLoader implements PropertyMetadataLoaderInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be split as well for the same reasons (#59915 (comment))?

Copy link
Member

@stof stof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest splitting the PR to make the review easier. Adding support for union types is totally separate from adding support for the GMP or BCMath objects. It would make the review a lot easier.

{
if (!$value instanceof \DateTimeInterface) {
throw new InvalidArgumentException('The native value must implement the "\DateTimeInterface".');
return $value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why making it return the original value instead of failing when it cannot transform it ?

$propertyMetadataLoader = new GenericTypePropertyMetadataLoader(
new DateTimeTypePropertyMetadataLoader(
$propertyMetadataLoader = new ValueObjectTypePropertyMetadataLoader(
new GenericTypePropertyMetadataLoader(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing the order of decorators ?

@mtarld
Copy link
Contributor Author

mtarld commented Mar 31, 2025

As suggested by @stof in #59915 (review), I gonna close this PR in favor of two new ones.

@mtarld mtarld closed this Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants