File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,10 @@ public function decodesProtectedProperties()
8787
8888 private function transform ($ transformer , $ jsonArrayData , $ instance )
8989 {
90+ if (empty ($ jsonArrayData )) {
91+ return null ;
92+ }
93+
9094 $ classBindings = new ClassBindings ($ this );
9195 $ transformer ->register ($ classBindings );
9296
Original file line number Diff line number Diff line change @@ -103,6 +103,14 @@ public function it_should_be_able_to_transform_raw_with_private_properties()
103103 $ response ->getId ()->shouldBe (1 );
104104 $ response ->getName ()->shouldReturn ('John Doe ' );
105105 }
106+
107+ public function it_should_be_able_to_transform_null_values ()
108+ {
109+ $ this ->register (new SampleTransformer ());
110+ $ response = $ this ->decode ('null ' , JsonDecoderSample::class);
111+
112+ $ response ->shouldBe (null );
113+ }
106114}
107115
108116class JsonDecoderSample
You can’t perform that action at this time.
0 commit comments