diff --git a/NEWS b/NEWS index 9ab884ee430..f1909fda442 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ PHP NEWS . Removed the pdo_odbc.db2_instance_name php.ini directive. (Kalle) . Fixed bug #77619 (Wrong reflection on MultipleIterator::__construct). (Fabien Villepinte) + . Fixed bug #65274 (Enhance undefined class constant error with class name). + (Nikita) - Date: . Fixed bug #65547 (Default value for sunrise/sunset zenith still wrong). diff --git a/Zend/tests/class_constants_001.phpt b/Zend/tests/class_constants_001.phpt index f36b1af9f62..484157fe4b9 100644 --- a/Zend/tests/class_constants_001.phpt +++ b/Zend/tests/class_constants_001.phpt @@ -19,7 +19,7 @@ echo "Done\n"; string(6) "string" 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: #0 {main} thrown in %s on line %d diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index c38499d9723..608d24f5080 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -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); } 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)); HANDLE_EXCEPTION(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index c5a429a9e3b..3940598619a 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -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); } 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)); 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); } 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)); 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); } 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)); HANDLE_EXCEPTION(); } diff --git a/tests/classes/constants_basic_001.phpt b/tests/classes/constants_basic_001.phpt index af9915c2775..796c8d559eb 100644 --- a/tests/classes/constants_basic_001.phpt +++ b/tests/classes/constants_basic_001.phpt @@ -79,7 +79,7 @@ string(6) "hello2" 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: #0 {main} thrown in %s on line %d diff --git a/tests/classes/constants_visibility_004.phpt b/tests/classes/constants_visibility_004.phpt index 93acacf3c90..983b2e247b1 100644 --- a/tests/classes/constants_visibility_004.phpt +++ b/tests/classes/constants_visibility_004.phpt @@ -21,7 +21,7 @@ B::checkConstants(); int(1) 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: #0 %s(15): B::checkConstants() #1 {main}