Skip to content

Conversation

@fbourigault
Copy link
Contributor

@fbourigault fbourigault commented Oct 8, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ?
License MIT
Doc PR symfony/symfony-docs#10530

This is a small refactoring to reduce the complexity of the ObjectNormalizer. It now use a PropertyListExtractorInterface to get the class properties list.

To achieve this, I also added a exclude_static_properties option to the ReflectionExtractor::getProperties method.

Starting from this PR, symfony/serializer has a hard dependency on symfony/property-info.

This was exposed by @dunglas in #19374 (comment).

To do

  • add a CHANGELOG.md entry.
  • documentation for exclude_static_properties.
  • check for performance regression.

Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

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

Awesome, it will allow to dramatically simplify the component, then to improve its performance.

$properties = array();
foreach ($reflectionProperties as $reflectionProperty) {
if ($reflectionProperty->isPublic()) {
if ($reflectionProperty->isPublic() && (!($context[self::EXCLUDE_STATIC_PROPERTIES] ?? false) || !$reflectionProperty->isStatic())) {
Copy link
Member

Choose a reason for hiding this comment

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

It almost looks like a bug to me that we used to include static properties. I would like to change the default behavior and add a flag to include static props instead, but it's maybe to late (BC break). WDYT @symfony/deciders?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I am afraid changing that would be a BC break.

@fbourigault fbourigault changed the title [Serializer]Use PropertyInfo to extract properties [WIP][Serializer]Use PropertyInfo to extract properties Dec 10, 2018
@fbourigault
Copy link
Contributor Author

I’m closing this PR because I don’t plan to work on it soon.

@fbourigault fbourigault closed this Aug 9, 2019
@nicolas-grekas nicolas-grekas removed this from the next milestone Oct 27, 2019
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Oct 27, 2019
@fbourigault fbourigault deleted the object-normalizer-property-list-extractor branch June 24, 2021 13:38
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.

5 participants