1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-21 14:22:40 +01:00

Update update_compat_info.php to use PHP_CompatInfo version 3

Summary:
Fixes T5377. The current `scripts/update_compat_info.php` script works for PHP CompatInfo version 2, but doesn't work with the newer version 3.

There are a few breaking changes in version 3 that had to be addressed:

- PHP 5.3 is required. Whilst Arcanist is generally compatible with PHP 5.2, I don't think that having this dependency presents any real issues because it is purely a development tool that is rarely updated.
- [[https://getcomposer.org/ | Composer]] is used for packaging, which makes including the library slightly more complicated. Basically, I had to install `PHP_CompatInfo` globally with Composer (`composer global require "bartlett/php-compatinfo"` and then symlink `~/.composer/vendor` into `externals/includes`.

Test Plan: Compared the `resources/php_compat_info.json` file. There are a bunch of functions/classes that //were// in this file but are no longer, but I think that I've covered the most popular extensions.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5377

Differential Revision: https://secure.phabricator.com/D9568
This commit is contained in:
Joshua Spence 2014-06-17 00:30:16 +10:00
parent 497229acd8
commit 8f8ab969db
3 changed files with 5702 additions and 12437 deletions

File diff suppressed because it is too large Load diff

View file

@ -6,39 +6,78 @@ require_once dirname(__FILE__).'/__init_script__.php';
$target = 'resources/php_compat_info.json';
echo "Purpose: Updates {$target} used by ArcanistXHPASTLinter.\n";
$ok = include 'PHP/CompatInfo/Autoload.php';
if (!$ok) {
echo "You need PHP_CompatInfo available in 'include_path'.\n";
echo "http://php5.laurent-laville.org/compatinfo/\n";
exit(1);
}
$reference = id(new PHP_CompatInfo_Reference_ALL())->getAll();
require_once 'vendor/autoload.php';
$output = array();
$output['@'.'generated'] = true;
$output['params'] = array();
$output['functions'] = array();
$output['classes'] = array();
$output['interfaces'] = array();
foreach (array('functions', 'classes', 'interfaces') as $type) {
$output[$type] = array();
foreach ($reference[$type] as $name => $versions) {
$name = strtolower($name);
$versions = reset($versions);
list($min, $max) = $versions;
$output[$type][$name] = array(
'min' => nonempty($min, null),
'max' => nonempty($max, null),
$references = array(
new \Bartlett\CompatInfo\Reference\Extension\ApcExtension(),
new \Bartlett\CompatInfo\Reference\Extension\CoreExtension(),
new \Bartlett\CompatInfo\Reference\Extension\CurlExtension(),
new \Bartlett\CompatInfo\Reference\Extension\DateExtension(),
new \Bartlett\CompatInfo\Reference\Extension\FileinfoExtension(),
new \Bartlett\CompatInfo\Reference\Extension\GdExtension(),
new \Bartlett\CompatInfo\Reference\Extension\GettextExtension(),
new \Bartlett\CompatInfo\Reference\Extension\HttpExtension(),
new \Bartlett\CompatInfo\Reference\Extension\ImagickExtension(),
new \Bartlett\CompatInfo\Reference\Extension\IntlExtension(),
new \Bartlett\CompatInfo\Reference\Extension\JsonExtension(),
new \Bartlett\CompatInfo\Reference\Extension\LibxmlExtension(),
new \Bartlett\CompatInfo\Reference\Extension\MysqlExtension(),
new \Bartlett\CompatInfo\Reference\Extension\MysqliExtension(),
new \Bartlett\CompatInfo\Reference\Extension\PcntlExtension(),
new \Bartlett\CompatInfo\Reference\Extension\PcreExtension(),
new \Bartlett\CompatInfo\Reference\Extension\PdoExtension(),
new \Bartlett\CompatInfo\Reference\Extension\PharExtension(),
new \Bartlett\CompatInfo\Reference\Extension\PosixExtension(),
new \Bartlett\CompatInfo\Reference\Extension\ReflectionExtension(),
new \Bartlett\CompatInfo\Reference\Extension\SimplexmlExtension(),
new \Bartlett\CompatInfo\Reference\Extension\StandardExtension(),
new \Bartlett\CompatInfo\Reference\Extension\SplExtension(),
new \Bartlett\CompatInfo\Reference\Extension\XmlExtension(),
new \Bartlett\CompatInfo\Reference\Extension\XmlreaderExtension(),
new \Bartlett\CompatInfo\Reference\Extension\XmlwriterExtension(),
new \Bartlett\CompatInfo\Reference\Extension\YamlExtension(),
);
foreach ($references as $reference) {
foreach ($reference->getFunctions() as $function => $compat) {
$output['functions'][$function] = array(
'min' => nonempty($compat['php.min'], null),
'max' => nonempty($compat['php.max'], null),
);
if ($type == 'functions' && isset($versions[4])) {
$params = explode(', ', $versions[4]);
foreach ($params as $i => $version) {
$output['params'][$name][$i] = $version;
}
if (idx($compat, 'parameters')) {
$output['params'][$function] = array_map(
'trim', explode(',', $compat['parameters']));
}
}
foreach ($reference->getInterfaces() as $interface => $compat) {
$output['interfaces'][$interface] = array(
'min' => nonempty($compat['php.min'], null),
'max' => nonempty($compat['php.max'], null),
);
}
foreach ($reference->getClasses() as $class => $compat) {
$output['classes'][$class] = array(
'min' => nonempty($compat['php.min'], null),
'max' => nonempty($compat['php.max'], null),
);
}
}
ksort($output['params']);
ksort($output['functions']);
ksort($output['classes']);
ksort($output['interfaces']);
// Grepped from PHP Manual.
$output['functions_windows'] = array(
'apache_child_terminate' => '',

View file

@ -454,7 +454,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
$calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');
foreach ($calls as $call) {
$node = $call->getChildByIndex(0);
$name = strtolower($node->getConcreteString());
$name = $node->getConcreteString();
$version = idx($compat_info['functions'], $name);
$windows = idx($compat_info['functions_windows'], $name);
if ($version && version_compare($version['min'], $required, '>')) {
@ -488,8 +488,8 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
$classes = $root->selectDescendantsOfType('n_CLASS_NAME');
foreach ($classes as $node) {
$name = $node->getConcreteString();
$version = idx($compat_info['interfaces'], strtolower($name));
$version = idx($compat_info['classes'], strtolower($name), $version);
$version = idx($compat_info['interfaces'], $name);
$version = idx($compat_info['classes'], $name, $version);
if ($version && version_compare($version['min'], $required, '>')) {
$this->raiseLintAtNode(
$node,