1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-09-19 16:38:51 +02:00

Add binary integers to ArcanistPHPCompatibilityXHPASTLinterRule

Summary: Binary integers (such as `0b1`) were added to PHP 5.4 and cannot be used in earlier versions.

Test Plan: Added a test case.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14643
This commit is contained in:
Joshua Spence 2015-12-03 08:30:29 +11:00
parent 560e4ae491
commit ae3c2cb0e1
2 changed files with 13 additions and 0 deletions

View file

@ -414,6 +414,16 @@ final class ArcanistPHPCompatibilityXHPASTLinterRule
'$this'));
}
}
$numeric_scalars = $root->selectDescendantsOfType('n_NUMERIC_SCALAR');
foreach ($numeric_scalars as $numeric_scalar) {
if (preg_match('/^0b[01]+$/i', $numeric_scalar->getConcreteString())) {
$this->raiseLintAtNode(
$numeric_scalar,
pht(
'Binary integer literals are not available before PHP 5.4.'));
}
}
}
private function lintPHP54Incompatibilities(XHPASTNode $root) {

View file

@ -20,11 +20,14 @@ final class SomeClass extends Phobject {
}
}
0b1;
~~~~~~~~~~
error:3:5
error:4:9
error:12:7
error:18:7
error:23:1
~~~~~~~~~~
~~~~~~~~~~
{