mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Do not prepend ? on nullables in ReflectionType::__toString()
Better BC with 7.0.
This commit is contained in:
parent
08c5d77027
commit
8855a2ce76
5 changed files with 18 additions and 32 deletions
13
NEWS
13
NEWS
|
@ -2,13 +2,18 @@ PHP NEWS
|
|||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 2016, PHP 7.1.0RC1
|
||||
|
||||
- IMAP:
|
||||
. Fixed bug #72852 (imap_mail null dereference). (Anatol)
|
||||
- Reflection:
|
||||
. Reverted prepending \ for class names and ? for nullable types returned
|
||||
from ReflectionType::__toString(). (Trowski)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #65732 (grapheme_*() is not Unicode compliant on CR LF
|
||||
sequence). (cmb)
|
||||
|
||||
- Reflection:
|
||||
. Reverted prepending \ for class names and ? for nullable types returned
|
||||
from ReflectionType::__toString(). (Trowski)
|
||||
|
||||
- XML:
|
||||
. Fixed bug #72714 (_xml_startElementHandler() segmentation fault). (cmb)
|
||||
|
||||
|
@ -67,8 +72,8 @@ PHP NEWS
|
|||
- Reflection:
|
||||
. Implemented request #38992 (invoke() and invokeArgs() static method calls
|
||||
should match). (cmb).
|
||||
. Add ReflectionNamedType::getName() and return leading "?" for nullable types
|
||||
from ReflectionType::__toString(). (Trowski)
|
||||
. Add ReflectionNamedType::getName(). This method should be used instead of
|
||||
ReflectionType::__toString()
|
||||
|
||||
- Session:
|
||||
. Implemented RFC: Session ID without hashing. (Yasuo)
|
||||
|
|
|
@ -124,9 +124,6 @@ PHP 7.1 UPGRADE NOTES
|
|||
. The behavior of ReflectionMethod::invoke() and ::invokeArgs() has been
|
||||
aligned, what causes slightly different behavior than before for some
|
||||
pathological cases.
|
||||
. ReflectionType::__toString() will now return the type name with a leading
|
||||
"?" if it is nullable. To retrieve the type name without leading "?" the new
|
||||
ReflectionNamedType::getName() method can be used.
|
||||
|
||||
========================================
|
||||
2. New Features
|
||||
|
@ -308,6 +305,9 @@ PHP 7.1 UPGRADE NOTES
|
|||
- Reflection:
|
||||
. Failure to retrieve a reflection object or retrieve an object property
|
||||
will now throw an instance of Error instead of resulting in a fatal error.
|
||||
. ReflectionNamedType will be returned from ReflectionParameter::getType()
|
||||
and ReflectionFunctionAbstract::getReturnType(). This class includes a
|
||||
getName() method that returns the type name as a string.
|
||||
|
||||
- Session:
|
||||
. Custom session handlers that do not return strings for session IDs will
|
||||
|
|
|
@ -3028,32 +3028,13 @@ 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);
|
||||
|
||||
str = reflection_type_name(param);
|
||||
|
||||
if (param->arg_info->type_hint == IS_OBJECT
|
||||
&& !zend_string_equals_literal_ci(param->arg_info->class_name, "self")
|
||||
&& !zend_string_equals_literal_ci(param->arg_info->class_name, "parent")) {
|
||||
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] = '\\';
|
||||
}
|
||||
|
||||
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);
|
||||
RETURN_STR(reflection_type_name(param));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -32,10 +32,10 @@ var_dump((string) $return);
|
|||
?>
|
||||
--EXPECTF--
|
||||
string(11) "Traversable"
|
||||
string(12) "?Traversable"
|
||||
string(11) "Traversable"
|
||||
string(6) "string"
|
||||
string(6) "string"
|
||||
string(7) "?string"
|
||||
string(4) "Test"
|
||||
string(5) "?Test"
|
||||
string(4) "Test"
|
||||
string(5) "?Test"
|
||||
string(4) "Test"
|
||||
string(4) "Test"
|
||||
|
|
|
@ -94,7 +94,7 @@ string(8) "callable"
|
|||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
string(9) "?stdClass"
|
||||
string(8) "stdClass"
|
||||
** Function 0 - Parameter 4
|
||||
bool(false)
|
||||
** Function 0 - Parameter 5
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue