]> granicus.if.org Git - php/commitdiff
Fix #65274: Add class name to undef class constant error
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 8 Jan 2020 13:18:14 +0000 (14:18 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 8 Jan 2020 13:18:14 +0000 (14:18 +0100)
NEWS
Zend/tests/class_constants_001.phpt
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
tests/classes/constants_basic_001.phpt
tests/classes/constants_visibility_004.phpt

diff --git a/NEWS b/NEWS
index 9ab884ee43092f42ffcf48c19a61baeb1f5783df..f1909fda44245680469f41c1053470a4a625d32b 100644 (file)
--- 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).
index f36b1af9f628f38b17aab520d0a3b9d0da98de4b..484157fe4b9e7824a9af3579d20de88c37a382a7 100644 (file)
@@ -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
index c38499d97233ab837f63518e4825fe3fb5a77c75..608d24f5080ae961b09448f74ae0cbcd05214837 100644 (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);
                } 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();
                }
index c5a429a9e3bc3776e42439e527ae7c98c49ee3c1..3940598619a67521e2660890cda5228e31ee7d85 100644 (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);
                } 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();
                }
index af9915c2775b022c01e052a536a6774e80681579..796c8d559eb514496d6575c2991f9053beef3659 100644 (file)
@@ -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
index 93acacf3c9096ca8d6c8d02ac33f4204c837df29..983b2e247b11df50afceaab0f9e61acf1914c3d3 100644 (file)
@@ -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}