]> granicus.if.org Git - php/commitdiff
Fixed bug #43344 (Wrong error message for undefined namespace constant)
authorDmitry Stogov <dmitry@php.net>
Fri, 7 Dec 2007 17:11:24 +0000 (17:11 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 7 Dec 2007 17:11:24 +0000 (17:11 +0000)
20 files changed:
Zend/tests/bug43343.phpt [new file with mode: 0644]
Zend/tests/bug43344_1.phpt [new file with mode: 0644]
Zend/tests/bug43344_10.phpt [new file with mode: 0644]
Zend/tests/bug43344_11.phpt [new file with mode: 0644]
Zend/tests/bug43344_12.phpt [new file with mode: 0644]
Zend/tests/bug43344_13.phpt [new file with mode: 0644]
Zend/tests/bug43344_2.phpt [new file with mode: 0644]
Zend/tests/bug43344_3.phpt [new file with mode: 0644]
Zend/tests/bug43344_4.phpt [new file with mode: 0644]
Zend/tests/bug43344_5.phpt [new file with mode: 0644]
Zend/tests/bug43344_6.phpt [new file with mode: 0644]
Zend/tests/bug43344_7.phpt [new file with mode: 0644]
Zend/tests/bug43344_8.phpt [new file with mode: 0644]
Zend/tests/bug43344_9.phpt [new file with mode: 0644]
Zend/tests/ns_057.phpt
Zend/zend_compile.c
Zend/zend_execute_API.c
Zend/zend_language_parser.y
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/Zend/tests/bug43343.phpt b/Zend/tests/bug43343.phpt
new file mode 100644 (file)
index 0000000..fa1d993
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #43343 (Variable class name)
+--FILE--
+<?php
+namespace Foo;
+class Bar { }
+$foo = 'bar';
+var_dump(new namespace::$foo);
+?>
+--EXPECTF--
+Fatal error: Cannot use 'namespace' as a class name in %sbug43343.php on line 5
diff --git a/Zend/tests/bug43344_1.phpt b/Zend/tests/bug43344_1.phpt
new file mode 100644 (file)
index 0000000..59129d7
--- /dev/null
@@ -0,0 +1,32 @@
+--TEST--
+Bug #43344.1 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+function f1($a=bar) {
+       return $a;
+}
+function f2($a=array(bar)) {
+       return $a[0];
+}
+function f3($a=array(bar=>0)) {
+       reset($a);
+       return key($a);
+}
+echo bar."\n";
+echo f1()."\n";
+echo f2()."\n";
+echo f3()."\n";
+?>
+--EXPECTF--
+Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 13
+bar
+
+Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 3
+bar
+
+Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 6
+bar
+
+Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 9
+bar
diff --git a/Zend/tests/bug43344_10.phpt b/Zend/tests/bug43344_10.phpt
new file mode 100644 (file)
index 0000000..d80a06b
--- /dev/null
@@ -0,0 +1,8 @@
+--TEST--
+Bug #43344.10 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+echo namespace::bar."\n";
+?>
+--EXPECTF--
+Fatal error: Undefined constant 'bar' in %sbug43344_10.php on line %d
diff --git a/Zend/tests/bug43344_11.phpt b/Zend/tests/bug43344_11.phpt
new file mode 100644 (file)
index 0000000..4daa236
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #43344.11 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+function f($a=namespace::bar) {
+       return $a;
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Undefined constant 'bar' in %sbug43344_11.php on line %d
diff --git a/Zend/tests/bug43344_12.phpt b/Zend/tests/bug43344_12.phpt
new file mode 100644 (file)
index 0000000..79dfc65
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #43344.12 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+function f($a=array(namespace::bar)) {
+       return $a[0];
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Undefined constant 'bar' in %sbug43344_12.php on line %d
diff --git a/Zend/tests/bug43344_13.phpt b/Zend/tests/bug43344_13.phpt
new file mode 100644 (file)
index 0000000..d4fff4f
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #43344.13 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+function f($a=array(namespace::bar=>0)) {
+       reset($a);
+       return key($a);
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Undefined constant 'bar' in %sbug43344_13.php on line %d
diff --git a/Zend/tests/bug43344_2.phpt b/Zend/tests/bug43344_2.phpt
new file mode 100644 (file)
index 0000000..1c55559
--- /dev/null
@@ -0,0 +1,9 @@
+--TEST--
+Bug #43344.2 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+echo Foo::bar."\n";
+?>
+--EXPECTF--
+Fatal error: Class 'Foo::Foo' not found in %sbug43344_2.php on line %d
diff --git a/Zend/tests/bug43344_3.phpt b/Zend/tests/bug43344_3.phpt
new file mode 100644 (file)
index 0000000..26a6b46
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #43344.3 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+function f($a=Foo::bar) {
+       return $a;
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Class 'Foo::Foo' not found in %sbug43344_3.php on line %d
diff --git a/Zend/tests/bug43344_4.phpt b/Zend/tests/bug43344_4.phpt
new file mode 100644 (file)
index 0000000..20feaf9
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #43344.4 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+function f($a=array(Foo::bar)) {
+       return $a[0];
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Class 'Foo::Foo' not found in %sbug43344_4.php on line %d
diff --git a/Zend/tests/bug43344_5.phpt b/Zend/tests/bug43344_5.phpt
new file mode 100644 (file)
index 0000000..2ccd029
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Bug #43344.5 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+function f($a=array(Foo::bar=>0)) {
+       reset($a);
+       return key($a);
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Class 'Foo::Foo' not found in %sbug43344_5.php on line %d
diff --git a/Zend/tests/bug43344_6.phpt b/Zend/tests/bug43344_6.phpt
new file mode 100644 (file)
index 0000000..0597b58
--- /dev/null
@@ -0,0 +1,9 @@
+--TEST--
+Bug #43344.6 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+echo namespace::bar."\n";
+?>
+--EXPECTF--
+Fatal error: Undefined constant 'Foo::bar' in %sbug43344_6.php on line %d
diff --git a/Zend/tests/bug43344_7.phpt b/Zend/tests/bug43344_7.phpt
new file mode 100644 (file)
index 0000000..fab79fe
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #43344.7 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+function f($a=namespace::bar) {
+       return $a;
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Undefined constant 'Foo::bar' in %sbug43344_7.php on line %d
diff --git a/Zend/tests/bug43344_8.phpt b/Zend/tests/bug43344_8.phpt
new file mode 100644 (file)
index 0000000..a9272d7
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #43344.8 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+function f($a=array(namespace::bar)) {
+       return $a[0];
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Undefined constant 'Foo::bar' in %sbug43344_8.php on line %d
diff --git a/Zend/tests/bug43344_9.phpt b/Zend/tests/bug43344_9.phpt
new file mode 100644 (file)
index 0000000..b3c5dfb
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Bug #43344.9 (Wrong error message for undefined namespace constant)
+--FILE--
+<?php
+namespace Foo;
+function f($a=array(namespace::bar=>0)) {
+       reset($a);
+       return key($a);
+}
+echo f()."\n";
+?>
+--EXPECTF--
+Fatal error: Undefined constant 'Foo::bar' in %sbug43344_9.php on line %d
index 249634335c6b5c919925fc9f0749d6dd4dd56995..cfa02f923fa53781b8bbd4092e9e2e3eda121328 100755 (executable)
@@ -2,7 +2,7 @@
 057: Usage of 'namespace' in compound names (inside namespase)
 --FILE--
 <?php
