Skip to content

Commit 1036fd2

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Check update constant failure in ReflectionClassConstant::__toString()
2 parents ecd986c + 8bb2f40 commit 1036fd2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

ext/reflection/php_reflection.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,10 @@ static void _class_const_string(smart_str *str, char *name, zend_class_constant
557557
char *visibility = zend_visibility_string(Z_ACCESS_FLAGS(c->value));
558558
const char *type;
559559

560-
zval_update_constant_ex(&c->value, c->ce);
560+
if (zval_update_constant_ex(&c->value, c->ce) == FAILURE) {
561+
return;
562+
}
563+
561564
type = zend_zval_type_name(&c->value);
562565

563566
if (Z_TYPE(c->value) == IS_ARRAY) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Exception thrown while converting ReflectionClassConstant to string
3+
--FILE--
4+
<?php
5+
6+
class B {
7+
const X = self::UNKNOWN;
8+
}
9+
10+
try {
11+
echo new ReflectionClassConstant('B', 'X');
12+
} catch (Error $e) {
13+
echo $e->getMessage(), "\n";
14+
}
15+
16+
?>
17+
--EXPECT--
18+
Undefined constant self::UNKNOWN

0 commit comments

Comments
 (0)