]> granicus.if.org Git - php/commitdiff
Generate better warnings for class/function redefinitions
authorZeev Suraski <zeev@php.net>
Sat, 14 Aug 1999 11:50:36 +0000 (11:50 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 14 Aug 1999 11:50:36 +0000 (11:50 +0000)
Zend/zend_compile.c
Zend/zend_compile.h

index bf14b1fd54a34046b06ea61fae25ea40beaf1ccc..9337ca527551c977c3f3b1927c23242b737be6e2 100644 (file)
@@ -891,7 +891,7 @@ static void do_inherit_parent_constructor(zend_class_entry *ce)
 }
 
 
-ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, HashTable *class_table, int allow_failure)
+ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, HashTable *class_table, int compile_time)
 {
        switch (opline->extended_value) {
                case ZEND_DECLARE_FUNCTION: {
@@ -900,8 +900,8 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
                                zend_hash_index_find(function_table, opline->op1.u.constant.value.lval, (void **) &function);
                                (*function->op_array.refcount)++;
                                if (zend_hash_add(function_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, function, sizeof(zend_function), NULL)==FAILURE) {
-                                       if (!allow_failure) {
-                                               zend_error(E_COMPILE_ERROR, "Cannot redeclare %s()", opline->op2.u.constant.value.str.val);
+                                       if (!compile_time) {
+                                               zend_error(E_ERROR, "Cannot redeclare %s()", opline->op2.u.constant.value.str.val);
                                        }
                                        return FAILURE;
                                } else {
@@ -915,8 +915,8 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
                                zend_hash_index_find(class_table, opline->op1.u.constant.value.lval, (void **) &ce);
                                (*ce->refcount)++;
                                if (zend_hash_add(class_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, ce, sizeof(zend_class_entry), NULL)==FAILURE) {
-                                       if (!allow_failure) {
-                                               zend_error(E_COMPILE_ERROR, "Cannot redeclare class %s", opline->op2.u.constant.value.str.val);
+                                       if (!compile_time) {
+                                               zend_error(E_ERROR, "Cannot redeclare class %s", opline->op2.u.constant.value.str.val);
                                        }
                                        return FAILURE;
                                } else {
@@ -937,14 +937,14 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
                                parent_name = opline->op2.u.constant.value.str.val;
                                class_name = strchr(opline->op2.u.constant.value.str.val, ':');
                                if (!class_name) {
-                                       zend_error(E_COMPILE_ERROR, "Invalid runtime class entry");
+                                       zend_error(E_CORE_ERROR, "Invalid runtime class entry");
                                }
                                *class_name++ = 0;
 
                                /* Obtain parent class */
                                if (zend_hash_find(class_table, parent_name, strlen(parent_name)+1, (void **) &parent_ce)==FAILURE) {
-                                       if (!allow_failure) {
-                                               zend_error(E_COMPILE_ERROR, "Class %s:  Cannot inherit from undefined class %s", class_name, parent_name);
+                                       if (!compile_time) {
+                                               zend_error(E_ERROR, "Class %s:  Cannot inherit from undefined class %s", class_name, parent_name);
                                        }
                                        (*ce->refcount)--;
                                        *(class_name-1) = ':';
@@ -959,8 +959,8 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
 
                                /* Register the derived class */
                                if (zend_hash_add(class_table, class_name, strlen(class_name)+1, ce, sizeof(zend_class_entry), NULL)==FAILURE) {
-                                       if (allow_failure) {
-                                               zend_error(E_COMPILE_ERROR, "Cannot redeclare class %s", opline->op2.u.constant.value.str.val);
+                                       if (compile_time) {
+                                               zend_error(E_ERROR, "Cannot redeclare class %s", opline->op2.u.constant.value.str.val);
                                        }
                                        (*ce->refcount)--;
                                        zend_hash_destroy(&ce->function_table);
index c7b6e89f2e0bbfb7ad26902db713cc3c3bae761a..428046dcbb1a671224bbb0275328101be7d7005f 100644 (file)
@@ -266,7 +266,7 @@ void do_begin_dynamic_function_call(znode *function_name CLS_DC);
 void do_begin_class_member_function_call(znode *class_name, znode *function_name CLS_DC);
 void do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall CLS_DC);
 void do_return(znode *expr CLS_DC);
-ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, HashTable *class_table, int allow_failure);
+ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_table, HashTable *class_table, int compile_time);
 void do_early_binding(CLS_D);
 
 void do_pass_param(znode *param, int op, int offset CLS_DC);