-namespace test::ns1;
+namespace Test::ns1;
 
 const C = "const ok\n";
 
index 7cf4234b9787f86945aa9043eebc591739ba25ca..f29aa567f6825820865cfa8d6511596a0d21438b 100644 (file)
@@ -1305,6 +1305,7 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initia
        zend_arg_info *cur_arg_info;
 
        if (class_type->op_type == IS_CONST &&
+           Z_TYPE(class_type->u.constant) == IS_STRING &&
            Z_STRLEN(class_type->u.constant) == 0) {
                /* Usage of namespace as class name not in namespace */
                zval_dtor(&class_type->u.constant);
@@ -1614,6 +1615,7 @@ void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC)
        zend_op *opline;
 
        if (class_name->op_type == IS_CONST &&
+           Z_TYPE(class_name->u.constant) == IS_STRING &&
            Z_STRLEN(class_name->u.constant) == 0) {
                /* Usage of namespace as class name not in namespace */
                zval_dtor(&class_name->u.constant);
@@ -1681,9 +1683,19 @@ int zend_do_begin_class_member_function_call(znode *class_name, znode *method_na
        ulong fetch_type = 0;
 
        if (class_name->op_type == IS_CONST &&
+           Z_TYPE(class_name->u.constant) == IS_STRING &&
            Z_STRLEN(class_name->u.constant) == 0) {
                /* namespace::func() not in namespace */
                zval_dtor(&class_name->u.constant);
+               if (CG(current_namespace)) {
+                       znode tmp;
+
+                       tmp.op_type = IS_CONST;
+                       tmp.u.constant = *CG(current_namespace);
+                       zval_copy_ctor(&tmp.u.constant);
+                       zend_do_build_namespace_name(&tmp, &tmp, method_name TSRMLS_CC);
+                       *method_name = tmp;
+               }
                return zend_do_begin_function_call(method_name, 0 TSRMLS_CC);
        }
 
@@ -3557,6 +3569,17 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con
        ulong fetch_type = 0;
        znode tmp;
 
+       if (constant_container &&
+           constant_container->op_type == IS_CONST &&
+           Z_TYPE(constant_container->u.constant) == IS_STRING &&
+           Z_STRLEN(constant_container->u.constant) == 0) {
+               /* namespace::const */
+               zval_dtor(&constant_container->u.constant);
+               check_namespace = 1;
+               constant_container = NULL;
+               fetch_type = ZEND_FETCH_CLASS_RT_NS_CHECK | IS_CONSTANT_RT_NS_CHECK;;
+       }
+
        switch (mode) {
                case ZEND_CT:
                        if (constant_container) {
@@ -3570,7 +3593,7 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con
                                zend_do_fetch_class_name(NULL, constant_container, constant_name TSRMLS_CC);
                                *result = *constant_container;
                                result->u.constant.type = IS_CONSTANT | fetch_type;
-                       } else if (!zend_constant_ct_subst(result, &constant_name->u.constant TSRMLS_CC)) {
+                       } else if (fetch_type || !zend_constant_ct_subst(result, &constant_name->u.constant TSRMLS_CC)) {
                                if (check_namespace && CG(current_namespace)) {
                                        /* We assume we use constant from the current namespace
                                           if it is not prefixed. */
@@ -3579,22 +3602,13 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con
                                        zval_copy_ctor(&tmp.u.constant);
                                        zend_do_build_namespace_name(&tmp, &tmp, constant_name TSRMLS_CC);
                                        *constant_name = tmp;
-                                       fetch_type = IS_CONSTANT_RT_NS_CHECK;
+                                       fetch_type |= IS_CONSTANT_RT_NS_CHECK;
                                }
                                *result = *constant_name;
                                result->u.constant.type = IS_CONSTANT | fetch_type;
                        }
                        break;
                case ZEND_RT:
-                       if (constant_container &&
-                           constant_container->op_type == IS_CONST &&
-                           Z_STRLEN(constant_container->u.constant) == 0) {
-                               /* Usage of namespace as class name not in namespace */
-                               zval_dtor(&constant_container->u.constant);
-                               constant_container = NULL;
-                               check_namespace = 0;
-                       }
-
                        if (constant_container ||
                            !zend_constant_ct_subst(result, &constant_name->u.constant TSRMLS_CC)) {
                                zend_op *opline;
@@ -3614,11 +3628,11 @@ void zend_do_fetch_constant(znode *result, znode *constant_container, znode *con
                                        tmp.u.constant = *CG(current_namespace);
                                        zval_copy_ctor(&tmp.u.constant);
                                        constant_container = &tmp;
-                                       fetch_type = IS_CONSTANT_RT_NS_CHECK;
+                                       fetch_type |= IS_CONSTANT_RT_NS_CHECK;
                                }
                                opline = get_next_op(CG(active_op_array) TSRMLS_CC);
                                opline->opcode = ZEND_FETCH_CONSTANT;
-                               opline->extended_value = fetch_type  & ~ZEND_FETCH_CLASS_RT_NS_NAME;
+                               opline->extended_value = fetch_type & ~ZEND_FETCH_CLASS_RT_NS_NAME;
                                opline->result.op_type = IS_TMP_VAR;
                                opline->result.u.var = get_temporary_variable(CG(active_op_array));
                                if (constant_container) {
@@ -4692,6 +4706,19 @@ void zend_do_build_namespace_name(znode *result, znode *prefix, znode *name TSRM
 
        if (prefix) {
                *result = *prefix;
+               if (Z_TYPE(result->u.constant) == IS_STRING &&
+                   Z_STRLEN(result->u.constant) == 0) {
+                       /* namespace:: */
+                       if (CG(current_namespace)) {
+                               znode tmp;
+
+                               zval_dtor(&result->u.constant);
+                               tmp.op_type = IS_CONST;
+                               tmp.u.constant = *CG(current_namespace);
+                               zval_copy_ctor(&tmp.u.constant);
+                               zend_do_build_namespace_name(result, NULL, &tmp TSRMLS_CC);
+                       }
+               }
        } else {
                result->op_type = IS_CONST;
                Z_TYPE(result->u.constant) = IS_STRING;
index ff76d3aa4f732b48983c12933ad17fb990113c6d..a6aceb5f1366ccd8a093105f1de6eacc341b18e2 100644 (file)
@@ -483,8 +483,24 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
                is_ref = Z_ISREF_P(p);
 
                if (!zend_get_constant_ex(p->value.str.val, p->value.str.len, &const_value, scope, Z_REAL_TYPE_P(p) TSRMLS_CC)) {
-                       if ((colon = memchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p))) && colon[1] == ':') {
-                               zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));
+                       if ((colon = zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p))) &&
+                           colon > Z_STRVAL_P(p) &&
+                           *(colon-1) == ':') {
+                               if ((Z_TYPE_P(p) & IS_CONSTANT_RT_NS_CHECK) == 0) {
+                                       zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));
+                               } else if (Z_TYPE_P(p) & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                       zend_error(E_ERROR, "Undefined constant '%s'", Z_STRVAL_P(p));
+                               }
+                               Z_STRLEN_P(p) -= ((colon - Z_STRVAL_P(p)) + 1);
+                               if (inline_change) {
+                                       colon = estrndup(colon + 1, Z_STRLEN_P(p));
+                                       efree(Z_STRVAL_P(p));
+                                       Z_STRVAL_P(p) = colon;
+                               } else {
+                                       Z_STRVAL_P(p) = colon + 1;
+                               }
+                       } else if (Z_TYPE_P(p) & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                               zend_error(E_ERROR, "Undefined constant '%s'", Z_STRVAL_P(p));
                        }
                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",  Z_STRVAL_P(p),  Z_STRVAL_P(p));
                        p->type = IS_STRING;
@@ -523,9 +539,19 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
                                continue;
                        }
                        if (!zend_get_constant_ex(str_index, str_index_len - 3, &const_value, scope, str_index[str_index_len - 2] TSRMLS_CC)) {
-                               if ((colon = memchr(str_index, ':', str_index_len - 3)) && colon[1] == ':') {
-                                       zend_error(E_ERROR, "Undefined class constant '%s'", str_index);
-                               }
+                               if ((colon = zend_memrchr(str_index, ':', str_index_len - 3)) &&
+                                   colon > str_index &&
+                                   *(colon-1) == ':') {
+                                       if ((str_index[str_index_len - 2] & IS_CONSTANT_RT_NS_CHECK) == 0) {
+                                               zend_error(E_ERROR, "Undefined class constant '%s'", str_index);
+                                       } else if (str_index[str_index_len - 2] & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                               zend_error(E_ERROR, "Undefined constant '%s'", str_index);
+                                       }
+                                       str_index_len -= ((colon - str_index) + 1);
+                                       str_index = colon + 1;
+                               } else if (str_index[str_index_len - 2] & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                       zend_error(E_ERROR, "Undefined constant '%s'", str_index);
+                               } 
                                zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",     str_index, str_index);
                                ZVAL_STRINGL(&const_value, str_index, str_index_len-3, 1);
                        }
