Page MenuHomePhabricator

Add a linter rule for invalid octals
ClosedPublic

Authored by joshuaspence on Nov 30 2015, 11:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 27, 10:02 PM
Unknown Object (File)
May 7 2025, 7:21 AM
Unknown Object (File)
Apr 27 2025, 4:06 AM
Unknown Object (File)
Apr 21 2025, 11:47 PM
Unknown Object (File)
Apr 21 2025, 11:47 PM
Unknown Object (File)
Apr 21 2025, 11:47 PM
Unknown Object (File)
Apr 21 2025, 11:47 PM
Unknown Object (File)
Apr 21 2025, 11:47 PM
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.