File tree 2 files changed +4
-0
lines changed
2 files changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,9 @@ public function serialize($value)
40
40
if ($ value === null ) {
41
41
return 'null ' ;
42
42
}
43
+ if (is_object ($ value ) && method_exists ($ value , '__toString ' )) {
44
+ return (string ) $ value ;
45
+ }
43
46
if (!is_scalar ($ value )) {
44
47
throw new Error ("String cannot represent non scalar value: " . Utils::printSafe ($ value ));
45
48
}
Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ public function testSerializesOutputStrings()
150
150
$ this ->assertSame ('true ' , $ stringType ->serialize (true ));
151
151
$ this ->assertSame ('false ' , $ stringType ->serialize (false ));
152
152
$ this ->assertSame ('null ' , $ stringType ->serialize (null ));
153
+ $ this ->assertSame ('2 ' , $ stringType ->serialize (new ObjectIdStub (2 )));
153
154
}
154
155
155
156
public function testSerializesOutputStringsCannotRepresentArray ()
You can’t perform that action at this time.
0 commit comments