forked from StanAngeloff/php.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_syntax.php
165 lines (150 loc) · 3.99 KB
/
update_syntax.php
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
/**
* Script to gather up all native functions, classes, and interfaces from any release of
* PHP for the purposes of updating the VIM syntax file.
*
* @author Paul Garvin <[email protected]>
* @copyright Copyright 2009 Paul Garvin
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*
* @author Stan Angeloff <[email protected]>
*/
/**
* This script works by loading up PHP extensions and using reflection to pull
* the functions, classes, and constants out of those extesions. The list of extensions
* below are ones included with PHP 5.3 source code. The ones commented out depend on
* an external library being installed, are Unix specific, or just not commonly used.
*
* Add, comment, or uncomment to fit your needs or particular PHP installation.
* Remember that some of these extensions are likely shared extensions and must be
* enabled in your php.ini file.
*
* NOTE: mysqlnd is not included because it exposes no functions, classes, or constants.
* The pdo_* extensions are not included in the list because they do not expose any
* functions, classes, or constants themselves. The constants and methods specific
* to that driver are exposed though the PDO extension itself. The pdo_* extensions
* must still be enabled (compiled in or loaded as shared) for these constants to show up.
*/
$allowed_extensions = array(
# 'calendar',
# 'com_dotnet',
# 'ctype',
# 'dba',
# 'enchant',
# 'exif',
# 'fileinfo',
# 'filter',
# 'ftp',
# 'gmp',
# 'imap',
# 'interbase',
# 'intl',
# 'ldap',
# 'mssql',
# 'oci8',
# 'oci8_11g',
# 'odbc',
# 'pcntl',
# 'posix',
# 'pspell',
# 'readline',
# 'recode',
# 'shmop',
# 'snmp',
# 'sqlite',
# 'sybase_ct',
# 'sysvmsg',
# 'sysvsem',
# 'sysvshm',
# 'tidy',
# 'xmlrpc',
# 'xsl',
'bcmath',
'bz2',
'core',
'curl',
'date',
'dom',
'ereg',
'gd',
'gettext',
'hash',
'iconv',
'json',
'libxml',
'mbstring',
'mcrypt',
'mhash',
'mysql',
'mysqli',
'openssl',
'pcre',
'pdo',
'pgsql',
'phar',
'reflection',
'session',
'simplexml',
'soap',
'sockets',
'spl',
'sqlite3',
'standard',
'tokenizer',
'wddx',
'xml',
'xmlreader',
'xmlwriter',
'zip',
'zlib',
);
$processed = array();
foreach ($allowed_extensions as $extension) {
try {
$details = array();
$options = new ReflectionExtension($extension);
$classes = array();
$functions = array_keys($options->getFunctions());
$constants = array_keys($options->getConstants());
foreach ($options->getClasses() as $class) {
$classes[] = $class->getName();
$constants = array_merge($constants, array_keys($class->getConstants()));
}
$constants = array_unique($constants);
$details['name'] = $options->getName();
if (sizeof ($functions)) {
$details['functions'] = implode(' ', $functions);
}
if (sizeof ($constants)) {
$details['constants'] = implode(' ', $constants);
}
if (sizeof ($classes)) {
$details['classes'] = implode(' ', $classes);
}
$processed[$extension] = $details;
} catch (Exception $e) {
print "ERROR: '{$extension}' -- " . $e->getMessage() . "\n";
}
}
$code = "syn case match\n\n";
foreach ($processed as $extension) {
if (isset ($extension['constants'])) {
$code = $code . '" ' . $extension['name'] . "\n";
$code = $code . 'syn keyword phpConstants ' . $extension['constants'] . " contained\n\n";
}
}
$code = $code . "syn case ignore\n\n";
foreach ($processed as $extension) {
$code = $code . '" ' . $extension['name'] . "\n";
if (isset ($extension['functions'])) {
$code = $code . 'syn keyword phpFunctions ' . $extension['functions'] . " contained\n";
}
if (isset ($extension['classes'])) {
$code = $code . 'syn keyword phpClasses ' . $extension['classes'] . " contained\n\n";
}
}
file_put_contents(
__DIR__ . '/syntax/php.vim',
str_replace('${code}', $code, file_get_contents(__DIR__ . '/syntax/php.template')),
LOCK_EX
);