diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-06 21:16:36 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-06 21:16:36 +0000 |
commit | 0b80d600e22ac218a59e1c09967a3caee91b1981 (patch) | |
tree | cedd11e696331db8daba91fabef9c7584327d7b5 /series/core/trunk/includes/xmlrpc/is_callable.php | |
parent | aa716b0b246bb9efa678dae48c1e36a315b5e3e4 (diff) | |
download | instadisc-0b80d600e22ac218a59e1c09967a3caee91b1981.tar.gz instadisc-0b80d600e22ac218a59e1c09967a3caee91b1981.tar.bz2 instadisc-0b80d600e22ac218a59e1c09967a3caee91b1981.zip |
Series: Imported XML-RPC libraries
Refs #28
Diffstat (limited to 'series/core/trunk/includes/xmlrpc/is_callable.php')
-rw-r--r-- | series/core/trunk/includes/xmlrpc/is_callable.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/series/core/trunk/includes/xmlrpc/is_callable.php b/series/core/trunk/includes/xmlrpc/is_callable.php new file mode 100644 index 0000000..b769c41 --- /dev/null +++ b/series/core/trunk/includes/xmlrpc/is_callable.php | |||
@@ -0,0 +1,53 @@ | |||
1 | <?php | ||
2 | /** | ||
3 | * Replace function is_callable() | ||
4 | * | ||
5 | * @category PHP | ||
6 | * @package PHP_Compat | ||
7 | * @link http://php.net/function.is_callable | ||
8 | * @author Gaetano Giunta <giunta.gaetano@sea-aeroportimilano.it> | ||
9 | * @version $Id: is_callable.php,v 1.3 2006/08/21 14:03:15 ggiunta Exp $ | ||
10 | * @since PHP 4.0.6 | ||
11 | * @require PHP 4.0.0 (true, false, etc...) | ||
12 | * @todo add the 3rd parameter syntax... | ||
13 | */ | ||
14 | if (!function_exists('is_callable')) { | ||
15 | function is_callable($var, $syntax_only=false) | ||
16 | { | ||
17 | if ($syntax_only) | ||
18 | { | ||
19 | /* from The Manual: | ||
20 | * If the syntax_only argument is TRUE the function only verifies | ||
21 | * that var might be a function or method. It will only reject simple | ||
22 | * variables that are not strings, or an array that does not have a | ||
23 | * valid structure to be used as a callback. The valid ones are | ||
24 | * supposed to have only 2 entries, the first of which is an object | ||
25 | * or a string, and the second a string | ||
26 | */ | ||
27 | return (is_string($var) || (is_array($var) && count($var) == 2 && is_string(end($var)) && (is_string(reset($var)) || is_object(reset($var))))); | ||
28 | } | ||
29 | else | ||
30 | { | ||
31 | if (is_string($var)) | ||
32 | { | ||
33 | return function_exists($var); | ||
34 | } | ||
35 | else if (is_array($var) && count($var) == 2 && is_string($method = end($var))) | ||
36 | { | ||
37 | $obj = reset($var); | ||
38 | if (is_string($obj)) | ||
39 | { | ||
40 | $methods = get_class_methods($obj); | ||
41 | return (bool)(is_array($methods) && in_array(strtolower($method), $methods)); | ||
42 | } | ||
43 | else if (is_object($obj)) | ||
44 | { | ||
45 | return method_exists($obj, $method); | ||
46 | } | ||
47 | } | ||
48 | return false; | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | |||
53 | ?> \ No newline at end of file | ||