Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e3bbf8d

Browse filesBrowse files
committed
bug #30720 Fix getSetMethodNormalizer to correctly ignore the attributes specified in "ignored_attributes" (Emmanuel BORGES)
This PR was merged into the 3.4 branch. Discussion ---------- Fix getSetMethodNormalizer to correctly ignore the attributes specified in "ignored_attributes" …ed in "ignored_attributes" | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30453 | License | MIT The GetSetMethodNormalizer class correctly ignores the attributes specified in "ignored_attributes" Commits ------- 606d8d3 Fix getSetMethodNormalizer to correctly ignore the attributes specified in "ignored_attributes"
2 parents cc6bfea + 606d8d3 commit e3bbf8d
Copy full SHA for e3bbf8d

File tree

2 files changed

+18
-1
lines changed
Filter options

2 files changed

+18
-1
lines changed

‎src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Normalizer/GetSetMethodNormalizer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected function extractAttributes($object, $format = null, array $context = [
109109

110110
$attributeName = lcfirst(substr($method->name, 0 === strpos($method->name, 'is') ? 2 : 3));
111111

112-
if ($this->isAllowedAttribute($object, $attributeName)) {
112+
if ($this->isAllowedAttribute($object, $attributeName, $format, $context)) {
113113
$attributes[] = $attributeName;
114114
}
115115
}

‎src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ public function testDenormalize()
9191
$this->assertTrue($obj->isBaz());
9292
}
9393

94+
public function testIgnoredAttributesInContext()
95+
{
96+
$ignoredAttributes = ['foo', 'bar', 'baz', 'object'];
97+
$this->normalizer->setIgnoredAttributes($ignoredAttributes);
98+
$obj = new GetSetDummy();
99+
$obj->setFoo('foo');
100+
$obj->setBar('bar');
101+
$obj->setCamelCase(true);
102+
$this->assertEquals(
103+
[
104+
'fooBar' => 'foobar',
105+
'camelCase' => true,
106+
],
107+
$this->normalizer->normalize($obj, 'any')
108+
);
109+
}
110+
94111
public function testDenormalizeWithObject()
95112
{
96113
$data = new \stdClass();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.