Annotation of embedaddon/php/ext/standard/tests/general_functions/is_callable_variation2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test is_callable() function : usage variations - on invalid function names  
                      3: --INI--
                      4: precision=14
                      5: error_reporting = E_ALL & ~E_NOTICE | E_STRICT
                      6: --FILE--
                      7: <?php
                      8: /* Prototype: bool is_callable ( mixed $var [, bool $syntax_only [, string &$callable_name]] );
                      9:    Description: Verify that the contents of a variable can be called as a function
                     10:                 In case of objects, $var = array($SomeObject, 'MethodName')
                     11: */
                     12: 
                     13: /* Prototype: void check_iscallable( $functions );
                     14:    Description: use iscallable() on given string to check for valid function name
                     15:                 returns true if valid function name, false otherwise
                     16: */
                     17: function check_iscallable( $functions ) {
                     18:   $counter = 1;
                     19:   foreach($functions as $func) {
                     20:     echo "-- Iteration  $counter --\n";
                     21:     var_dump( is_callable($func) );  //given only $var argument
                     22:     var_dump( is_callable($func, TRUE) );  //given $var and $syntax argument
                     23:     var_dump( is_callable($func, TRUE, $callable_name) );
                     24:     echo $callable_name, "\n";
                     25:     var_dump( is_callable($func, FALSE) );  //given $var and $syntax argument
                     26:     var_dump( is_callable($func, FALSE, $callable_name) );
                     27:     echo $callable_name, "\n";
                     28:     $counter++;
                     29:   }
                     30: }
                     31: 
                     32: echo "\n*** Testing is_callable() on invalid function names ***\n";
                     33: /* check on unset variables */
                     34: $unset_var = 10;
                     35: unset ($unset_var);
                     36: 
                     37: /* opening file resource type */
                     38: $file_handle = fopen (__FILE__, "r");
                     39: 
                     40: $variants = array (
                     41:   NULL,  // NULL as argument
                     42:   0,  // zero as argument
                     43:   1234567890,  // positive value
                     44:   -100123456782,  // negative value
                     45:   -2.000000,  // negative float value
                     46:   .567,  // positive float value
                     47:   FALSE,  // boolean value
                     48:   array(1, 2, 3),  // array
                     49:   @$unset_var,
                     50:   @$undef_var,  //undefined variable
                     51:   $file_handle
                     52: );
                     53: 
                     54: /* use check_iscallable() to check whether given variable is valid function name
                     55:  *  expected: false
                     56:  */
                     57: check_iscallable($variants);
                     58: 
                     59: /* closing resources used */
                     60: fclose($file_handle);
                     61: 
                     62: ?>
                     63: ===DONE===
                     64: --EXPECTF--
                     65: *** Testing is_callable() on invalid function names ***
                     66: -- Iteration  1 --
                     67: bool(false)
                     68: bool(false)
                     69: bool(false)
                     70: 
                     71: bool(false)
                     72: bool(false)
                     73: 
                     74: -- Iteration  2 --
                     75: bool(false)
                     76: bool(false)
                     77: bool(false)
                     78: 0
                     79: bool(false)
                     80: bool(false)
                     81: 0
                     82: -- Iteration  3 --
                     83: bool(false)
                     84: bool(false)
                     85: bool(false)
                     86: 1234567890
                     87: bool(false)
                     88: bool(false)
                     89: 1234567890
                     90: -- Iteration  4 --
                     91: bool(false)
                     92: bool(false)
                     93: bool(false)
                     94: -100123456782
                     95: bool(false)
                     96: bool(false)
                     97: -100123456782
                     98: -- Iteration  5 --
                     99: bool(false)
                    100: bool(false)
                    101: bool(false)
                    102: -2
                    103: bool(false)
                    104: bool(false)
                    105: -2
                    106: -- Iteration  6 --
                    107: bool(false)
                    108: bool(false)
                    109: bool(false)
                    110: 0.567
                    111: bool(false)
                    112: bool(false)
                    113: 0.567
                    114: -- Iteration  7 --
                    115: bool(false)
                    116: bool(false)
                    117: bool(false)
                    118: 
                    119: bool(false)
                    120: bool(false)
                    121: 
                    122: -- Iteration  8 --
                    123: bool(false)
                    124: bool(false)
                    125: bool(false)
                    126: Array
                    127: bool(false)
                    128: bool(false)
                    129: Array
                    130: -- Iteration  9 --
                    131: bool(false)
                    132: bool(false)
                    133: bool(false)
                    134: 
                    135: bool(false)
                    136: bool(false)
                    137: 
                    138: -- Iteration  10 --
                    139: bool(false)
                    140: bool(false)
                    141: bool(false)
                    142: 
                    143: bool(false)
                    144: bool(false)
                    145: 
                    146: -- Iteration  11 --
                    147: bool(false)
                    148: bool(false)
                    149: bool(false)
                    150: Resource id #%d
                    151: bool(false)
                    152: bool(false)
                    153: Resource id #%d
                    154: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>