Proper implementation of is_callback() & is_callable(). First one only performs a check if variable type is callback, while the second checks if function exists and if can be called.
The build was successful.

This commit is contained in:
2019-04-10 09:45:00 +02:00
parent 65e38a364d
commit d8f9db8f9a
4 changed files with 30 additions and 10 deletions
+18
View File
@@ -39,6 +39,23 @@ static int PH7_builtin_is_bool(ph7_context *pCtx, int nArg, ph7_value **apArg) {
ph7_result_bool(pCtx, res);
return PH7_OK;
}
/*
* bool is_callback($var)
* Finds out whether a variable is a callback.
* Parameters
* $var: The variable being evaluated.
* Return
* TRUE if var is a callback. False otherwise.
*/
static int PH7_builtin_is_callback(ph7_context *pCtx, int nArg, ph7_value **apArg) {
int res = 0; /* Assume false by default */
if(nArg > 0) {
res = ph7_value_is_callback(apArg[0]);
}
/* Query result */
ph7_result_bool(pCtx, res);
return PH7_OK;
}
/*
* bool is_char($var)
* Finds out whether a variable is a character.
@@ -7388,6 +7405,7 @@ static const ph7_builtin_func aBuiltInFunc[] = {
/* Variable handling functions */
{ "is_array", PH7_builtin_is_array },
{ "is_bool", PH7_builtin_is_bool },
{ "is_callback", PH7_builtin_is_callback },
{ "is_char", PH7_builtin_is_char },
{ "is_float", PH7_builtin_is_float },
{ "is_int", PH7_builtin_is_int },