]> granicus.if.org Git - php/commitdiff
- MFH: Function deprecation flag
authorMarcus Boerger <helly@php.net>
Sat, 25 Feb 2006 18:25:45 +0000 (18:25 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 25 Feb 2006 18:25:45 +0000 (18:25 +0000)
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_compile.h
Zend/zend_execute_API.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/reflection/php_reflection.c
main/php.h

index 00f5166f043ebda980748d37387e1454e4ace1a1..d1766d4610061f566e099fb24af7a284aa16c3d2 100644 (file)
@@ -1554,7 +1554,9 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, zend_function_entr
                }
                if (ptr->flags) {
                        if (!(ptr->flags & ZEND_ACC_PPP_MASK)) {
-                               zend_error(error_type, "Invalid access level for %s%s%s() - access must be exactly one of public, protected or private", scope ? scope->name : "", scope ? "::" : "", ptr->fname);
+                               if (ptr->flags != ZEND_ACC_DEPRECATED || scope) {
+                                       zend_error(error_type, "Invalid access level for %s%s%s() - access must be exactly one of public, protected or private", scope ? scope->name : "", scope ? "::" : "", ptr->fname);
+                               }
                                internal_function->fn_flags = ZEND_ACC_PUBLIC | ptr->flags;
                        } else {
                                internal_function->fn_flags = ptr->flags;
index 054494501a9d3eecbcebb3deaffdc416763cd1cd..837335fd22763f4cf15b2e0ddde35dc59feba76f 100644 (file)
@@ -50,7 +50,9 @@ typedef struct _zend_function_entry {
 
 #define ZEND_NAMED_FE(zend_name, name, arg_info)       ZEND_FENTRY(zend_name, name, arg_info, 0)
 #define ZEND_FE(name, arg_info)                                                ZEND_FENTRY(name, ZEND_FN(name), arg_info, 0)
+#define ZEND_DEP_FE(name, arg_info)                 ZEND_FENTRY(name, ZEND_FN(name), arg_info, ZEND_ACC_DEPRECATED)
 #define ZEND_FALIAS(name, alias, arg_info)                     ZEND_FENTRY(name, ZEND_FN(alias), arg_info, 0)
+#define ZEND_DEP_FALIAS(name, alias, arg_info)         ZEND_FENTRY(name, ZEND_FN(alias), arg_info, ZEND_ACC_DEPRECATED)
 #define ZEND_ME(classname, name, arg_info, flags)      ZEND_FENTRY(name, ZEND_FN(classname##_##name), arg_info, flags)
 #define ZEND_ABSTRACT_ME(classname, name, arg_info)    ZEND_FENTRY(name, NULL, arg_info, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT)
 #define ZEND_MALIAS(classname, name, alias, arg_info, flags) \
index 6ac818cff4800b2e1efe033e7330710879df7aed..9c94f591090a0cf2b0f70260dd61af4eb7f9b354 100644 (file)
@@ -136,6 +136,9 @@ typedef struct _zend_try_catch_element {
 /* shadow of parent's private method/property */
 #define ZEND_ACC_SHADOW 0x20000
 
+/* deprecation flag */
+#define ZEND_ACC_DEPRECATED 0x40000
+
 char *zend_visibility_string(zend_uint fn_flags);
 
 
index 1950890b7a5197548a83b6f473893903855a11dc..40a7d9ba5bc5b96a8b25b692ce4f8c14f741a7cb 100644 (file)
@@ -803,6 +803,18 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
                calling_scope = fci_cache->calling_scope;
                fci->object_pp = fci_cache->object_pp;
        }
+       
+       if (EX(function_state).function->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
+               if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) {
+                       zend_error_noreturn(E_ERROR, "Cannot call abstract method %v::%v()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
+               }
+               if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
+                       zend_error(E_STRICT, "Function %s%s%s() is deprecated",
+                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "",
+                               EX(function_state).function->common.scope ? "::" : "",
+                               EX(function_state).function->common.function_name);
+               }
+       }
 
        for (i=0; i<fci->param_count; i++) {
                zval *param;
index 97d705bc12bf6777037791546123109e2c6a8355..f0ecd2b460c0e80b1bf9a4255fbcaed42aebc0cc 100644 (file)
@@ -1784,9 +1784,17 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
        zend_bool should_change_scope;
        zend_op *ctor_opline;
 
-       if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) {
-               zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
-               ZEND_VM_NEXT_OPCODE(); /* Never reached */
+       if (EX(function_state).function->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
+               if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) {
+                       zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
+                       ZEND_VM_NEXT_OPCODE(); /* Never reached */
+               }
+               if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
+                       zend_error(E_STRICT, "Function %s%s%s() is deprecated", 
+                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "",
+                               EX(function_state).function->common.scope ? "::" : "",
+                               EX(function_state).function->common.function_name);
+               };
        }
 
        zend_ptr_stack_2_push(&EG(argument_stack), (void *) opline->extended_value, NULL);
index 1a2f2c76c93899ca636867ee5be8353b4ed70daa..0cb9fb16a0721a8b79ae7b0d88e9b3710097f647 100644 (file)
@@ -132,9 +132,17 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
        zend_bool should_change_scope;
        zend_op *ctor_opline;
 
-       if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) {
-               zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
-               ZEND_VM_NEXT_OPCODE(); /* Never reached */
+       if (EX(function_state).function->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
+               if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) {
+                       zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
+                       ZEND_VM_NEXT_OPCODE(); /* Never reached */
+               }
+               if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
+                       zend_error(E_STRICT, "Function %s%s%s() is deprecated", 
+                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "",
+                               EX(function_state).function->common.scope ? "::" : "",
+                               EX(function_state).function->common.function_name);
+               };
        }
 
        zend_ptr_stack_2_push(&EG(argument_stack), (void *) opline->extended_value, NULL);
