]> khamidou — GitHub mirrors - arcanist.git/commit
Add a linter rule for invalid octals
authorJoshua Spence <josh@freelancer.com>
Wed, 2 Dec 2015 21:11:22 +0000 (08:11 +1100)
committerJoshua Spence <josh@freelancer.com>
Wed, 2 Dec 2015 21:27:51 +0000 (08:27 +1100)
commit560e4ae4919b9a7eb10b9625cb66b99ac50cee12
tree31c0523c9c15bd08d09b5233ae91696ea684dd2d
parent8ed3c45c822654a6e9617feddbdd2ee4ef48f3dd
Add a linter rule for invalid octals

Summary: PHP doesn't handle octals very well. Basically, it seems that any numeric scalar matching `/^0\d+$/` will be treated as an octal, whereas this should be `/^0[0-7]+$/`. As a result, `08` and `09` are both treated as `0` (because they are invalid octals. This diff adds a linter rule to detect this abnormality.

Test Plan: Added unit tests.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D14604
src/__phutil_library_map__.php
src/lint/linter/xhpast/rules/ArcanistInvalidOctalNumericScalarXHPASTLinterRule.php [new file with mode: 0644]
src/lint/linter/xhpast/rules/__tests__/ArcanistInvalidOctalNumericScalarXHPASTLinterRuleTestCase.php [new file with mode: 0644]
src/lint/linter/xhpast/rules/__tests__/invalid-octal-numeric-scalar/binary.lint-test [new file with mode: 0644]
src/lint/linter/xhpast/rules/__tests__/invalid-octal-numeric-scalar/decimal.lint-test [new file with mode: 0644]
src/lint/linter/xhpast/rules/__tests__/invalid-octal-numeric-scalar/hexadecimal.lint-test [new file with mode: 0644]
src/lint/linter/xhpast/rules/__tests__/invalid-octal-numeric-scalar/octal.lint-test [new file with mode: 0644]