4 // Author: Matti MÃ¥rds
5 // License: GPL V2 or later
7 // Script to generate a new php.tags file from a downloaded PHP function summary list from
8 // http://cvs.php.net/viewvc.cgi/phpdoc/funcsummary.txt?view=co
9 // The script expects a file funcsummary.txt in /tmp and will write the parsed tags into
12 // wget -O funcsummary.txt "http://cvs.php.net/viewvc.cgi/phpdoc/funcsummary.txt?view=co"
14 // (the script should be run in the top source directory)
16 # (from tagmanager/tm_tag.c:32)
17 define("TA_NAME", 200);
18 define("TA_TYPE", 204);
19 define("TA_ARGLIST", 205);
20 define("TA_VARTYPE", 207);
22 # TMTagType (tagmanager/tm_tag.h:47)
23 define("TYPE_FUNCTION", 128);
25 // Create an array of the lines in the file
26 $file = file('funcsummary.txt');
28 // Create template for a tag (tagmanager format)
29 $tagTpl = "%s%c%d%c%s%c%s";
31 // String to store the output
32 $tagsOutput = array();
34 // Iterate through each line of the file
35 for($line = 0, $lineCount = count($file); $line < $lineCount; ++
$line) {
37 // If the line isn't a function definition, skip it
38 if(!preg_match('/^(?P<retType>\w+) (?P<funcName>[\w:]+)(?P<params>\(.*?\))/', $file[$line], $funcDefMatch)) {
41 // Skip methods as they aren't used for now
42 if (strpos($funcDefMatch['funcName'], '::') !== false) {
46 // Get the function description
47 //$funcDesc = trim($file[$line + 1]);
48 // Geany doesn't use the function description (yet?), so use an empty string to save space
51 // Remove the void parameter, it will only confuse some people
52 if($funcDefMatch['params'] === '(void)') {
53 $funcDefMatch['params'] = '()';
56 // $funcDefMatch['funcName'] = str_replace('::', '->', $funcDefMatch['funcName']);
58 $tagsOutput[] = sprintf($tagTpl, $funcDefMatch['funcName'], TA_TYPE
, TYPE_FUNCTION
,
59 TA_ARGLIST
, $funcDefMatch['params'], TA_VARTYPE
, $funcDefMatch['retType']);
62 $tagsOutput[] = sprintf(
63 '# format=tagmanager - Automatically generated file - do not edit (created on %s)',
68 file_put_contents('data/php.tags', join("\n", $tagsOutput));