mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Reflection: show the type of object constants used as default properties
This commit is contained in:
4
NEWS
4
NEWS
@@ -65,6 +65,10 @@ PHP NEWS
|
||||
. Partially fixed bug GH-17387 (Trivial crash in phpdbg lexer). (nielsdos)
|
||||
. Fix memory leak in phpdbg calling registered function. (nielsdos)
|
||||
|
||||
- Reflection:
|
||||
. Fixed bug GH-15902 (Core dumped in ext/reflection/php_reflection.c).
|
||||
(DanielEScherzer)
|
||||
|
||||
- Streams:
|
||||
. Fixed bug GH-17650 (realloc with size 0 in user_filters.c). (nielsdos)
|
||||
. Fix memory leak on overflow in _php_stream_scandir(). (nielsdos)
|
||||
|
||||
@@ -688,6 +688,16 @@ static int format_default_value(smart_str *str, zval *value) {
|
||||
format_default_value(str, zv);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
smart_str_appendc(str, ']');
|
||||
} else if (Z_TYPE_P(value) == IS_OBJECT) {
|
||||
/* This branch is reached if the constant AST was already evaluated and
|
||||
* resulted in an object; enums are already handled in smart_str_append_zval()
|
||||
* (GH-15902) */
|
||||
zend_object *obj = Z_OBJ_P(value);
|
||||
zend_class_entry *class = obj->ce;
|
||||
ZEND_ASSERT(!(class->ce_flags & ZEND_ACC_ENUM));
|
||||
smart_str_appends(str, "object(");
|
||||
smart_str_append(str, class->name);
|
||||
smart_str_appends(str, ")");
|
||||
} else {
|
||||
ZEND_ASSERT(Z_TYPE_P(value) == IS_CONSTANT_AST);
|
||||
zend_string *ast_str = zend_ast_export("", Z_ASTVAL_P(value), "");
|
||||
|
||||
37
ext/reflection/tests/gh15902/ReflectionClass-callable.phpt
Normal file
37
ext/reflection/tests/gh15902/ReflectionClass-callable.phpt
Normal file
@@ -0,0 +1,37 @@
|
||||
--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] {
|
||||
}
|
||||
}
|
||||
38
ext/reflection/tests/gh15902/ReflectionClass-class.phpt
Normal file
38
ext/reflection/tests/gh15902/ReflectionClass-class.phpt
Normal file
@@ -0,0 +1,38 @@
|
||||
--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] {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
ReflectionProperty object default - 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 ReflectionProperty(C::class, 'a');
|
||||
echo $reflector;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Property [ public stdClass $a = object(stdClass) ]
|
||||
20
ext/reflection/tests/gh15902/ReflectionProperty-class.phpt
Normal file
20
ext/reflection/tests/gh15902/ReflectionProperty-class.phpt
Normal file
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
ReflectionProperty object default - used to say "__CLASS__"
|
||||
--INI--
|
||||
opcache.enable_cli=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class C {
|
||||
public stdClass $a = FOO;
|
||||
}
|
||||
$reflector = new ReflectionProperty(C::class, 'a');
|
||||
|
||||
define('FOO', new stdClass);
|
||||
new C;
|
||||
|
||||
echo $reflector;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Property [ public stdClass $a = object(stdClass) ]
|
||||
Reference in New Issue
Block a user