index 343f81d3b3807458167d5230d4b17c78f8b01b4f..a407b50133d433aac006dc8c73375c393297484b 100644 (file)
@@ -656,14 +656,14 @@ function_call:
 class_name:
                T_STRING { $$ = $1; }
        |       T_STATIC { $$.op_type = IS_CONST; ZVAL_STRINGL(&$$.u.constant, "static", sizeof("static")-1, 1);}
-       |       T_NAMESPACE {if (CG(current_namespace)) { $1.op_type = IS_CONST; $1.u.constant = *CG(current_namespace); zval_copy_ctor(&$1.u.constant); zend_do_build_namespace_name(&$$, NULL, &$1 TSRMLS_CC); } else { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); } }
+       |       T_NAMESPACE { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); }
        |       T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_build_namespace_name(&$$, NULL, &$2 TSRMLS_CC); }
        |       class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_build_namespace_name(&$$, &$1, &$3 TSRMLS_CC); }
 ;
 
 fully_qualified_class_name:
                T_STRING { $$ = $1; }
-       |       T_NAMESPACE {if (CG(current_namespace)) { $1.op_type = IS_CONST; $1.u.constant = *CG(current_namespace); zval_copy_ctor(&$1.u.constant); zend_do_build_namespace_name(&$$, NULL, &$1 TSRMLS_CC); } else { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); } }
+       |       T_NAMESPACE { $$.op_type = IS_CONST; ZVAL_EMPTY_STRING(&$$.u.constant); }
        |       T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_build_namespace_name(&$$, NULL, &$2 TSRMLS_CC); }
        |       fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_build_namespace_name(&$$, &$1, &$3 TSRMLS_CC); }
 ;
