]> khamidou — GitHub mirrors - arcanist.git/commit
Allow classes/functions from a later version if they are used conditionally
authorJoshua Spence <josh@joshuaspence.com>
Wed, 10 Sep 2014 14:19:38 +0000 (00:19 +1000)
committerJoshua Spence <josh@joshuaspence.com>
Wed, 10 Sep 2014 14:24:08 +0000 (00:24 +1000)
commit3f79ae258f342ce479604dbd5c663a922673a4ee
treef6e5d3eef47aadd1214b73b31801966c1e1a4b22
parentf0f6897fce9e59d04e62ff4e0651bac7a44e1647
Allow classes/functions from a later version if they are used conditionally

Summary:
Fixes T5299. Currently, linting `src/future/http/HTTPSFuture.php` from rPHU will raise the following error:

```
   Error  (XHP31) Use Of PHP 5.3 Features
    This codebase targets PHP 5.2.3, but `curlfile` was not introduced until
    PHP 5.5.0.

             532       // use this "@" stuff.
             533
             534       if (class_exists('CURLFile')) {
    >>>      535         $file_value = new CURLFile((string)$tmp, $info['mime'], $info['name']);
             536       } else {
             537         $file_value = '@'.(string)$tmp;
             538       }
```

However, since this class is being used conditionally, it //should// be fine and no linter errors should be being raised.

Test Plan: Added a test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5299

Differential Revision: https://secure.phabricator.com/D10132
src/lint/linter/ArcanistXHPASTLinter.php
src/lint/linter/__tests__/xhpast/conditional-usage.lint-test [new file with mode: 0644]