4chdir(dirname(__FILE__));
5require_once
'common.php';
6require_once
'../library/HTMLPurifier.auto.php';
9if (version_compare(PHP_VERSION,
'5.2.2',
'<')) {
10 echo
"This script requires PHP 5.2.2 or later, for tokenizer line numbers.";
24chdir(dirname(__FILE__) .
'/../library/');
29 if (strncmp(
'standalone/',
$file, 11) === 0)
continue;
30 if (substr_count(
$file,
'.') > 1)
continue;
39 do {$i++;}
while (is_array($tokens[$i]) && $tokens[$i][0] === T_WHITESPACE);
49function testToken($token, $value_or_token, $value =
null)
51 if (is_null($value)) {
52 if (is_int($value_or_token))
return is_array($token) && $token[0] === $value_or_token;
53 else return $token === $value_or_token;
55 return is_array($token) && $token[0] === $value_or_token && $token[1] === $value;
64 $tokens = token_get_all(file_get_contents(
$file));
66 for ($i = 0, $c = count($tokens); $i < $c; $i++) {
71 while (!
$ok &&
testToken($tokens[$i], T_VARIABLE,
'$this')) {
73 if (!
testToken($tokens[$i], T_OBJECT_OPERATOR))
break;
75 if (
testToken($tokens[$i], T_STRING,
'config'))
$ok =
true;
81 for($i++; $i < $c; $i++) {
82 if ($tokens[$i] ===
',' || $tokens[$i] ===
')' || $tokens[$i] ===
';') {
85 if (is_string($tokens[$i]))
continue;
86 if ($tokens[$i][0] === T_OBJECT_OPERATOR) {
93 $line = $tokens[$i][2];
96 if (!
testToken($tokens[$i], T_STRING,
'get'))
continue;
99 if (!
testToken($tokens[$i],
'('))
continue;
112 if (!
testToken($tokens[$i], T_CONSTANT_ENCAPSED_STRING))
continue;
113 $id = substr($tokens[$i][1], 1, -1);
128echo
"\n$counter/$full_counter instances of \$config or \$this->config found in source code.\n";
130echo
"Generating XML... ";
133$xw->openURI(
'../configdoc/usage.xml');
135$xw->startDocument(
'1.0',
'UTF-8');
136$xw->startElement(
'usage');
138 $xw->startElement(
'directive');
139 $xw->writeAttribute(
'id', $id);
141 $xw->startElement(
'file');
143 foreach ($lines as $line) {
144 $xw->writeElement(
'line', $line);
An exception for terminatinating execution or to throw for unit testing.
testToken($token, $value_or_token, $value=null)
Tests whether or not a token is a particular type.
foreach( $raw_files as $file) consumeWhitespace($tokens, &$i)
Moves the $i cursor to the next non-whitespace token.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file