Page MenuHomePhabricator

Add a linter rule for invalid octals
ClosedPublic

Authored by joshuaspence on Nov 30 2015, 11:35 AM.
Tags
None
Referenced Files
F14641763: D14604.diff
Sat, Jan 11, 4:41 AM
Unknown Object (File)
Thu, Jan 9, 7:46 AM
Unknown Object (File)
Sun, Jan 5, 9:13 PM
Unknown Object (File)
Thu, Jan 2, 11:42 PM
Unknown Object (File)
Thu, Dec 26, 12:01 AM
Unknown Object (File)
Fri, Dec 20, 5:08 PM
Unknown Object (File)
Sun, Dec 15, 10:48 AM
Unknown Object (File)
Sun, Dec 15, 1:59 AM
Subscribers

Details

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.

Diff Detail

Repository
rARC Arcanist
Branch
master
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 9233
Build 10936: Run Core Tests
Build 10935: arc lint + arc unit

Event Timeline

joshuaspence retitled this revision from to Add a linter rule for invalid numerals.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
epriestley added a reviewer: epriestley.
epriestley added inline comments.
src/lint/linter/xhpast/rules/__tests__/invalid-octal-numeric-scalar/octal.lint-test
4–5

Maybe include these test cases?

0
0.9
0xFf
0XFf
0b01
-08
This revision is now accepted and ready to land.Nov 30 2015, 7:35 PM
joshuaspence retitled this revision from Add a linter rule for invalid numerals to Add a linter rule for invalid octals.Dec 2 2015, 9:25 PM
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence marked an inline comment as done.
joshuaspence removed a subscriber: Korvin.
This revision was automatically updated to reflect the committed changes.