mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00

When dumping default values in ReflectionXXX::__toString(), for expression initializers print the AST export instead of trying to evaluate the expression. With the introduction of "new in initializers" the result of the evaluation will commonly not be printable at all, and "__toString" will throw an exception, which is not particularly useful. Using the AST export also provides more information on how the parameter was originally declared, e.g. it preserves the fact that a certain constant was used. Closes GH-7540.
44 lines
730 B
PHP
44 lines
730 B
PHP
--TEST--
|
|
ReflectionMethod and RECV_INIT (bug #70957 and #70958)
|
|
--FILE--
|
|
<?php
|
|
Abstract class F {
|
|
private function bar($a = self::class) {}
|
|
}
|
|
|
|
Trait T
|
|
{
|
|
private function bar($a = self::class) {}
|
|
}
|
|
|
|
|
|
class B {
|
|
use T;
|
|
}
|
|
|
|
echo new \ReflectionMethod('F', 'bar');
|
|
echo new \ReflectionMethod('T', 'bar');
|
|
echo new \ReflectionMethod('B', 'bar');
|
|
?>
|
|
--EXPECTF--
|
|
Method [ <user> private method bar ] {
|
|
@@ %s
|
|
|
|
- Parameters [1] {
|
|
Parameter #0 [ <optional> $a = 'F' ]
|
|
}
|
|
}
|
|
Method [ <user> private method bar ] {
|
|
@@ %s
|
|
|
|
- Parameters [1] {
|
|
Parameter #0 [ <optional> $a = self::class ]
|
|
}
|
|
}
|
|
Method [ <user> private method bar ] {
|
|
@@ %s
|
|
|
|
- Parameters [1] {
|
|
Parameter #0 [ <optional> $a = self::class ]
|
|
}
|
|
}
|