token_get_all_variation1.phpt [plain text]
--TEST--
Test token_get_all() function : usage variations - unexpected values for 'source' argument
--SKIPIF--
<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
--FILE--
<?php
echo "*** Testing token_get_all() : unexpected values for 'source' argument ***\n";
$unset_var = 10;
unset ($unset_var);
class MyClass
{
public function __toString()
{
return "object";
}
}
$fp = fopen(__FILE__, 'r');
$source_values = array(
0,
1,
12345,
-2345,
10.5,
-10.5,
10.1234567e8,
10.7654321E-8,
.5,
array(),
array(0),
array(1),
array(1, 2),
array('color' => 'red', 'item' => 'pen'),
NULL,
null,
true,
false,
TRUE,
FALSE,
"",
'',
new MyClass(),
$fp,
@$undefined_var,
@$unset_var,
);
for($count = 0; $count < count($source_values); $count++) {
echo "--Iteration ".($count + 1)." --\n";
var_dump( token_get_all($source_values[$count]));
};
fclose($fp);
echo "Done"
?>
--EXPECTF--
*** Testing token_get_all() : unexpected values for 'source' argument ***
--Iteration 1 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(1) "0"
[2]=>
int(1)
}
}
--Iteration 2 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(1) "1"
[2]=>
int(1)
}
}
--Iteration 3 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(5) "12345"
[2]=>
int(1)
}
}
--Iteration 4 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(5) "-2345"
[2]=>
int(1)
}
}
--Iteration 5 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(4) "10.5"
[2]=>
int(1)
}
}
--Iteration 6 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(5) "-10.5"
[2]=>
int(1)
}
}
--Iteration 7 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(10) "1012345670"
[2]=>
int(1)
}
}
--Iteration 8 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(13) "1.07654321E-7"
[2]=>
int(1)
}
}
--Iteration 9 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(3) "0.5"
[2]=>
int(1)
}
}
--Iteration 10 --
Warning: token_get_all() expects parameter 1 to be string, array given in %s on line %d
NULL
--Iteration 11 --
Warning: token_get_all() expects parameter 1 to be string, array given in %s on line %d
NULL
--Iteration 12 --
Warning: token_get_all() expects parameter 1 to be string, array given in %s on line %d
NULL
--Iteration 13 --
Warning: token_get_all() expects parameter 1 to be string, array given in %s on line %d
NULL
--Iteration 14 --
Warning: token_get_all() expects parameter 1 to be string, array given in %s on line %d
NULL
--Iteration 15 --
array(0) {
}
--Iteration 16 --
array(0) {
}
--Iteration 17 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(1) "1"
[2]=>
int(1)
}
}
--Iteration 18 --
array(0) {
}
--Iteration 19 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(1) "1"
[2]=>
int(1)
}
}
--Iteration 20 --
array(0) {
}
--Iteration 21 --
array(0) {
}
--Iteration 22 --
array(0) {
}
--Iteration 23 --
array(1) {
[0]=>
array(3) {
[0]=>
int(%d)
[1]=>
string(6) "object"
[2]=>
int(1)
}
}
--Iteration 24 --
Warning: token_get_all() expects parameter 1 to be string, resource given in %s on line %d
NULL
--Iteration 25 --
array(0) {
}
--Iteration 26 --
array(0) {
}
Done