com php-src: Do not prepend ? on nullables in Reflect ionType::__toString(): NEWS UPGRADING ext/r eflection/php_reflection.c
ext/reflection/tests/Reflectio nNamedType.phpt ext/reflection/tests/ReflectionType_0 01.phpt

From: Date: Sun, 21 Aug 2016 05:12:47 +0000
Subject: com php-src: Do not prepend ? on nullables in Reflect ionType::__toString(): NEWS UPGRADING ext/r eflection/php_reflection.c
ext/reflection/tests/Reflectio nNamedType.phpt ext/reflection/tests/ReflectionType_0 01.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94019@lists.php.net to get a copy of this message
Commit: 8855a2ce76e8bfba1d2eea1345c765fde7a9a441 Author: Aaron Piotrowski <aaron@trowski.com> Sat, 20 Aug 2016 01:06:06 -0500 Parents: 08c5d77027cbd65abe8dab6149d4de91daabb9c7 Branches: PHP-7.1 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8855a2ce76e8bfba1d2eea1345c765fde7a9a441 Log: Do not prepend ? on nullables in ReflectionType::__toString() Better BC with 7.0. Changed paths: M NEWS M UPGRADING M ext/reflection/php_reflection.c M ext/reflection/tests/ReflectionNamedType.phpt M ext/reflection/tests/ReflectionType_001.phpt Diff: diff --git a/NEWS b/NEWS index 25dcc17..9d62352 100644 --- a/NEWS +++ b/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) diff --git a/UPGRADING b/UPGRADING index 410a0f2..71cc312 100644 --- a/UPGRADING +++ b/UPGRADING @@ -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 diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 66ffeab..a164cbd 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -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)); } /* }}} */ diff --git a/ext/reflection/tests/ReflectionNamedType.phpt b/ext/reflection/tests/ReflectionNamedType.phpt index 1e8f55a..123e09d 100644 --- a/ext/reflection/tests/ReflectionNamedType.phpt +++ b/ext/reflection/tests/ReflectionNamedType.phpt @@ -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" diff --git a/ext/reflection/tests/ReflectionType_001.phpt b/ext/reflection/tests/ReflectionType_001.phpt index a317566..f764cf1 100644 --- a/ext/reflection/tests/ReflectionType_001.phpt +++ b/ext/reflection/tests/ReflectionType_001.phpt @@ -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

« previous php.cvs (#94019) next »