Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #26140 [Serializer] deserialize as a null when inner object canno…
…t be created and type hint allows null (kbkk) This PR was squashed before being merged into the 4.1-dev branch (closes #26140). Discussion ---------- [Serializer] deserialize as a null when inner object cannot be created and type hint allows null | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT ```php class ObjectConstructorDummy { protected $foo; public $bar; private $baz; public function __construct($foo, $bar, $baz) { $this->foo = $foo; $this->bar = $bar; $this->baz = $baz; } } class DummyWithNullableConstructorObject { private $id; private $inner; public function __construct($id, ?ObjectConstructorDummy $inner) { $this->id = $id; $this->inner = $inner; } public function getId() { return $this->id; } public function getInner() { return $this->inner; } } ``` Trying to deserialize to `DummyWithNullableConstructorObject` with the following data currently fails: ```php [ 'id' => 10, 'inner' => null ] ``` With this PR `DummyWithNullableConstructorObject ` would be constructed with `null` passed as `$inner` because of the type hint. Commits ------- 2fe9eb1 [Serializer] deserialize as a null when inner object cannot be created and type hint allows null
- Loading branch information