Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/tests/bug69802.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $r = new ReflectionMethod($f, '__invoke');
var_dump($r->getParameters()[0]->getName());
var_dump($r->getParameters()[0]->getClass());
echo $r->getParameters()[0], "\n";
echo $r->getReturnType(),"\n";
echo $r->getReturnType()->getName(), "\n";
echo $r,"\n";
?>
--EXPECT--
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/closures/closure_from_callable_reflection.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ foreach ($callables as $callable) {
foreach ($refl->getParameters() as $param) {
if ($param->hasType()) {
$type = $param->getType();
echo $type->__toString() . "\n";
echo $type->getName() . "\n";
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
internal_function->prototype = NULL;
if (ptr->flags) {
if (!(ptr->flags & ZEND_ACC_PPP_MASK)) {
if (ptr->flags != ZEND_ACC_DEPRECATED || scope) {
if (ptr->flags != ZEND_ACC_DEPRECATED && scope) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks unrelated but I asked Nikita about it and he said this:

there was a bug elsewhere preventing me from using ZEND_ACC_DEPRECATED in ZEND_ME without also specifying ZEND_ACC_PUBLIC

(tl;dr is related)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not needed anymore, right? (Would be better as a separate change anyway.)

zend_error(error_type, "Invalid access level for %s%s%s() - access must be exactly one of public, protected or private", scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname);
}
internal_function->fn_flags = ZEND_ACC_PUBLIC | ptr->flags;
Expand Down
15 changes: 4 additions & 11 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
/* }}} */

Expand Down Expand Up @@ -6711,6 +6701,9 @@ 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)
/* ReflectionType::__toString() is deprecated, but we currently do not mark it as such
* due to bad interaction with the PHPUnit error handler and exceptions in __toString().
* See PR2137. */
ZEND_ME(reflection_type, __toString, arginfo_reflection__void, 0)
PHP_FE_END
};
Expand Down
10 changes: 5 additions & 5 deletions ext/reflection/tests/ReflectionNamedType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ var_dump($return->getName());
var_dump((string) $return);

?>
--EXPECTF--
--EXPECT--
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"
8 changes: 4 additions & 4 deletions ext/reflection/tests/ReflectionType_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ foreach ([
if ($ra) {
var_dump($ra->allowsNull());
var_dump($ra->isBuiltin());
var_dump((string)$ra);
var_dump($ra->getName());
}
}
}
Expand All @@ -48,7 +48,7 @@ foreach ([
if ($ra) {
var_dump($ra->allowsNull());
var_dump($ra->isBuiltin());
var_dump((string)$ra);
var_dump($ra->getName());
}
}
}
Expand All @@ -70,7 +70,7 @@ foreach ([
if ($ra) {
var_dump($ra->allowsNull());
var_dump($ra->isBuiltin());
var_dump((string)$ra);
var_dump($ra->getName());
}
}

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/tests/ReflectionType_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/tests/ReflectionType_possible_types.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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--
Expand Down