Page MenuHomePhabricator

Add a linter rule for invalid octals
ClosedPublic

Authored by joshuaspence on Nov 30 2015, 11:35 AM.
Tags
None
Referenced Files
F14026732: D14604.id35423.diff
Fri, Nov 8, 2:01 AM
F14026730: D14604.id35422.diff
Fri, Nov 8, 2:00 AM
F14026728: D14604.id35346.diff
Fri, Nov 8, 2:00 AM
F14026727: D14604.id35324.diff
Fri, Nov 8, 2:00 AM
F14026725: D14604.id.diff
Fri, Nov 8, 2:00 AM
F14026724: D14604.diff
Fri, Nov 8, 2:00 AM
F14022072: D14604.diff
Wed, Nov 6, 3:09 PM
F14018098: D14604.id.diff
Tue, Nov 5, 4:38 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
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.