-
Notifications
You must be signed in to change notification settings - Fork 61
Replace file path when it is encountered in string constants #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace file path when it is encountered in string constants #410
Conversation
return $value; | ||
} | ||
|
||
return str_replace(dirname(realpath($filePath)), self::MAGIC_DIR_OR_FILE_VALUE, $value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% convinced this is "the best way":tm: but it was just an idea I put together. Thoughts welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, looks iffy
da0a2c3
to
0c9330e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking further about it, I think the correct way would be to change the path detected for source locators, which would fix a whole category of issues related to this.
I don't know yet how to approach this, but shadowing the /tmp
location completely seems like a better approach.
One approach I thought of (not sure if viable), would be to replace
We could produce a |
I've potentially identified a way of making this work in a relatively hacky, but clean way. The way we find symbols via source locators is via While We could decorate the That would make |
@Ocramius that sounds like a plausible approach; will try and look into this when I can |
…the base path of `LocatedSource` instances This fails due to `CompileNodeToValue()` internally using `realpath()` and `dirname()` operations, which both depend on the current filesystem: as it currently stands, this requires an improvement of `roave/better-reflection` first. Also, `ReplaceSourcePathOfLocatedSources` and `LocatedSourceWithStrippedSourcesDirectory` are extending `@internal` symbols, so we may want to first make these symbols public in `roave/better-reflection`, to avoid the BC boundary to become too relaxed, and therefore causing crashes if we (rightfully) decide to change `roave/better-reflection` internals. Fixes #400 Fixes #410
I sent up a patch with my proposed approach @ #476 It will need patching |
…the base path of `LocatedSource` instances This fails due to `CompileNodeToValue()` internally using `realpath()` and `dirname()` operations, which both depend on the current filesystem: as it currently stands, this requires an improvement of `roave/better-reflection` first. Also, `ReplaceSourcePathOfLocatedSources` and `LocatedSourceWithStrippedSourcesDirectory` are extending `@internal` symbols, so we may want to first make these symbols public in `roave/better-reflection`, to avoid the BC boundary to become too relaxed, and therefore causing crashes if we (rightfully) decide to change `roave/better-reflection` internals. Fixes #400 Fixes #410
Closing this one: approach in #476 works fine, and is a bit better than operating on the constant expressions, as those can really occur almost anywhere in the system, so relying on the abstractions by |
…hs-to-prevent-__DIR__-and-__FILE__-bc-break-false-positives Normalize `__DIR__` and `__FILE__` by changing the base path of `LocatedSource` instances, prevent false-positive BC breaks on those magic constants
Fixes #400