1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/reflection/tests/gh15902/ReflectionClass-callable.phpt
Daniel Scherzer ca0414e64d Reflection: show the type of object constants used as default properties
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.
2025-02-21 09:32:10 +01:00

38 lines
535 B
PHP

--TEST--
ReflectionClass object default property - used to say "callable"
--INI--
opcache.enable_cli=0
--FILE--
<?php
class C {
public stdClass $a = FOO;
}
define('FOO', new stdClass);
new C;
$reflector = new ReflectionClass(C::class);
echo $reflector;
?>
--EXPECTF--
Class [ <user> class C ] {
@@ %sReflectionClass-callable.php %d-%d
- Constants [0] {
}
- Static properties [0] {
}
- Static methods [0] {
}
- Properties [1] {
Property [ public stdClass $a = object(stdClass) ]
}
- Methods [0] {
}
}