1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00
phorge-arcanist/scripts/update_compat_info.php
Joshua Spence f13aa21b8e Capture a wider range of version information in php_compat_info.json.
Summary: Ref T5141. Currently, `php_compat_info.json` is hardcoded to support PHP 5.2.3. Instead, store as much version information as possible in `php_compat_info.json` and filter accordingly in `ArcanistXHPASTLinter.`

Test Plan: Ran `arc lint` and made sure no additional warnings were raised.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5141

Differential Revision: https://secure.phabricator.com/D9247
2014-05-22 09:14:14 -07:00

71 lines
1.8 KiB
PHP
Executable file

#!/usr/bin/env php
<?php
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();
$output = array();
$output['@'.'generated'] = true;
$output['params'] = 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] = $min;
if ($type == 'functions' && isset($versions[4])) {
$params = explode(', ', $versions[4]);
foreach ($params as $i => $version) {
$output['params'][$name][$i] = $version;
}
}
}
}
// Grepped from PHP Manual.
$output['functions_windows'] = array(
'apache_child_terminate' => '',
'chroot' => '',
'getrusage' => '',
'imagecreatefromxpm' => '',
'lchgrp' => '',
'lchown' => '',
'nl_langinfo' => '',
'strptime' => '',
'sys_getloadavg' => '',
'checkdnsrr' => '5.3.0',
'dns_get_record' => '5.3.0',
'fnmatch' => '5.3.0',
'getmxrr' => '5.3.0',
'getopt' => '5.3.0',
'imagecolorclosesthwb' => '5.3.0',
'inet_ntop' => '5.3.0',
'inet_pton' => '5.3.0',
'link' => '5.3.0',
'linkinfo' => '5.3.0',
'readlink' => '5.3.0',
'socket_create_pair' => '5.3.0',
'stream_socket_pair' => '5.3.0',
'symlink' => '5.3.0',
'time_nanosleep' => '5.3.0',
'time_sleep_until' => '5.3.0',
);
file_put_contents(
phutil_get_library_root('arcanist').'/../'.$target,
id(new PhutilJSON())->encodeFormatted($output));
echo "Done.\n";