Magic scalars (__DIR__, __FILE__, etc) return false for isConstantString whereas they should probably return true.
Details
Details
Diff Detail
Diff Detail
- Repository
- rPHU libphutil
- Branch
- magicscalar
- Lint
Lint Passed - Unit
Tests Passed - Build Status
Buildable 2443 Build 2447: [Placeholder Plan] Wait for 30 Seconds
Event Timeline
Comment Actions
Hmm, what's the context/use case?
I think we mostly use this for pht(...) and qsprintf(...) right now, and pht(__FILE__) is not correct, just like define('SOMECONST', 'str'); ... pht(SOMECONST); would not be correct.
Comment Actions
That is, we actually use this method as isConstantStringWhichCanBeEvaluatedStaticallyRightNow(), which is not true of __DIR__, __FILE__, __CLASS__, or real constants.
Comment Actions
I am writing a custom linter and want to enforce that require_once paths are constants. We have a lot of legacy code which does require_once "$BASE_DIR/foo/bar.php" where $BASE_DIR is a global variable.