1--TEST--
2Test is_callable() function : usage variations - defined functions
3--FILE--
4<?php
5function check_iscallable( $functions ) {
6  $counter = 1;
7  foreach($functions as $func) {
8    echo "-- Iteration  $counter --\n";
9    var_dump( is_callable($func) );  //given only $var argument
10    var_dump( is_callable($func, TRUE) );  //given $var and $syntax argument
11    var_dump( is_callable($func, TRUE, $callable_name) );
12    echo $callable_name, "\n";
13    var_dump( is_callable($func, FALSE) );  //given $var and $syntax argument
14    var_dump( is_callable($func, FALSE, $callable_name) );
15    echo $callable_name, "\n";
16    $counter++;
17  }
18}
19
20echo "\n*** Testing is_callable() on defined functions ***\n";
21/* function name with simple string */
22function someFunction() {
23}
24
25/* function name with mixed string and integer */
26function x123() {
27}
28
29/* function name as NULL */
30function NULL() {
31}
32
33/* function name with boolean name */
34function false() {
35}
36
37/* function name with string and special character */
38function Hello_World() {
39}
40
41$defined_functions = array (
42  $functionVar1 = 'someFunction',
43  $functionVar2 = 'x123',
44  $functionVar3 = 'NULL',
45  $functionVar4 = 'false',
46  $functionVar5 = "Hello_World"
47);
48/* use check_iscallable() to check whether given string is valid function name
49 *  expected: true as it is valid callback
50 */
51check_iscallable($defined_functions);
52
53?>
54--EXPECT--
55*** Testing is_callable() on defined functions ***
56-- Iteration  1 --
57bool(true)
58bool(true)
59bool(true)
60someFunction
61bool(true)
62bool(true)
63someFunction
64-- Iteration  2 --
65bool(true)
66bool(true)
67bool(true)
68x123
69bool(true)
70bool(true)
71x123
72-- Iteration  3 --
73bool(true)
74bool(true)
75bool(true)
76NULL
77bool(true)
78bool(true)
79NULL
80-- Iteration  4 --
81bool(true)
82bool(true)
83bool(true)
84false
85bool(true)
86bool(true)
87false
88-- Iteration  5 --
89bool(true)
90bool(true)
91bool(true)
92Hello_World
93bool(true)
94bool(true)
95Hello_World
96