Skip to content

Commit 600bf56

Browse files
committed
Merge branch 'PHP-7.1'
2 parents 7edaed6 + f4e68a3 commit 600bf56

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

ext/reflection/php_reflection.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3028,13 +3028,23 @@ ZEND_METHOD(reflection_type, __toString)
30283028
{
30293029
reflection_object *intern;
30303030
type_reference *param;
3031+
zend_string *str;
30313032

30323033
if (zend_parse_parameters_none() == FAILURE) {
30333034
return;
30343035
}
30353036
GET_REFLECTION_OBJECT_PTR(param);
30363037

3037-
RETURN_STR(reflection_type_name(param));
3038+
str = reflection_type_name(param);
3039+
3040+
if (param->arg_info->allow_null) {
3041+
size_t orig_len = ZSTR_LEN(str);
3042+
str = zend_string_extend(str, orig_len + 1, 0);
3043+
memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), orig_len + 1);
3044+
ZSTR_VAL(str)[0] = '?';
3045+
}
3046+
3047+
RETURN_STR(str);
30383048
}
30393049
/* }}} */
30403050

ext/reflection/tests/ReflectionNamedType.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ var_dump((string) $return);
3232
?>
3333
--EXPECTF--
3434
string(11) "Traversable"
35-
string(11) "Traversable"
36-
string(6) "string"
35+
string(12) "?Traversable"
3736
string(6) "string"
37+
string(7) "?string"
3838
string(4) "Test"
39+
string(5) "?Test"
3940
string(4) "Test"
40-
string(4) "Test"
41-
string(4) "Test"
41+
string(5) "?Test"

ext/reflection/tests/ReflectionType_001.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ foreach ([
7373
var_dump((string)$ra);
7474
}
7575
}
76+
77+
?>
7678
--EXPECT--
7779
*** functions
7880
** Function 0 - Parameter 0
@@ -94,7 +96,7 @@ string(8) "callable"
9496
bool(true)
9597
bool(true)
9698
bool(false)
97-
string(8) "stdClass"
99+
string(9) "?stdClass"
98100
** Function 0 - Parameter 4
99101
bool(false)
100102
** Function 0 - Parameter 5

0 commit comments

Comments
 (0)