instanceof should be used instead of is_a. I need to do a bit more research here to see if there are any edge cases.
Details
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Commits
- rARC3dbc1418ff07: (stable) Promote 2015 Week 52
rARCb3e68c9f1793: Add a linter rule for use of `is_a`
Added unit tests.
Diff Detail
Diff Detail
- Repository
- rARC Arcanist
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
I think this is an edge case:
$subclass = 'Subclass'; is_a($subclass, 'Base', $allow_string = true); // true $subclass instanceof Base; // false, string is not an instance of anything
I'm also not sure offhand what the distinction between is_a() and is_subclass_of() is.
src/lint/linter/xhpast/rules/ArcanistIsAShouldBeInstanceOfXHPASTLinterRule.php | ||
---|---|---|
30–32 | We could probably make evalStatic() smarter about this and have the code do something like: if (!$allow_string->isSomethingWeCanCallEvalStaticOn()) { continue; } if ($allow_string->evalStatic()) { continue; } ...to catch 0, etc., some day far in the future. | |
57 | Missing text at end of sentence ("which has... what?") | |
60 | Prefer ($replacement === null) for consistency. |