Version 1.0: Initial upload

This commit is contained in:
Paul Garvin 2009-11-29 00:00:00 +00:00 committed by Able Scraper
commit 09ddf308e3
3 changed files with 773 additions and 0 deletions

3
README Normal file
View file

@ -0,0 +1,3 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2874
This is an updated version of the php.vim syntax file distributed with VIM. The list of PHP constants, functions, and classes was updated to be current with PHP 5.3. Many new classes were added in the 5.2 branch and the distributed version only covers up to 5.1.4. In addition I simplified the file, removing several sections that are not often used (at least by me) such as automatic folding of all control structures and ASP tags support. I also removed several switches designed for b/c with VIM 5.X and 6.X. As an addition I have included the PHP file I used to generate the constant, function, class list. It uses reflection to mine out these items from your PHP installation and generate part of the php.vim script. Before running open up the file and adjust the output file location and the list of extensions to generate syntax for. Then run "php php_vimgen.php" from your shell.

114
php_vimgen.php Normal file
View file

@ -0,0 +1,114 @@
<?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 <paul@paulgarvin.net>
* @copyright Copyright 2009 Paul Garvin
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* 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.
*/
$extensions = array(
'core', 'bcmath', 'bz2', 'calendar', 'com_dotnet',
'ctype', 'curl', 'date', /*'dba',*/ 'dom',
'enchant', 'ereg', 'exif', 'fileinfo', 'filter',
'ftp', 'gd', 'gettext', 'gmp', 'hash',
'iconv', 'imap', /*'interbase',*/ 'intl', 'json',
'ldap', 'libxml', 'mbstring', 'mcrypt', 'mhash',
/*'mssql',*/ 'mysql', 'mysqli', /*'oci8', 'oci8_11g',*/
'odbc', 'openssl', 'pcntl', 'pcre', 'pdo',
'pgsql', 'phar', /*'posix', 'pspell', 'readline',*/
/*'recode',*/ 'reflection', 'session', 'shmop', 'simplexml',
/*'snmp',*/ 'soap', 'sockets', 'spl', 'standard',
'sqlite', 'sqlite3', /*'sybase_ct', 'sysvmsg', 'sysvsem', 'sysvshm',*/
'tidy', 'tokenizer', 'xml', 'xmlreader', 'xmlwriter',
'xmlrpc', 'xsl', /*'wddx',*/ 'zip', 'zlib'
);
$out_file = 'C:\php_vimgen_out.vim'; // Pick your output file & location.
$out_str = '';
$store = array();
$errors = array();
foreach ($extensions as $ext) {
echo "Processing extension '$ext'." . PHP_EOL;
try {
$extension = new ReflectionExtension($ext);
$ext_info = array();
$ext_info['name'] = $extension->getName();
$ext_functions = array_keys($extension->getFunctions());
$ext_constants = array_keys($extension->getConstants());
$classes = $extension->getClasses();
$ext_classes = array();
foreach ($classes as $class) {
$ext_classes[] = $class->getName();
$ext_constants = array_merge($ext_constants, array_keys($class->getConstants()));
}
$ext_constants = array_unique($ext_constants);
if (count($ext_functions)) {
$ext_info['functions'] = implode(' ', $ext_functions);
}
if (count($ext_constants)) {
$ext_info['constants'] = implode(' ', $ext_constants);
}
if (count($ext_classes)) {
$ext_info['classes'] = implode(' ', $ext_classes);
}
} catch (Exception $e) {
$errors[] = "\"Error: '$ext' " . $e->getMessage() . "\n";
echo 'Error Encountered.' . PHP_EOL;
}
$store[$ext] = $ext_info;
}
$out_str .= "syn case match\n\n";
foreach ($store as $ext) {
if (isset($ext['constants'])) {
$out_str .= '" ' . $ext['name'] . "\n";
$out_str .= 'syn keyword phpConstants ' . $ext['constants'] . " contained\n\n";
}
}
$out_str .= "syn case ignore\n\n";
foreach ($store as $ext) {
$out_str .= '" ' . $ext['name'] . "\n";
if (isset($ext['functions'])) {
$out_str .= 'syn keyword phpFunctions ' . $ext['functions'] . " contained\n";
}
if (isset($ext['classes'])) {
$out_str .= 'syn keyword phpClasses ' . $ext['classes'] . " contained\n\n";
}
}
foreach ($errors as $error) {
$out_str .= "$error\n";
}
file_put_contents($out_file, $out_str);
?>

656
syntax/php.vim Normal file

File diff suppressed because one or more lines are too long