Permalink
Browse files

Version 1.0: Initial upload

  • Loading branch information...
0 parents commit 6ba3b35b6da7cdf261caa11d20b6f8eac45d4032 Laruence committed with Aug 5, 2012
Showing with 794 additions and 0 deletions.
  1. +6 −0 README
  2. +115 −0 php_vimgen.php
  3. +673 −0 syntax/php.vim
6 README
@@ -0,0 +1,6 @@
+This is a mirror of http://www.vim.org/scripts/script.php?script_id=4159
+
+This script is based on Paul Garvin's vimuser 5.3 script vimscript #2874. Thanks for his script generator.
+
+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.4
+
@@ -0,0 +1,115 @@
+<?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',
+ 'yaf', 'yar', 'taint',
+ );
+
+$out_file = '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);
+
+?>
Oops, something went wrong.

0 comments on commit 6ba3b35

Please sign in to comment.