You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to override one property with another on serialization, but I wasn't able to do so without removing target property from the serialized object.
I want to replace property "id" with property "fooBar".
When property "id" doesn't exists in the serialized object, it replaces it as desired, but when it exists - it doesn't.
class SomeClass {
public $id;
public $fooBar;
public function getFooBar() {
return $this->fooBar;
}
}
$toSerialize = new SomeClass();
$toSerialize->id = 1;
$toSerialize->fooBar = 999;
Expected Result
{"id":"999"}
Actual Result
{"id":"1"}
The text was updated successfully, but these errors were encountered:
I try to override one property with another on serialization, but I wasn't able to do so without removing target property from the serialized object.
I want to replace property "id" with property "fooBar".
When property "id" doesn't exists in the serialized object, it replaces it as desired, but when it exists - it doesn't.
It's caused by overriding virtualProperty config when source property exists: https://github.com/schmittjoh/serializer/blob/2.2.0/src/Metadata/Driver/YamlDriver.php#L86
Steps required to reproduce the problem
Serializer config:
Serialized class:
Expected Result
Actual Result
The text was updated successfully, but these errors were encountered: