git subrepo clone (merge) https://github.com/stanangeloff/php.vim.git ./dotfiles/.vim/plugged/php.vim

subrepo:
  subdir:   "dotfiles/.vim/plugged/php.vim"
  merged:   "930aec5c"
upstream:
  origin:   "https://github.com/stanangeloff/php.vim.git"
  branch:   "master"
  commit:   "930aec5c"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
This commit is contained in:
Git E2E Dev Test Username 2022-10-18 10:36:27 -04:00
parent 76b2929ec8
commit 20b4a91fbb
10 changed files with 1685 additions and 0 deletions

View file

@ -0,0 +1,12 @@
; DO NOT EDIT (unless you know what you are doing)
;
; This subdirectory is a git "subrepo", and this file is maintained by the
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
;
[subrepo]
remote = https://github.com/stanangeloff/php.vim.git
branch = master
commit = 930aec5c7026297a6630bd2940c08c5ff552cf2a
parent = 76b2929ec800ed21363a4059c44ce085dc969b49
method = merge
cmdver = 0.4.3

View file

@ -0,0 +1,143 @@
php.vim
=======
An up-to-date Vim syntax for PHP.
_This project is a fork of [php.vim--Garvin][php.vim-garvin] which in turn is an update of the [php.vim][php.vim-original] script which in turn is an updated version of the php.vim syntax file distributed with Vim. **Whew!**_
Installation
------------
If you don't have a preferred installation method, [vim-plug] is quick and simple. With [vim-plug installed], add the following to your `vimrc` (if you are a NeoVim user, see the [FAQ page][neovim-faq] for help):
```vim
Plug 'StanAngeloff/php.vim'
```
If you are using Git, please be aware [the original repository this project was forked from][php.vim-garvin] contains bad timezone in some of the commits. You'll need to fetch with `fsckObjects` disabled:
```sh
git clone -c fetch.fsckObjects=false git@github.com:StanAngeloff/php.vim.git
```
Unless you specify `-c fetch.fsckObjects=false` as an option to `git clone`, you may see `badTimezone: invalid author/committer line - bad time zone` in the output and the cloning will [fail](https://github.com/StanAngeloff/php.vim/issues/96).
Configuration
-------------
`php.vim` comes with sensible defaults for most use cases. Below is a list of some interesting configuration options you may tweak. Refer to the [source code][php.vim-source] for additional options.
- `g:php_version_id`,
`b:php_version_id`
Default: `g:php_version_id = 70300`
The PHP version the Vim syntax should adhere to. This currently determines how strict [Heredoc/Nowdoc syntax](https://www.php.net/manual/en/migration73.new-features.php#migration73.new-features.core.heredoc) should be. The format of the Vim variable follows the [PHP predefined constant `PHP_VERSION_ID`](https://www.php.net/manual/en/reserved.constants.php#constant.php-version-id).
- `g:php_syntax_extensions_enabled`, `g:php_syntax_extensions_disabled`
`b:php_syntax_extensions_enabled`, `b:php_syntax_extensions_disabled`
Default: `g:php_syntax_extensions_enabled = ["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"]`
A list of PHP extension names (lowercase) for which highlighting of built-in functions, constants, classes and interfaces is enabled / disabled.
If you are **not** interested in highlighting **any** built-in functions/constants/etc., set `g:php_syntax_extensions_enabled` to an empty list `[]`.
If you are **not** interested in highlighting built-in functions/constants/etc. for a subset of PHP extensions, set `g:php_syntax_extensions_enabled` to a list of extensions you wish to disable, e.g., `["mcrypt"]`.
- `php_var_selector_is_identifier`
Default: `0`
Set this to a truthy value (e.g., `1`) to include the dollar sign `$` as part of the highlighting group for a PHP variable.
- `php_html_load`, `php_html_in_heredoc`, `php_html_in_nowdoc`
Default: `1` (NOTE: setting `php_html_load` to a truthy value takes precedence and overrides both `php_html_in_heredoc` & `php_html_in_nowdoc`)
Set to a falsy value (e.g., `0`) to disable embedding HTML in PHP. Doing so may yield significant speed-ups of syntax highlighting.
This should not affect HTML highlighting in templating languages, such as [Blade].
- `php_sql_query`, `php_sql_heredoc`, `php_sql_nowdoc`
Default: `1`
Set to a falsy value (e.g., `0`) to disable SQL syntax in PHP. Doing so may yield moderate speed-ups of syntax highlighting.
### Projects of interest
`php.vim` pairs nicely with:
- [`phpfolding.vim`](https://github.com/rayburgemeestre/phpfolding.vim): _Automatic folding of PHP functions, classes, … (also folds related PhpDoc)_
- [`PHP-Indenting-for-VIm`](https://github.com/2072/PHP-Indenting-for-VIm): _The official VIm indent script for PHP_
### Overriding highlighting
Syntax highlighting can be controlled at a fine-grained level. For example, all text in PHP comments is highlighted as `phpComment` by default, however there are smaller syntax groups you can tweak, e.g., how PHPDoc `@tags` appear. There are [several syntax groups you can choose from](syntax-groups).
Example: Overriding PHP `@tags` and `$parameters` in comments to appear as a different highlighting group, giving them distinct colouring:
```vim
" Put this function at the very end of your vimrc file.
function! PhpSyntaxOverride()
" Put snippet overrides in this function.
hi! link phpDocTags phpDefine
hi! link phpDocParam phpType
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END
```
#### Snippets
You may add the code snippets below to your `PhpSyntaxOverride` function (see above for instructions on how to create this function).
##### Colourising namespace separator in `use`, `extends` and `implements`
If you wish to highlight the namespace separator `\` differently ([original request](https://github.com/StanAngeloff/php.vim/issues/63)):
```vim
hi phpUseNamespaceSeparator guifg=#808080 guibg=NONE gui=NONE
hi phpClassNamespaceSeparator guifg=#808080 guibg=NONE gui=NONE
```
##### Colourising parentheses
If you wish to highlight `(` and `)` differently ([original request](https://github.com/StanAngeloff/php.vim/issues/31#issuecomment-52879108)):
```vim
syn match phpParentOnly "[()]" contained containedin=phpParent
hi phpParentOnly guifg=#f08080 guibg=NONE gui=NONE
```
Developing
----------
When you install `php.vim` using your preferred installation method, all the needed files are already in place.
If you wish to rebuild the syntax file with a more recent version of PHP available on the [Docker Hub], you should use the provided `Dockerfile` to do so:
```bash
docker build --no-cache --force-rm -f attic/Dockerfile -t php.vim .
cat syntax/php.vim | docker run --rm -i php.vim > syntax/php.vim.new
docker rmi php.vim
mv syntax/php.vim.new syntax/php.vim
```
NOTE: If the updated syntax file fails to load and is corrupted, try loading `syntax/php.vim` in your favourite editor and ensure line endings are set to Unix `\n`.
[php.vim-garvin]: https://github.com/vim-scripts/php.vim--Garvin
[php.vim-original]: http://www.vim.org/scripts/script.php?script_id=2874
[vim-plug]: https://github.com/junegunn/vim-plug
[vim-plug installed]: https://github.com/junegunn/vim-plug#installation
[neovim-faq]: https://github.com/neovim/neovim/wiki/FAQ#where-should-i-put-my-config-vimrc
[php.vim-source]: https://github.com/StanAngeloff/php.vim/blob/master/syntax/php.vim#L35
[Blade]: https://github.com/jwalton512/vim-blade
[syntax-groups]: https://github.com/StanAngeloff/php.vim/blob/41c36f7f/syntax/php.vim#L804
[Docker Hub]: https://docs.docker.com/samples/library/php/

View file

@ -0,0 +1,6 @@
<?php
error_reporting(E_ALL | E_DEPRECATED | E_STRICT);
ini_set('display_errors', 'On');
date_default_timezone_set('UTC');

View file

@ -0,0 +1,52 @@
<?php
/**
* Script to update Vim's PHP syntax file.
*
* @author Stan Angeloff <stanimir@angeloff.name>
*
* @author Paul Garvin <paul@paulgarvin.net>
* @copyright Copyright 2009 Paul Garvin
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*
* Loosely based on Paul Garvin <paul@paulgarvin.net> original script.
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code.
*/
require __DIR__ . '/0-bootstrap.inc.php';
# Parse the configuration file associated with this script.
$configuration = parse_ini_file(__DIR__ . '/syntax.ini', /* $process_sections = */ true);
# Process extensions and serialize built-in functions, constants, classes and interfaces.
$extensions = array();
foreach ($configuration['extensions'] as $extensionName => $isEnabled) {
if (! $isEnabled) {
continue;
}
try {
$reflect = new \ReflectionExtension($extensionName);
$collected = array(
'name' => $reflect->getName(),
'versions' => array(sprintf('%d.%d.%d', PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION)),
'classes' => array(),
'functions' => array_keys($reflect->getFunctions()),
'constants' => array_diff(array_keys($reflect->getConstants()), array('TRUE', 'FALSE', 'NULL')),
);
foreach ($reflect->getClasses() as $extensionClass) {
$collected['classes'][] = $extensionClass->getName();
$collected['constants'] = array_unique(array_merge($collected['constants'], array_keys($extensionClass->getConstants())));
}
$extensions[$extensionName] = $collected;
} catch (ReflectionException $e) {
file_put_contents('php://stderr', sprintf('[ERROR] [PHP %d.%d] %\'.12s: %s.' . PHP_EOL, PHP_MAJOR_VERSION, PHP_MINOR_VERSION, $extensionName, rtrim($e->getMessage(), ' ?!.')));
}
}
echo serialize($extensions) . PHP_EOL;

View file

@ -0,0 +1,103 @@
<?php
require __DIR__ . '/0-bootstrap.inc.php';
$extensions = [];
$versions = [];
while (false !== $line = fgets(STDIN)) {
$unserialized = unserialize($line, ['allowed_classes' => false]);
foreach ($unserialized as $extension => &$collected) {
if (! isset($extensions[$extension])) {
$extensions[$extension] = $collected;
continue;
}
$extensions[$extension] = array(
'name' => $extensions[$extension]['name'],
'versions' => array_merge($extensions[$extension]['versions'], $collected['versions']),
'classes' => array_merge($extensions[$extension]['classes'], $collected['classes']),
'functions' => array_merge($extensions[$extension]['functions'], $collected['functions']),
'constants' => array_merge($extensions[$extension]['constants'], $collected['constants']),
);
}
}
foreach ($extensions as &$collected) {
$collected['classes'] = array_unique($collected['classes']);
$collected['functions'] = array_unique($collected['functions']);
$collected['constants'] = array_unique($collected['constants']);
sort($collected['classes'], SORT_NATURAL);
sort($collected['functions'], SORT_NATURAL);
sort($collected['constants'], SORT_NATURAL);
$versions = array_merge($versions, $collected['versions']);
}
$versions = array_unique($versions);
sort($versions, SORT_NATURAL);
$blocks = array(
'extensions' => array(),
'last-modified' => sprintf(
'%s, PHP %s',
date('r' /* RFC 2822 */),
implode(/* $glue = */ ', ', $versions)
),
);
$blocks['extensions'][] = 'if ! exists("g:php_syntax_extensions_enabled")';
$blocks['extensions'][] = sprintf(' let g:php_syntax_extensions_enabled = ["%s"]', implode(/* $glue = */ '", "', array_map('strtolower', array_keys($extensions))));
$blocks['extensions'][] = 'endif';
$blocks['extensions'][] = 'if ! exists("g:php_syntax_extensions_disabled")';
$blocks['extensions'][] = ' let g:php_syntax_extensions_disabled = []';
$blocks['extensions'][] = 'endif';
$ifExtensionEnabled = function ($extensionName) {
return sprintf(
'if ' .
'index(g:php_syntax_extensions_enabled, "%1$s") >= 0 && ' .
'index(g:php_syntax_extensions_disabled, "%1$s") < 0 && ' .
'( ! exists("b:php_syntax_extensions_enabled") || index(b:php_syntax_extensions_enabled, "%1$s") >= 0) && ' .
'( ! exists("b:php_syntax_extensions_disabled") || index(b:php_syntax_extensions_disabled, "%1$s") < 0)',
strtolower($extensionName)
);
};
$blocks['extensions'][] = 'syn case match';
foreach ($extensions as $extension) {
if (! count($extension['constants'])) {
continue;
}
$blocks['extensions'][] = $ifExtensionEnabled($extension['name']);
$blocks['extensions'][] = sprintf('" %s constants', $extension['name']);
$blocks['extensions'][] = sprintf('syn keyword phpConstants %s contained', implode(/* $glue = */ ' ', $extension['constants']));
$blocks['extensions'][] = 'endif';
}
$blocks['extensions'][] = 'syn case ignore';
foreach ($extensions as $extension) {
if (! count($extension['functions']) && ! count($extension['classes'])) {
continue;
}
$blocks['extensions'][] = $ifExtensionEnabled($extension['name']);
if (count($extension['functions'])) {
$blocks['extensions'][] = sprintf('" %s functions', $extension['name']);
$blocks['extensions'][] = sprintf('syn keyword phpFunctions %s contained', implode(/* $glue = */ ' ', $extension['functions']));
}
if (count($extension['classes'])) {
$blocks['extensions'][] = sprintf('" %s classes and interfaces', $extension['name']);
$blocks['extensions'][] = sprintf('syn keyword phpClasses %s contained', implode(/* $glue = */ ' ', $extension['classes']));
}
$blocks['extensions'][] = 'endif';
}
echo serialize($blocks);

View file

@ -0,0 +1,71 @@
<?php
require __DIR__ . '/0-bootstrap.inc.php';
$blocks = unserialize(file_get_contents('php://stdin'), ['allowed_classes' => false]);
# Read the existing syntax file with block markers in it.
#
$template = file_get_contents($argv[1]);
# Clean up any previously defined blocks.
$template = preg_replace(
sprintf(
'/(@block\([\'"](%s)[\'"]\)["\r\n\t ]*).*?(["\r\n\t ]*@endblock)\b/ism',
implode(/* $glue = */ '|', array_keys($blocks))
),
"\\1___\\2___\\3",
$template
);
# Update block contents in the template.
foreach ($blocks as $blockName => $lines) {
$template = str_ireplace(
sprintf('___%s___', $blockName),
rtrim(is_array($lines) ? implode(/* $glue = */ "\n", $lines) : $lines),
$template
);
}
$template = preg_replace_callback(
'/
(?<begin>"\s*@copy\s+(?<copy>[a-zA-Z0-9_]+)(?<processors>(\s+(strip_maximum_size))+)?)
(?<script>.*?)
(?<end>"\s*@end\s+([a-zA-Z0-9_]+))
/sx',
function (array $groups) use ($template) {
$copy = preg_quote($groups['copy'], /* $delimiter = */ '/');
$processors = array_filter(array_map('trim', preg_split('{[;, ]+}', $groups['processors'])));
preg_match("/
\"\\s*@begin\\s+{$copy}\b
(?<script>.*?)
\"\\s*@end\\s+{$copy}\b
/sx", $template, $captures);
if (! isset($captures['script'])) {
file_put_contents('php://stderr', "[ERROR] The block referenced by '{$groups['begin']}' was not found." . PHP_EOL);
return $groups['begin'] . $groups['script'] . $groups['end'];
}
$script = $captures['script'];
foreach ($processors as $processor) {
switch ($processor) {
case 'strip_maximum_size':
$script = preg_replace('{\\\\@\d+}', '\@', $script);
break;
default:
file_put_contents('php://stderr', "[ERROR] The processor \"{$processor}\" is not supported, found in '{$groups['begin']}'." . PHP_EOL);
}
}
return $groups['begin'] . $script . $groups['end'];
},
$template
);
echo $template;

View file

@ -0,0 +1,154 @@
FROM ubuntu:18.04
MAINTAINER Stan Angeloff "stanimir@psp-webtech.co.uk"
ENV UBUNTU_RELEASE=bionic \
ONDREJ_PHP_KEY="14AA40EC0831756756D7F66C4F4EA0AAE5267A6C"
RUN apt-get update && apt-get install -y gnupg2 && \
/bin/echo -e "\n\ndeb http://ppa.launchpad.net/ondrej/php/ubuntu $UBUNTU_RELEASE main\ndeb-src http://ppa.launchpad.net/ondrej/php/ubuntu $UBUNTU_RELEASE main" >> /etc/apt/sources.list && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys "$ONDREJ_PHP_KEY" && \
apt-get update
RUN apt-get install -y \
\
php5.6-cli \
php5.6-bcmath \
php5.6-bz2 \
php5.6-curl \
php5.6-dom \
php5.6-gd \
php5.6-gettext \
php5.6-iconv \
php5.6-json \
php5.6-mbstring \
php5.6-mcrypt \
php5.6-mysql \
php5.6-mysqli \
php5.6-pdo \
php5.6-pgsql \
php5.6-phar \
php5.6-simplexml \
php5.6-soap \
php5.6-sockets \
php5.6-sqlite3 \
php5.6-tokenizer \
php5.6-wddx \
php5.6-xml \
php5.6-xmlreader \
php5.6-xmlwriter \
php5.6-zip \
\
php7.0-cli \
php7.0-bcmath \
php7.0-bz2 \
php7.0-curl \
php7.0-dom \
php7.0-gd \
php7.0-gettext \
php7.0-iconv \
php7.0-json \
php7.0-mbstring \
php7.0-mcrypt \
php7.0-mysql \
php7.0-mysqli \
php7.0-pdo \
php7.0-pgsql \
php7.0-phar \
php7.0-simplexml \
php7.0-soap \
php7.0-sockets \
php7.0-sqlite3 \
php7.0-tokenizer \
php7.0-wddx \
php7.0-xml \
php7.0-xmlreader \
php7.0-xmlwriter \
php7.0-zip \
\
php7.1-cli \
php7.1-bcmath \
php7.1-bz2 \
php7.1-curl \
php7.1-dom \
php7.1-gd \
php7.1-gettext \
php7.1-iconv \
php7.1-json \
php7.1-mbstring \
php7.1-mcrypt \
php7.1-mysql \
php7.1-mysqli \
php7.1-pdo \
php7.1-pgsql \
php7.1-phar \
php7.1-simplexml \
php7.1-soap \
php7.1-sockets \
php7.1-sqlite3 \
php7.1-tokenizer \
php7.1-wddx \
php7.1-xml \
php7.1-xmlreader \
php7.1-xmlwriter \
php7.1-zip \
\
php7.2-cli \
php7.2-bcmath \
php7.2-bz2 \
php7.2-curl \
php7.2-dom \
php7.2-gd \
php7.2-gettext \
php7.2-iconv \
php7.2-json \
php7.2-mbstring \
php7.2-mysql \
php7.2-mysqli \
php7.2-pdo \
php7.2-pgsql \
php7.2-phar \
php7.2-simplexml \
php7.2-soap \
php7.2-sockets \
php7.2-sqlite3 \
php7.2-tokenizer \
php7.2-wddx \
php7.2-xml \
php7.2-xmlreader \
php7.2-xmlwriter \
php7.2-zip \
\
php7.3-cli \
php7.3-bcmath \
php7.3-bz2 \
php7.3-curl \
php7.3-dom \
php7.3-gd \
php7.3-gettext \
php7.3-iconv \
php7.3-json \
php7.3-mbstring \
php7.3-mysql \
php7.3-mysqli \
php7.3-pdo \
php7.3-pgsql \
php7.3-phar \
php7.3-simplexml \
php7.3-soap \
php7.3-sockets \
php7.3-sqlite3 \
php7.3-tokenizer \
php7.3-wddx \
php7.3-xml \
php7.3-xmlreader \
php7.3-xmlwriter \
php7.3-zip \
\
;
ADD attic/ /var/php
WORKDIR /var/php
CMD ["/bin/sh", "/var/php/update.sh"]

View file

@ -0,0 +1,83 @@
; A list of extensions for which to generate built-in functions, constants, classes and interfaces.
;
; You MUST have the extensions compiled with PHP or loaded as shared libraries.
;
; NOTE: 'mysqlnd' is not included because it exposes no functions, classes, or constants.
;
; NOTE: Any 'pdo_*' driver extensions are not included in the list as they DO NOT expose any functions, constants, etc. themselves.
; The driver-specific functions and constants are exposed though the 'pdo' extension itself.
; The 'pdo_*' extensions MUST still be enabled (compiled in or loaded as shared) for these members to show up, though.
;
[extensions]
bcmath = yes
bz2 = yes
calendar = no
com_dotnet = no
core = yes
ctype = no
curl = yes
date = yes
dba = no
dom = yes
enchant = no
ereg = yes
exif = no
fileinfo = no
filter = no
ftp = no
gd = yes
gettext = yes
gmp = no
hash = yes
iconv = yes
imap = no
interbase = no
intl = no
json = yes
ldap = no
libxml = yes
mbstring = yes
mcrypt = yes
mhash = yes
mssql = no
mysql = yes
mysqli = yes
oci8 = no
oci8_11g = no
odbc = no
openssl = yes
pcntl = no
pcre = yes
pdo = yes
pgsql = yes
phar = yes
posix = no
pspell = no
readline = no
recode = no
reflection = yes
session = yes
shmop = no
simplexml = yes
snmp = no
soap = yes
sockets = yes
spl = yes
sqlite = no
sqlite3 = yes
standard = yes
sybase_ct = no
sysvmsg = no
sysvsem = no
sysvshm = no
tidy = no
tokenizer = yes
wddx = yes
xml = yes
xmlreader = yes
xmlrpc = no
xmlwriter = yes
xsl = no
zip = yes
zlib = yes

View file

@ -0,0 +1,13 @@
#!/bin/sh
cat - > php.vim
test -e update.out && rm update.out
for version in 5.6 7.0 7.1 7.2 7.3; do
php$version 10-collect.php 1>>update.out
done
cat update.out | \
php7.2 20-generate.php | \
php7.2 30-update.php php.vim

File diff suppressed because one or more lines are too long