index e94676461d73b5fd8c076e2ea55121988095030d..51f0efe3f8e4eecc54510c813da413472f4bce83 100644 (file)
@@ -2684,6 +2684,9 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
 
        if (OP1_TYPE == IS_UNUSED) {
                if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
+                       if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                               zend_error_noreturn(E_ERROR, "Undefined constant '%s'", Z_STRVAL(opline->op2.u.constant));
+                       }
                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
                                Z_STRVAL(opline->op2.u.constant),
                                Z_STRVAL(opline->op2.u.constant));
@@ -2707,7 +2710,9 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
                                zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var);
                                ZEND_VM_NEXT_OPCODE();
                        } else if ((opline->extended_value & IS_CONSTANT_RT_NS_CHECK) != 0) {
-                               if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
+                               if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                       zend_error_noreturn(E_ERROR, "Undefined constant '%s::%s'", Z_STRVAL(opline->op1.u.constant), Z_STRVAL(opline->op2.u.constant));
+                               } else if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
                                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
                                                Z_STRVAL(opline->op2.u.constant),
                                                Z_STRVAL(opline->op2.u.constant));
index dda04218f14a3c936153a582afc00e93ec762f93..10a569f5a7853341fd53bd869116290dd075b41c 100644 (file)
@@ -2492,6 +2492,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS
 
        if (IS_CONST == IS_UNUSED) {
                if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
+                       if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                               zend_error_noreturn(E_ERROR, "Undefined constant '%s'", Z_STRVAL(opline->op2.u.constant));
+                       }
                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
                                Z_STRVAL(opline->op2.u.constant),
                                Z_STRVAL(opline->op2.u.constant));
@@ -2515,7 +2518,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS
                                zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var);
                                ZEND_VM_NEXT_OPCODE();
                        } else if ((opline->extended_value & IS_CONSTANT_RT_NS_CHECK) != 0) {
-                               if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
+                               if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                       zend_error_noreturn(E_ERROR, "Undefined constant '%s::%s'", Z_STRVAL(opline->op1.u.constant), Z_STRVAL(opline->op2.u.constant));
+                               } else if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
                                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
                                                Z_STRVAL(opline->op2.u.constant),
                                                Z_STRVAL(opline->op2.u.constant));
@@ -9812,6 +9817,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
 
        if (IS_VAR == IS_UNUSED) {
                if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
+                       if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                               zend_error_noreturn(E_ERROR, "Undefined constant '%s'", Z_STRVAL(opline->op2.u.constant));
+                       }
                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
                                Z_STRVAL(opline->op2.u.constant),
                                Z_STRVAL(opline->op2.u.constant));
@@ -9835,7 +9843,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                                zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var);
                                ZEND_VM_NEXT_OPCODE();
                        } else if ((opline->extended_value & IS_CONSTANT_RT_NS_CHECK) != 0) {
-                               if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
+                               if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                       zend_error_noreturn(E_ERROR, "Undefined constant '%s::%s'", Z_STRVAL(opline->op1.u.constant), Z_STRVAL(opline->op2.u.constant));
+                               } else if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
                                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
                                                Z_STRVAL(opline->op2.u.constant),
                                                Z_STRVAL(opline->op2.u.constant));
@@ -16526,6 +16536,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG
 
        if (IS_UNUSED == IS_UNUSED) {
                if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
+                       if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                               zend_error_noreturn(E_ERROR, "Undefined constant '%s'", Z_STRVAL(opline->op2.u.constant));
+                       }
                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
                                Z_STRVAL(opline->op2.u.constant),
                                Z_STRVAL(opline->op2.u.constant));
@@ -16549,7 +16562,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG
                                zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var);
                                ZEND_VM_NEXT_OPCODE();
                        } else if ((opline->extended_value & IS_CONSTANT_RT_NS_CHECK) != 0) {
-                               if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
+                               if (opline->extended_value & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                       zend_error_noreturn(E_ERROR, "Undefined constant '%s::%s'", Z_STRVAL(opline->op1.u.constant), Z_STRVAL(opline->op2.u.constant));
+                               } else if (!zend_get_constant(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
                                        zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
                                                Z_STRVAL(opline->op2.u.constant),
                                                Z_STRVAL(opline->op2.u.constant));