diff options
author | Levi Morrison <levim@php.net> | 2016-08-23 09:42:04 -0600 |
---|---|---|
committer | Levi Morrison <levim@php.net> | 2016-08-23 09:43:31 -0600 |
commit | f4e68a3968429757719c600ce16913ab09539f0d (patch) | |
tree | db2d68458a6c0e4cad8dff6879f0a0d8a8acc680 /ext/reflection/php_reflection.c | |
parent | 129e8dadf447df7d98a08447bc8c950b7c9209ec (diff) | |
download | php-git-f4e68a3968429757719c600ce16913ab09539f0d.tar.gz |
Revert "Do not prepend ? on nullables in ReflectionType::__toString()"
This reverts commit 8855a2ce76e8bfba1d2eea1345c765fde7a9a441.
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r-- | ext/reflection/php_reflection.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index a164cbda72..cf861b65d8 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3028,13 +3028,23 @@ ZEND_METHOD(reflection_type, __toString) { reflection_object *intern; type_reference *param; + zend_string *str; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(param); - RETURN_STR(reflection_type_name(param)); + str = reflection_type_name(param); + + if (param->arg_info->allow_null) { + size_t orig_len = ZSTR_LEN(str); + str = zend_string_extend(str, orig_len + 1, 0); + memmove(ZSTR_VAL(str) + 1, ZSTR_VAL(str), orig_len + 1); + ZSTR_VAL(str)[0] = '?'; + } + + RETURN_STR(str); } /* }}} */ |