Fix #65274: Add class name to undef class constant error

This commit is contained in:
Nikita Popov 2020-01-08 14:18:14 +01:00
parent 4cac97bfb9
commit ae5d7604f6
6 changed files with 13 additions and 7 deletions

2
NEWS
View file

@ -6,6 +6,8 @@ PHP NEWS
. Removed the pdo_odbc.db2_instance_name php.ini directive. (Kalle) . Removed the pdo_odbc.db2_instance_name php.ini directive. (Kalle)
. Fixed bug #77619 (Wrong reflection on MultipleIterator::__construct). . Fixed bug #77619 (Wrong reflection on MultipleIterator::__construct).
(Fabien Villepinte) (Fabien Villepinte)
. Fixed bug #65274 (Enhance undefined class constant error with class name).
(Nikita)
- Date: - Date:
. Fixed bug #65547 (Default value for sunrise/sunset zenith still wrong). . Fixed bug #65547 (Default value for sunrise/sunset zenith still wrong).

View file

@ -19,7 +19,7 @@ echo "Done\n";
string(6) "string" string(6) "string"
int(1) int(1)
Fatal error: Uncaught Error: Undefined class constant 'val3' in %s:%d Fatal error: Uncaught Error: Undefined class constant 'test::val3' in %s:%d
Stack trace: Stack trace:
#0 {main} #0 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -5485,7 +5485,8 @@ ZEND_VM_HANDLER(181, ZEND_FETCH_CLASS_CONSTANT, VAR|CONST|UNUSED|CLASS_FETCH, CO
} }
CACHE_POLYMORPHIC_PTR(opline->extended_value, ce, value); CACHE_POLYMORPHIC_PTR(opline->extended_value, ce, value);
} else { } else {
zend_throw_error(NULL, "Undefined class constant '%s'", Z_STRVAL_P(RT_CONSTANT(opline, opline->op2))); zend_throw_error(NULL, "Undefined class constant '%s::%s'",
ZSTR_VAL(ce->name), Z_STRVAL_P(RT_CONSTANT(opline, opline->op2)));
ZVAL_UNDEF(EX_VAR(opline->result.var)); ZVAL_UNDEF(EX_VAR(opline->result.var));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }

View file

@ -5957,7 +5957,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_CONSTANT_SPEC_CONS
} }
CACHE_POLYMORPHIC_PTR(opline->extended_value, ce, value); CACHE_POLYMORPHIC_PTR(opline->extended_value, ce, value);
} else { } else {
zend_throw_error(NULL, "Undefined class constant '%s'", Z_STRVAL_P(RT_CONSTANT(opline, opline->op2))); zend_throw_error(NULL, "Undefined class constant '%s::%s'",
ZSTR_VAL(ce->name), Z_STRVAL_P(RT_CONSTANT(opline, opline->op2)));
ZVAL_UNDEF(EX_VAR(opline->result.var)); ZVAL_UNDEF(EX_VAR(opline->result.var));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }
@ -22760,7 +22761,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_CONSTANT_SPEC_VAR_
} }
CACHE_POLYMORPHIC_PTR(opline->extended_value, ce, value); CACHE_POLYMORPHIC_PTR(opline->extended_value, ce, value);
} else { } else {
zend_throw_error(NULL, "Undefined class constant '%s'", Z_STRVAL_P(RT_CONSTANT(opline, opline->op2))); zend_throw_error(NULL, "Undefined class constant '%s::%s'",
ZSTR_VAL(ce->name), Z_STRVAL_P(RT_CONSTANT(opline, opline->op2)));
ZVAL_UNDEF(EX_VAR(opline->result.var)); ZVAL_UNDEF(EX_VAR(opline->result.var));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }
@ -30698,7 +30700,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_CLASS_CONSTANT_SPEC_UNUS
} }
CACHE_POLYMORPHIC_PTR(opline->extended_value, ce, value); CACHE_POLYMORPHIC_PTR(opline->extended_value, ce, value);
} else { } else {
zend_throw_error(NULL, "Undefined class constant '%s'", Z_STRVAL_P(RT_CONSTANT(opline, opline->op2))); zend_throw_error(NULL, "Undefined class constant '%s::%s'",
ZSTR_VAL(ce->name), Z_STRVAL_P(RT_CONSTANT(opline, opline->op2)));
ZVAL_UNDEF(EX_VAR(opline->result.var)); ZVAL_UNDEF(EX_VAR(opline->result.var));
HANDLE_EXCEPTION(); HANDLE_EXCEPTION();
} }

View file

@ -79,7 +79,7 @@ string(6) "hello2"
Expecting fatal error: Expecting fatal error:
Fatal error: Uncaught Error: Undefined class constant 'c19' in %s:%d Fatal error: Uncaught Error: Undefined class constant 'C::c19' in %s:%d
Stack trace: Stack trace:
#0 {main} #0 {main}
thrown in %s on line %d thrown in %s on line %d

View file

@ -21,7 +21,7 @@ B::checkConstants();
int(1) int(1)
int(2) int(2)
Fatal error: Uncaught Error: Undefined class constant 'Z' in %s:11 Fatal error: Uncaught Error: Undefined class constant 'B::Z' in %s:11
Stack trace: Stack trace:
#0 %s(15): B::checkConstants() #0 %s(15): B::checkConstants()
#1 {main} #1 {main}