Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added support for serializedName alias in properties. Fixed #15171 #29615

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

Closed
wants to merge 2 commits into from

Conversation

acataluddi
Copy link

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

@acataluddi acataluddi closed this Dec 14, 2018
@@ -109,19 +109,24 @@ public function normalize($object, $format = null, array $context = array())
$attributeValue = $maxDepthHandler($attributeValue, $object, $attribute, $format, $context);
}

// Adding support for serialized-name
array_key_exists($attribute, $attributesMetadata) && null !== $attributesMetadata[$attribute]->getSerializedName() ?
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if this syntax work, it's not documented: http://us2.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary

Anyway, IMHO it will be easier to read if written as:

Suggested change
array_key_exists($attribute, $attributesMetadata) && null !== $attributesMetadata[$attribute]->getSerializedName() ?
$serializedName = (array_key_exists($attribute, $attributesMetadata) && null !== $attributesMetadata[$attribute]->getSerializedName()) ?
$attributesMetadata[$attribute]->getSerializedName() :
$attribute;

(and it can be expanded in multiple lines to avoid one long line with 2 expressions)

Copy link
Author

Choose a reason for hiding this comment

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

Hi Alexis,
Yes, looks a sensible suggestion. However, even though the implementation is working, it breaks some unit test. I think I need to understand more about the Normaliser before actually pull it again.

Thanks,
Adriano

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.

3 participants