summaryrefslogtreecommitdiff
path: root/ext/reflection
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-09-21 21:36:09 +0200
committerNikita Popov <nikic@php.net>2016-09-28 19:21:51 +0200
commitbf907b9961000dfb9b3bf3bd8a1e00e327a8268e (patch)
tree92281583c6e5f5449596f54ec719b0f35042719e /ext/reflection
parent4c0804c07de703826e38646bb6cc6d6ca633ddc4 (diff)
downloadphp-git-bf907b9961000dfb9b3bf3bd8a1e00e327a8268e.tar.gz
Revert ReflectionType::__toString() behavior + deprecate
Diffstat (limited to 'ext/reflection')
-rw-r--r--ext/reflection/php_reflection.c14
-rw-r--r--ext/reflection/tests/ReflectionNamedType.phpt16
-rw-r--r--ext/reflection/tests/ReflectionType_001.phpt8
-rw-r--r--ext/reflection/tests/ReflectionType_002.phpt2
-rw-r--r--ext/reflection/tests/ReflectionType_possible_types.phpt2
-rw-r--r--ext/reflection/tests/bug72661.phpt3
6 files changed, 22 insertions, 23 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 16601ee4d6..47c09d4521 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -3022,23 +3022,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->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));
}
/* }}} */
@@ -6711,7 +6701,7 @@ static const zend_function_entry reflection_type_functions[] = {
ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
ZEND_ME(reflection_type, allowsNull, arginfo_reflection__void, 0)
ZEND_ME(reflection_type, isBuiltin, arginfo_reflection__void, 0)
- ZEND_ME(reflection_type, __toString, arginfo_reflection__void, 0)
+ ZEND_ME(reflection_type, __toString, arginfo_reflection__void, ZEND_ACC_DEPRECATED)
PHP_FE_END
};
diff --git a/ext/reflection/tests/ReflectionNamedType.phpt b/ext/reflection/tests/ReflectionNamedType.phpt
index 1e8f55ac9d..afb592127c 100644
--- a/ext/reflection/tests/ReflectionNamedType.phpt
+++ b/ext/reflection/tests/ReflectionNamedType.phpt
@@ -32,10 +32,18 @@ var_dump((string) $return);
?>
--EXPECTF--
string(11) "Traversable"
-string(12) "?Traversable"
+
+Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
+string(11) "Traversable"
+string(6) "string"
+
+Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
string(6) "string"
-string(7) "?string"
string(4) "Test"
-string(5) "?Test"
+
+Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
+string(4) "Test"
+string(4) "Test"
+
+Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
string(4) "Test"
-string(5) "?Test"
diff --git a/ext/reflection/tests/ReflectionType_001.phpt b/ext/reflection/tests/ReflectionType_001.phpt
index ee2ebb64dd..d949e18107 100644
--- a/ext/reflection/tests/ReflectionType_001.phpt
+++ b/ext/reflection/tests/ReflectionType_001.phpt
@@ -28,7 +28,7 @@ foreach ([
if ($ra) {
var_dump($ra->allowsNull());
var_dump($ra->isBuiltin());
- var_dump((string)$ra);
+ var_dump($ra->getName());
}
}
}
@@ -48,7 +48,7 @@ foreach ([
if ($ra) {
var_dump($ra->allowsNull());
var_dump($ra->isBuiltin());
- var_dump((string)$ra);
+ var_dump($ra->getName());
}
}
}
@@ -70,7 +70,7 @@ foreach ([
if ($ra) {
var_dump($ra->allowsNull());
var_dump($ra->isBuiltin());
- var_dump((string)$ra);
+ var_dump($ra->getName());
}
}
@@ -96,7 +96,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
diff --git a/ext/reflection/tests/ReflectionType_002.phpt b/ext/reflection/tests/ReflectionType_002.phpt
index 8313862ec5..501dfc8d89 100644
--- a/ext/reflection/tests/ReflectionType_002.phpt
+++ b/ext/reflection/tests/ReflectionType_002.phpt
@@ -9,7 +9,7 @@ $rp = $rm->getParameters()[0];
$rt = $rp->getType();
$rrt = $rm->getReturnType();
unset($rm, $rp);
-var_dump((string) $rt, (string) $rrt);
+var_dump($rt->getName(), $rrt->getName());
--EXPECT--
string(4) "Test"
diff --git a/ext/reflection/tests/ReflectionType_possible_types.phpt b/ext/reflection/tests/ReflectionType_possible_types.phpt
index 81e08550f2..55302242be 100644
--- a/ext/reflection/tests/ReflectionType_possible_types.phpt
+++ b/ext/reflection/tests/ReflectionType_possible_types.phpt
@@ -17,7 +17,7 @@ $functions = [
foreach ($functions as $function) {
$reflectionFunc = new ReflectionFunction($function);
$returnType = $reflectionFunc->getReturnType();
- var_dump($returnType->__toString());
+ var_dump($returnType->getName());
}
?>
--EXPECTF--
diff --git a/ext/reflection/tests/bug72661.phpt b/ext/reflection/tests/bug72661.phpt
index 40d14922b8..1522c5f201 100644
--- a/ext/reflection/tests/bug72661.phpt
+++ b/ext/reflection/tests/bug72661.phpt
@@ -6,5 +6,6 @@ function test(iterable $arg) { }
var_dump((string)(new ReflectionParameter("test", 0))->getType());
?>
---EXPECT--
+--EXPECTF--
+Deprecated: Function ReflectionType::__toString() is deprecated in %s on line %d
string(8) "iterable"