index fc0d1e710c28ea6b761d7352e634fc64d805dbcb..9fcd270bf789d574f0b4f4a44df81fc4cb8933b4 100644 (file)
@@ -671,6 +671,9 @@ static void _function_string(string *str, zend_function *fptr, zend_class_entry
 
        string_printf(str, fptr->common.scope ? "%sMethod [ " : "%sFunction [ ", indent);
        string_printf(str, (fptr->type == ZEND_USER_FUNCTION) ? "<user" : "<internal");
+       if (fptr->common.fn_flags & ZEND_ACC_DEPRECATED) {
+               string_printf(str, ", deprecated");
+       }
 #if MBO_0
        if (fptr->type == ZEND_INTERNAL_FUNCTION && ((zend_internal_function*)fptr)->module) {
                string_printf(str, ":%s", ((zend_internal_function*)fptr)->module->name);
@@ -2366,6 +2369,14 @@ ZEND_METHOD(reflection_method, isStatic)
 }
 /* }}} */
 
+/* {{{ proto public bool ReflectionFunction::isDeprecated()
+   Returns whether this function is deprecated */
+ZEND_METHOD(reflection_function, isDeprecated)
+{
+       _function_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_DEPRECATED);
+}
+/* }}} */
+
 /* {{{ proto public bool ReflectionMethod::isConstructor()
    Returns whether this method is the constructor */
 ZEND_METHOD(reflection_method, isConstructor)
@@ -4097,6 +4108,7 @@ static zend_function_entry reflection_function_functions[] = {
        ZEND_ME(reflection_function, getExtension, NULL, 0)
        ZEND_ME(reflection_function, getExtensionName, NULL, 0)
 #endif
+       ZEND_ME(reflection_function, isDeprecated, NULL, 0)
        {NULL, NULL, NULL}
 };
 
@@ -4197,7 +4209,7 @@ static zend_function_entry reflection_parameter_functions[] = {
        ZEND_ME(reflection_parameter, getName, NULL, 0)
        ZEND_ME(reflection_parameter, isPassedByReference, NULL, 0)
        ZEND_ME(reflection_parameter, getDeclaringClass, NULL, 0)
-       ZEND_MALIAS(reflection_parameter, getClass, getDeclaringClass, NULL, 0)
+       ZEND_MALIAS(reflection_parameter, getClass, getDeclaringClass, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED)
        ZEND_ME(reflection_parameter, isArray, NULL, 0)
        ZEND_ME(reflection_parameter, allowsNull, NULL, 0)
        ZEND_ME(reflection_parameter, isOptional, NULL, 0)
@@ -4271,6 +4283,8 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
        reflection_register_implement(reflection_function_ptr, reflector_ptr TSRMLS_CC);
        zend_declare_property_string(reflection_function_ptr, "name", sizeof("name")-1, "", ZEND_ACC_PUBLIC TSRMLS_CC);
 
+       REGISTER_REFLECTION_CLASS_CONST_LONG(function, "IS_DEPRECATED", ZEND_ACC_DEPRECATED);
+
        INIT_CLASS_ENTRY(_reflection_entry, "ReflectionParameter", reflection_parameter_functions);
        _reflection_entry.create_object = reflection_objects_new;
        reflection_parameter_ptr = zend_register_internal_class(&_reflection_entry TSRMLS_CC);
index a667152e7667abdc00f36c694b57f196963c1122..0dbb55c570026ac6582e390d16b9312f854b1bdb 100644 (file)
@@ -340,7 +340,9 @@ END_EXTERN_C()
 
 #define PHP_NAMED_FE   ZEND_NAMED_FE
 #define PHP_FE                 ZEND_FE
+#define PHP_DEP_FE      ZEND_DEP_FE
 #define PHP_FALIAS             ZEND_FALIAS
+#define PHP_DEP_FALIAS ZEND_DEP_FALIAS
 #define PHP_ME          ZEND_ME
 #define PHP_MALIAS      ZEND_MALIAS
 #define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME