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

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
This commit is contained in:
Joshua Spence 2014-05-22 09:14:14 -07:00 committed by epriestley
parent bca14a368b
commit f13aa21b8e
3 changed files with 3248 additions and 328 deletions

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,6 @@ if (!$ok) {
exit(1);
}
$required = '5.2.3';
$reference = id(new PHP_CompatInfo_Reference_ALL())->getAll();
$output = array();
@ -26,19 +25,15 @@ foreach (array('functions', 'classes', 'interfaces') as $type) {
$name = strtolower($name);
$versions = reset($versions);
list($min, $max) = $versions;
if (version_compare($min, $required) > 0) {
$output[$type][$name] = $min;
}
if ($type == 'functions' && isset($versions[4])) {
$params = explode(', ', $versions[4]);
foreach ($params as $i => $version) {
if (version_compare($version, $required) > 0) {
$output['params'][$name][$i] = $version;
}
}
}
}
}
// Grepped from PHP Manual.
$output['functions_windows'] = array(

View file

@ -448,6 +448,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
$target = phutil_get_library_root('arcanist').
'/../resources/php_compat_info.json';
$compat_info = json_decode(file_get_contents($target), true);
$required = '5.2.3';
$calls = $root->selectDescendantsOfType('n_FUNCTION_CALL');
foreach ($calls as $call) {
@ -455,7 +456,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
$name = strtolower($node->getConcreteString());
$version = idx($compat_info['functions'], $name);
$windows = idx($compat_info['functions_windows'], $name);
if ($version) {
if ($version && version_compare($version, $required, '>')) {
$this->raiseLintAtNode(
$node,
self::LINT_PHP_53_FEATURES,
@ -465,7 +466,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
$params = $call->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
foreach (array_values($params->getChildren()) as $i => $param) {
$version = idx($compat_info['params'][$name], $i);
if ($version) {
if ($version && version_compare($version, $required, '>')) {
$this->raiseLintAtNode(
$param,
self::LINT_PHP_53_FEATURES,
@ -488,7 +489,7 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
$name = strtolower($node->getConcreteString());
$version = idx($compat_info['interfaces'], $name);
$version = idx($compat_info['classes'], $name, $version);
if ($version) {
if ($version && version_compare($version, $required, '>')) {
$this->raiseLintAtNode(
$node,
self::LINT_PHP_53_FEATURES,