-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #46958 [Serializer] Ignore getter with required parameters (Fix #…
…46592) (astepin) This PR was merged into the 5.4 branch. Discussion ---------- [Serializer] Ignore getter with required parameters (Fix #46592) | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46592 | License | MIT | Doc PR | na If no Ignore annotation is used, the attributes for serialization are obtained using `Symfony\Component\Serializer\Normalizer\ObjectNormalizer::extractAttributes`. There it is checked if the method has required parameters and if yes, the method is ignored. However, if you use the Ignore annotation, the attributes are determined with a different method. Here I have adapted at least for get methods the behavior as it was before. If someone serialized a class with Ignore annotations before, he got here `\Symfony\Component\PropertyAccess\PropertyAccessor::readProperty` an exception as written in ticket #46592. With this fix the methods are ignored and there is no exception anymore. Commits ------- fda9281bd6 Fix #46592 - Ignore getter with required parameters
- Loading branch information
Showing
8 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; | ||
|
||
use Symfony\Component\Serializer\Annotation\Ignore; | ||
|
||
class IgnoreDummyAdditionalGetter | ||
{ | ||
|
||
private $myValue; | ||
|
||
/** | ||
* @Ignore() | ||
*/ | ||
public function getMyValue() | ||
{ | ||
return $this->myValue; | ||
} | ||
|
||
public function getExtraValue(string $parameter) { | ||
return $parameter; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Tests/Fixtures/Annotations/IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Serializer\Tests\Fixtures\Annotations; | ||
|
||
class IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations | ||
{ | ||
|
||
private $myValue; | ||
|
||
public function getMyValue() | ||
{ | ||
return $this->myValue; | ||
} | ||
|
||
public function getExtraValue(string $parameter) { | ||
return $parameter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Serializer\Tests\Fixtures\Attributes; | ||
|
||
use Symfony\Component\Serializer\Annotation\Ignore; | ||
|
||
class IgnoreDummyAdditionalGetter | ||
{ | ||
private $myValue; | ||
|
||
#[Ignore] | ||
public function getIgnored2() | ||
{ | ||
return $this->myValue; | ||
} | ||
|
||
public function getExtraValue(string $parameter) { | ||
return $parameter; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Tests/Fixtures/Attributes/IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\Serializer\Tests\Fixtures\Attributes; | ||
|
||
class IgnoreDummyAdditionalGetterWithoutIgnoreAnnotations | ||
{ | ||
private $myValue; | ||
|
||
public function getIgnored2() | ||
{ | ||
return $this->myValue; | ||
} | ||
|
||
public function getExtraValue(string $parameter) { | ||
return $parameter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters