]> 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:12:22 +0000 (17:12 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 7 Dec 2007 17:12:22 +0000 (17:12 +0000)
21 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/lsb_018.phpt
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 c7877cddf7522945ea69e30b00cc808437df9388..1fa560470030d084c987dbb09eaa706354b5ee60 100755 (executable)
@@ -93,3 +93,41 @@ object(Baz)#%d (1) {
   int(2)
 }
 ===DONE===
+--UEXPECTF--
+object(Foo)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(0)
+}
+object(Bar)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(1)
+}
+object(Baz)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(2)
+}
+object(Foo)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(0)
+}
+object(Bar)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(1)
+}
+object(Baz)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(2)
+}
+object(Foo)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(0)
+}
+object(Bar)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(1)
+}
+object(Baz)#%d (1) {
+  [u"instanceId":u"Singleton":private]=>
+  int(2)
+}
+===DONE===
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 aacfb97b927872e580eb219e0505fc6dac68a37e..8dfcc14a1af9b26bd957d61af6e4df7b96d3fdab 100644 (file)
@@ -1395,6 +1395,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) == ZEND_STR_TYPE &&
            Z_UNILEN(class_type->u.constant) == 0) {
                /* Usage of namespace as class name not in namespace */
                zval_dtor(&class_type->u.constant);
@@ -1758,6 +1759,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) == ZEND_STR_TYPE &&
            Z_UNILEN(class_name->u.constant) == 0) {
                /* Usage of namespace as class name not in namespace */
                zval_dtor(&class_name->u.constant);
@@ -1835,9 +1837,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) == ZEND_STR_TYPE &&
            Z_UNILEN(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);
        }
 
@@ -3868,6 +3880,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) == ZEND_STR_TYPE &&
+           Z_UNILEN(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) {
@@ -3881,7 +3904,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. */
@@ -3890,22 +3913,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_UNILEN(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;
@@ -3925,11 +3939,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) {
@@ -5181,6 +5195,19 @@ void zend_do_build_namespace_name(znode *result, znode *prefix, znode *name TSRM
 
        if (prefix) {
                *result = *prefix;
+               if (Z_TYPE(result->u.constant) == ZEND_STR_TYPE &&
+                   Z_UNILEN(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) = ZEND_STR_TYPE;
index 77d3b3c52543a460460c863403d74a7c60251a0e..ab9d25c9e8cb21536c2d26acc38b0254566c9db2 100644 (file)
@@ -511,7 +511,32 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
                                } else {
                                        colon.s++;
                                }
-                               zend_error(E_ERROR, "Undefined class constant '%v'", colon);
+                               if ((Z_TYPE_P(p) & IS_CONSTANT_RT_NS_CHECK) == 0) {
+                                       zend_error(E_ERROR, "Undefined class constant '%v'", colon);
+                               } else if (Z_TYPE_P(p) & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                       zend_error(E_ERROR, "Undefined constant '%v'", Z_STRVAL_P(p));
+                               }
+                               if (UG(unicode)) {
+                                       Z_USTRLEN_P(p) -= ((colon.u - Z_USTRVAL_P(p)));
+                                       if (inline_change) {
+                                               colon.u = eustrndup(colon.u, Z_USTRLEN_P(p));
+                                               efree(Z_USTRVAL_P(p));
+                                               Z_USTRVAL_P(p) = colon.u;
+                                       } else {
+                                               Z_USTRVAL_P(p) = colon.u;
+                                       }
+                               } else {
+                                       Z_STRLEN_P(p) -= ((colon.s - Z_STRVAL_P(p)));
+                                       if (inline_change) {
+                                               colon.s = estrndup(colon.s, Z_STRLEN_P(p));
+                                               efree(Z_STRVAL_P(p));
+                                               Z_STRVAL_P(p) = colon.s;
+                                       } else {
+                                               Z_STRVAL_P(p) = colon.s;
+                                       }
+                               }
+                       } else if (Z_TYPE_P(p) & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                               zend_error(E_ERROR, "Undefined constant '%v'", Z_UNIVAL_P(p));
                        }
                        zend_error(E_NOTICE, "Use of undefined constant %v - assumed '%v'", Z_UNIVAL_P(p), Z_UNIVAL_P(p));
                        Z_TYPE_P(p) = UG(unicode) ? IS_UNICODE : IS_STRING;
@@ -550,10 +575,30 @@ ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *sco
                                continue;
                        }
                        if (!zend_u_get_constant_ex(ZEND_STR_TYPE, str_index, str_index_len - 3, &const_value, scope, (UG(unicode) ? str_index.u[str_index_len-2] : str_index.s[str_index_len-2]) TSRMLS_CC)) {
-                               if ((UG(unicode) && (colon.u = u_memchr(str_index.u, ':', str_index_len - 3)) && colon.u[1] == ':') ||
-                                       (!UG(unicode) && (colon.s = memchr(str_index.s, ':', str_index_len - 3)) && colon.s[1] == ':')
-                               ) {
-                                       zend_error(E_ERROR, "Undefined class constant '%v'", str_index);
+                               if (UG(unicode)) {
+                                       if ((colon.u = u_memrchr(str_index.u, ':', str_index_len - 3)) && colon.u > str_index.u && *(colon.u-1) == ':') {
+                                               if ((str_index.u[str_index_len - 2] & IS_CONSTANT_RT_NS_CHECK) == 0) {
+                                                       zend_error(E_ERROR, "Undefined class constant '%v'", str_index);
+                                               } else if (str_index.u[str_index_len - 2] & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                                       zend_error(E_ERROR, "Undefined constant '%v'", str_index);
+                                               }
+                                               str_index_len -= ((colon.u - str_index.u) + 1);
+                                               str_index.u = colon.u + 1;
+                                       } else if (str_index.u[str_index_len - 2] & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                               zend_error(E_ERROR, "Undefined constant '%v'", str_index);
+                                       }
+                               } else {
+                                       if ((colon.s = zend_memrchr(str_index.s, ':', str_index_len - 3)) && colon.s > str_index.s  && *(colon.s-1) == ':') {
+                                               if ((str_index.s[str_index_len - 2] & IS_CONSTANT_RT_NS_CHECK) == 0) {
+                                                       zend_error(E_ERROR, "Undefined class constant '%v'", str_index);
+                                               } else if (str_index.s[str_index_len - 2] & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                                       zend_error(E_ERROR, "Undefined constant '%v'", str_index);
+                                               }
+                                               str_index_len -= ((colon.s - str_index.s) + 1);
+                                               str_index.s = colon.s + 1;
+                                       } else if (str_index.s[str_index_len - 2] & ZEND_FETCH_CLASS_RT_NS_CHECK) {
+                                               zend_error(E_ERROR, "Undefined constant '%v'", str_index);
+                                       }
                                }
                                zend_error(E_NOTICE, "Use of undefined constant %v - assumed '%v'",     str_index, str_index);
                                ZVAL_TEXTL(&const_value, str_index, str_index_len-3, 1);
index 976c069edb811fcdce2356dc7f871300493189cb..d0d08be89cdbf32519922819afbb2e762bb76eca 100644 (file)
@@ -663,14 +663,14 @@ function_call:
 class_name:
                T_STRING { $$ = $1; }
        |       T_STATIC { $$.op_type = IS_CONST; ZVAL_ASCII_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_TEXT(&$$.u.constant); } }
+       |       T_NAMESPACE { $$.op_type = IS_CONST; ZVAL_EMPTY_TEXT(&$$.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_TEXT(&$$.u.constant); } }
+       |       T_NAMESPACE { $$.op_type = IS_CONST; ZVAL_EMPTY_TEXT(&$$.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 cfc603266a4d89485a60ecc255adbd8e89906ee3..0d3cd4ced0e7932fc4d1cc31a8b8c2db0b98c0c4 100644 (file)
@@ -2745,6 +2745,9 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|UNUSED|CONST, CONST)
 
        if (OP1_TYPE == IS_UNUSED) {
                if (!zend_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(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 '%R'", Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
+                       }
                        zend_error(E_NOTICE, "Use of undefined constant %R - assumed '%R'",
                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
@@ -2768,7 +2771,9 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|UNUSED|CONST, 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_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(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 '%R::%R'", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
+                               } else if (!zend_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
                                        zend_error(E_NOTICE, "Use of undefined constant %R - assumed '%R'",
                                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
                                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
index b356357e10d1536cd6f459e79b1d03a72df1735c..8bea94832c75e8737b60d4b60faca0aa45392125 100644 (file)
@@ -2568,6 +2568,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS
 
        if (IS_CONST == IS_UNUSED) {
                if (!zend_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(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 '%R'", Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
+                       }
                        zend_error(E_NOTICE, "Use of undefined constant %R - assumed '%R'",
                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
@@ -2591,7 +2594,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_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(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 '%R::%R'", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
+                               } else if (!zend_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
                                        zend_error(E_NOTICE, "Use of undefined constant %R - assumed '%R'",
                                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
                                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
@@ -10154,6 +10159,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
 
        if (IS_VAR == IS_UNUSED) {
                if (!zend_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(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 '%R'", Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
+                       }
                        zend_error(E_NOTICE, "Use of undefined constant %R - assumed '%R'",
                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
@@ -10177,7 +10185,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_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(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 '%R::%R'", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
+                               } else if (!zend_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
                                        zend_error(E_NOTICE, "Use of undefined constant %R - assumed '%R'",
                                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
                                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
@@ -17098,6 +17108,9 @@ static int ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARG
 
        if (IS_UNUSED == IS_UNUSED) {
                if (!zend_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(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 '%R'", Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
+                       }
                        zend_error(E_NOTICE, "Use of undefined constant %R - assumed '%R'",
                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
@@ -17121,7 +17134,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_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(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 '%R::%R'", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));
+                               } else if (!zend_u_get_constant(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant), &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) {
                                        zend_error(E_NOTICE, "Use of undefined constant %R - assumed '%R'",
                                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant),
                                                Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant));