Consider magic scalars such as __DIR__ to be constant strings. I am using this to determine if a path that is imported with require_once is autoloadable, see D12271 for some additional context.
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Commits
- rPHU7fc053c2cbb1: Consider magic scalars to be constant strings
Tested externally with a custom linter.
Diff Detail
- Repository
- rPHU libphutil
- Branch
- master
- Lint
Lint Passed - Unit
Tests Passed - Build Status
Buildable 5170 Build 5188: [Placeholder Plan] Wait for 30 Seconds
Event Timeline
Ah yeah, I thought this seemed familiar. What would need to happen for this to move forward?
I'm fine with introducing a similar method that allows n_MAGIC_SCALAR, but I think the current definition of a "constant string" is reasonable, and it's certainly the definition desired by the callsites.
If user-defined constants are also included, maybe the new method is isRuntimeConstantString(). If MAGIC is in but constants are out, maybe it's isConstantStringWithMagic() or something.
You could probably make this method private, add $include_magic and $include_constants flags or whatever, and then implement all the new methods in terms of calling it with appropriate flags? I think the number of reasonable modes is low enough not to expose the actual flags as part of the public API, maybe.
Consider two public APIs which take zero parameters plus one private API which requires parameters.
src/parser/xhpast/api/XHPASTNode.php | ||
---|---|---|
119 | This should pass $additional_types? |