]> granicus.if.org Git - php/commitdiff
@- Added is_callable() function that can be used to find out whether
authorAndrei Zmievski <andrei@php.net>
Wed, 9 May 2001 20:06:39 +0000 (20:06 +0000)
committerAndrei Zmievski <andrei@php.net>
Wed, 9 May 2001 20:06:39 +0000 (20:06 +0000)
@  its argument is a valid callable construct. (Andrei)

ext/standard/basic_functions.c
ext/standard/basic_functions.h

index 5374c248430f447d40a154aab91538f167a96241..41c2d403f9e59f0f16879d67ed1b713ac0da685d 100644 (file)
@@ -336,6 +336,7 @@ function_entry basic_functions[] = {
        PHP_FE(is_array,                                                                first_arg_allow_ref)
        PHP_FE(is_object,                                                               first_arg_allow_ref)
     PHP_FE(is_scalar,                               NULL)
+       PHP_FE(is_callable,                                                             third_argument_force_ref)
 
        PHP_FE(error_log,                                                               NULL)
        PHP_FE(call_user_func,                                                  NULL)
@@ -2628,6 +2629,36 @@ PHP_FUNCTION(parse_ini_file)
 /* }}} */
 
 
+/* {{{ proto bool is_callable(mixed var [, bool syntax_only [, string callable_name ]]) */
+PHP_FUNCTION(is_callable)
+{
+       zval **var, **syntax_only, **callable_name;
+       char *name;
+       zend_bool retval;
+       zend_bool syntax = 0;
+
+       if (ZEND_NUM_ARGS() < 1 || ZEND_NUM_ARGS() > 3 ||
+               zend_get_parameters_ex(ZEND_NUM_ARGS(), &var, &syntax_only, &callable_name) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+
+       if (ZEND_NUM_ARGS() > 1) {
+               convert_to_boolean_ex(syntax_only);
+               syntax = Z_BVAL_PP(syntax_only);
+       }
+
+       if (ZEND_NUM_ARGS() > 2) {
+               retval = zend_is_callable(*var, syntax, &name);
+               zval_dtor(*callable_name);
+               ZVAL_STRING(*callable_name, name, 0);
+       } else
+               retval = zend_is_callable(*var, syntax, NULL);
+
+       RETURN_BOOL(retval);
+}
+/* }}} */
+
+
 /*
  * Local variables:
  * tab-width: 4
index 381ab0496985e2042f601f26721ea1ff63ac6ac6..86e7756c7445151c02a2d547c1a2ef1d29b5ce88 100644 (file)
@@ -77,6 +77,7 @@ PHP_FUNCTION(is_string);
 PHP_FUNCTION(is_array);
 PHP_FUNCTION(is_object);
 PHP_FUNCTION(is_scalar);
+PHP_FUNCTION(is_callable);
 
 PHP_FUNCTION(error_log);