2007-12-15 00:21:33 +08:00
|
|
|
--TEST--
|
|
|
|
Test token_get_all() function : usage variations - with logical operators
|
2011-08-01 00:35:09 +08:00
|
|
|
--SKIPIF--
|
|
|
|
<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
|
2007-12-15 00:21:33 +08:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
/* Prototype : array token_get_all(string $source)
|
|
|
|
* Description: splits the given source into an array of PHP languange tokens
|
|
|
|
* Source code: ext/tokenizer/tokenizer.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Passing 'source' argument with different logical operators to test them for tokens
|
|
|
|
* and - T_AND_LOGICAL_AND(265),
|
|
|
|
* or - T_LOGICAL_OR(263),
|
|
|
|
* xor - T_LOGICAL_XOR(264),
|
|
|
|
* && - T_BOOLEAN_AND(279),
|
|
|
|
* || - T_BOOLEAN_OR(278)
|
|
|
|
*/
|
|
|
|
|
|
|
|
echo "*** Testing token_get_all() : 'source' string with different logical operators ***\n";
|
|
|
|
|
|
|
|
// logical operators : 'and', 'or', 'xor', '&&', '||'
|
|
|
|
$source = array (
|
|
|
|
'<?php $a = 1 and 024; ?>',
|
|
|
|
'<?php $b = $b or 0X1E; ?>',
|
|
|
|
'<?php $c = $a xor $b; ?>',
|
|
|
|
'<?php $a = $b && 2; ?>',
|
|
|
|
'<?php $b = $b || 1; ?>'
|
|
|
|
);
|
|
|
|
for($count = 0; $count < count($source); $count++) {
|
|
|
|
echo "-- Iteration ".($count + 1)." --\n";
|
|
|
|
var_dump( token_get_all($source[$count]));
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Done"
|
|
|
|
?>
|
2010-05-25 02:52:36 +08:00
|
|
|
--EXPECTF--
|
2007-12-15 00:21:33 +08:00
|
|
|
*** Testing token_get_all() : 'source' string with different logical operators ***
|
|
|
|
-- Iteration 1 --
|
|
|
|
array(13) {
|
|
|
|
[0]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(6) "<?php "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[1]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$a"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[2]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[3]=>
|
|
|
|
string(1) "="
|
|
|
|
[4]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[5]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) "1"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[6]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[7]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(3) "and"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[8]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[9]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(3) "024"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[10]=>
|
|
|
|
string(1) ";"
|
|
|
|
[11]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[12]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "?>"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-- Iteration 2 --
|
|
|
|
array(13) {
|
|
|
|
[0]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(6) "<?php "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[1]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$b"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[2]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[3]=>
|
|
|
|
string(1) "="
|
|
|
|
[4]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[5]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$b"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[6]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[7]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "or"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[8]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[9]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(4) "0X1E"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[10]=>
|
|
|
|
string(1) ";"
|
|
|
|
[11]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[12]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "?>"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-- Iteration 3 --
|
|
|
|
array(13) {
|
|
|
|
[0]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(6) "<?php "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[1]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$c"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[2]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[3]=>
|
|
|
|
string(1) "="
|
|
|
|
[4]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[5]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$a"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[6]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[7]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(3) "xor"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[8]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[9]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$b"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[10]=>
|
|
|
|
string(1) ";"
|
|
|
|
[11]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[12]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "?>"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-- Iteration 4 --
|
|
|
|
array(13) {
|
|
|
|
[0]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(6) "<?php "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[1]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$a"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[2]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[3]=>
|
|
|
|
string(1) "="
|
|
|
|
[4]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[5]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$b"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[6]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[7]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "&&"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[8]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[9]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) "2"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[10]=>
|
|
|
|
string(1) ";"
|
|
|
|
[11]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[12]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "?>"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-- Iteration 5 --
|
|
|
|
array(13) {
|
|
|
|
[0]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(6) "<?php "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[1]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$b"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[2]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[3]=>
|
|
|
|
string(1) "="
|
|
|
|
[4]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[5]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "$b"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[6]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[7]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "||"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[8]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[9]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) "1"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[10]=>
|
|
|
|
string(1) ";"
|
|
|
|
[11]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(1) " "
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
[12]=>
|
|
|
|
array(3) {
|
|
|
|
[0]=>
|
2010-05-25 02:52:36 +08:00
|
|
|
int(%d)
|
2007-12-15 00:21:33 +08:00
|
|
|
[1]=>
|
|
|
|
string(2) "?>"
|
|
|
|
[2]=>
|
|
|
|
int(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Done
|