[f934d2]: scripts / create_php_tags.php Maximize Restore History

Download this file

create_php_tags.php    75 lines (62 with data), 2.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/php
<?php
// Author: Matti M책rds
// License: GPL V2 or later
//
// Script to generate a new php.tags file from a downloaded PHP function summary list from
//
// http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt
//
// - The script can be run from any directory
// - The script downloads the file funcsummary.txt using PHP's stdlib
# (from tagmanager/tm_tag.c:32)
define("TA_NAME", 200);
define("TA_TYPE", 204);
define("TA_ARGLIST", 205);
define("TA_VARTYPE", 207);
# TMTagType (tagmanager/tm_tag.h:47)
define("TYPE_FUNCTION", 128);
// Create an array of the lines in the file
$url = 'http://svn.php.net/repository/phpdoc/doc-base/trunk/funcsummary.txt';
$file = file($url, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Create template for a tag (tagmanager format)
$tagTpl = "%s%c%d%c%s%c%s";
// String to store the output
$tagsOutput = array();
// String data base path for tags.php
$filePhpTags = implode( DIRECTORY_SEPARATOR,
array(
dirname(dirname(__FILE__)),
'data',
'php.tags'
));
// Iterate through each line of the file
for($line = 0, $lineCount = count($file); $line < $lineCount; ++$line) {
// If the line isn't a function definition, skip it
if(!preg_match('/^(?P<retType>\w+) (?P<funcName>[\w:]+)(?P<params>\(.*?\))/', $file[$line], $funcDefMatch)) {
continue;
}
// Skip methods as they aren't used for now
if (strpos($funcDefMatch['funcName'], '::') !== false) {
continue;
}
// Get the function description
//$funcDesc = trim($file[$line + 1]);
// Geany doesn't use the function description (yet?), so use an empty string to save space
$funcDesc = '';
// Remove the void parameter, it will only confuse some people
if($funcDefMatch['params'] === '(void)') {
$funcDefMatch['params'] = '()';
}
// $funcDefMatch['funcName'] = str_replace('::', '->', $funcDefMatch['funcName']);
$tagsOutput[] = sprintf($tagTpl, $funcDefMatch['funcName'], TA_TYPE, TYPE_FUNCTION,
TA_ARGLIST, $funcDefMatch['params'], TA_VARTYPE, $funcDefMatch['retType']);
}
$tagsOutput[] = sprintf(
'# format=tagmanager - Automatically generated file - do not edit (created on %s)',
date('r'));
// Sort the output
sort($tagsOutput);
file_put_contents($filePhpTags, join("\n", $tagsOutput));
echo "Created:\n${filePhpTags}\n";
echo str_repeat('-',75)."\n";