Skip to content

Commit b4d40fc

Browse files
committed
Handle null bool
1 parent 9a7a09e commit b4d40fc

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

php/ext/google/protobuf/convert.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ static bool to_double(zval* php_val, double* dbl) {
286286

287287
static bool to_bool(zval* from, bool* to) {
288288
switch (Z_TYPE_P(from)) {
289+
case IS_NULL:
290+
*to = false;
291+
return true;
289292
case IS_TRUE:
290293
*to = true;
291294
return true;

php/tests/optional_test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
$m = new TestMessage([]);
99

1010
$m->setTrueOptionalString(null);
11+
$m->setTrueOptionalBool(null);
1112

1213
var_dump($m->getTrueOptionalString());
14+
var_dump($m->getTrueOptionalBool());

0 commit comments

Comments
 (0)