mirror of
https://we.phorge.it/source/arcanist.git
synced 2025-02-16 16:58:38 +01: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:
parent
560e4ae491
commit
ae3c2cb0e1
2 changed files with 13 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
~~~~~~~~~~
|
||||
~~~~~~~~~~
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue