-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add types to private and internal properties #45721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hey! I think @mtarld has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
src/Symfony/Component/Serializer/CacheWarmer/CompiledClassMetadataCacheWarmer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Friendly ping @derrabus
I'm just wondering about those array-key
and array<Foo>
: don't we prefer using Foo[]
? /cc @wouterj since you're on a similar topic these days :)
For the record, I'm not sold on blindly using readonly
on private properties: the keyword breaks legit use cases (lazy proxies) for little to no practical benefits.
I agree about I'm not sure about I prefer |
Friendly ping @derrabus ) |
bbaabc3
to
63bb48e
Compare
63bb48e
to
7ff739a
Compare
Thank you @derrabus. |
Thank you for completing it. |
* @param array<DecoderInterface> $decoders | ||
*/ | ||
public function __construct( | ||
private readonly array $decoders = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've said this before, but strictly speaking this is a BC break: the $decoders
property has no longer a default value (the default value is given to the parameter only).
This creates issues when overriding the constructor without calling the parent as the property becomes uninitialized: https://3v4l.org/DId0c
Is this something we consider too much of an edge case, or would this be a reason against transforming everything to CPP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has already beaten us at least once so this is a valid concern to me.
This PR adds types to private and
@internal
properties of the serializer component. This time, I've also applied CPP andreadonly
flags where possible. If this makes the review too hard or there are other reasons not to do that, please tell me and I'll skip it in future PRs.