mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
812df2bd8a
Add zend_fetch_class_with_scope() which accepts a scope to use for self/parent, and use that during constant expression evaluation. Closes GH-7649.
65 lines
1.2 KiB
PHP
65 lines
1.2 KiB
PHP
--TEST--
|
|
Reflection Bug #81611 (ArgumentCountError when getting default value from ReflectionParameter with new)
|
|
--FILE--
|
|
<?php
|
|
|
|
class Bar
|
|
{
|
|
}
|
|
|
|
class Foo extends Bar
|
|
{
|
|
public function doFoo(object $test = new self()): object
|
|
{
|
|
return $test;
|
|
}
|
|
|
|
public function doBar(object $test = new parent()): object
|
|
{
|
|
return $test;
|
|
}
|
|
}
|
|
|
|
$ref = new \ReflectionClass(Foo::class);
|
|
|
|
foreach (['doFoo', 'doBar'] as $method) {
|
|
$params = $ref->getMethod($method)->getParameters();
|
|
|
|
foreach ($params as $param) {
|
|
echo "isDefaultValueAvailable:\n";
|
|
var_dump($param->isDefaultValueAvailable());
|
|
|
|
echo "isDefaultValueConstant:\n";
|
|
var_dump($param->isDefaultValueConstant());
|
|
|
|
echo "getDefaultValueConstantName:\n";
|
|
var_dump($param->getDefaultValueConstantName());
|
|
|
|
echo "getDefaultValue:\n";
|
|
var_dump($param->getDefaultValue());
|
|
|
|
echo "\n";
|
|
}
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
isDefaultValueAvailable:
|
|
bool(true)
|
|
isDefaultValueConstant:
|
|
bool(false)
|
|
getDefaultValueConstantName:
|
|
NULL
|
|
getDefaultValue:
|
|
object(Foo)#2 (0) {
|
|
}
|
|
|
|
isDefaultValueAvailable:
|
|
bool(true)
|
|
isDefaultValueConstant:
|
|
bool(false)
|
|
getDefaultValueConstantName:
|
|
NULL
|
|
getDefaultValue:
|
|
object(Bar)#3 (0) {
|
|
}
|