mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
When a property default is based on a global constant, show the type of the default. Previously, `format_default_value()` assumed that non-scalar and non-array defaults were always going to be `IS_CONSTANT_AST` pointers, and when the AST expression had been evaluated and produced an object, depending on when the `ReflectionClass` or `ReflectionProperty` instance had been created, the default was shown as one of `callable` or `__CLASS__`. Instead, if the default value is an object (`IS_OBJECT`), show the type of that object. Add test cases for both of the `callable` and `__CLASS__` cases to confirm that they now properly show the type of the constant. Closes GH-15902. Closes GH-17781.
39 lines
534 B
PHP
39 lines
534 B
PHP
--TEST--
|
|
ReflectionClass object default property - used to say "__CLASS__"
|
|
--INI--
|
|
opcache.enable_cli=0
|
|
--FILE--
|
|
<?php
|
|
|
|
class C {
|
|
public stdClass $a = FOO;
|
|
}
|
|
$reflector = new ReflectionClass(C::class);
|
|
|
|
define('FOO', new stdClass);
|
|
new C;
|
|
|
|
echo $reflector;
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Class [ <user> class C ] {
|
|
@@ %sReflectionClass-class.php %d-%d
|
|
|
|
- Constants [0] {
|
|
}
|
|
|
|
- Static properties [0] {
|
|
}
|
|
|
|
- Static methods [0] {
|
|
}
|
|
|
|
- Properties [1] {
|
|
Property [ public stdClass $a = object(stdClass) ]
|
|
}
|
|
|
|
- Methods [0] {
|
|
}
|
|
}
|