-
Notifications
You must be signed in to change notification settings - Fork 736
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
Removed warning about missing namespace leading backslash in var_export()
docs
#1472
Conversation
…ort()` docs `var_export()` needs to prefix classes it references with `\`, because its code could be transplanted in any source location/namespace, so the assumption of it being used only in the context of the root namespace is not sufficient. For example, in a code snippet like following ( https://3v4l.org/4mONc ): ```php <?php class SomeObject {} var_export([new SomeObject]); ``` This should produce: ``` array ( 0 => \SomeObject::__set_state(array( )), ) ``` Userland should not concern itself with the contents of the `var_export()`-produced code snippets, and use them as-is instead. Ref: php/php-src#8232 Ref: php/php-src#8233 Ref: Ocramius/ProxyManager#754
Hmm, but see https://externals.io/message/67008#67010. ;) |
Aye, mistakes were made :| Indeed confusing scope on my end:
Sorry for my previous mistake on that: my idea of See also php/php-src#8233 (comment) |
Should probably also add a row in the Changelog, and update Examples, as was done in 68601c39b9543a3d848e01f90f1fbb5512f39929^...9ddc8b6? |
Thanks @guilliamxavier: will try emulating that patch here, once php/php-src#8233 is merged |
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.
This makes sense to me, especially with the change in php/php-src#8233. Users should not make any assumptions about the output, except that the return value is a valid PHP expression.
This feels like it needs a changelog entry for 8.2 to explain the change (and also added to the migration guide/UPGRADING file, as that somehow didn't get done, so the change got missed). Otherwise, I don't really mind dropping it, but I think it may be useful to have it somewhere that details the nuance and pitfall. |
I just landed 0f27fad, so this ticket can be closed. Thanks everybody! |
var_export()
needs to prefix classes it references with\
, because its code could be transplanted inany source location/namespace, so the assumption of it being used only in the context of the root
namespace is not sufficient.
For example, in a code snippet like following ( https://3v4l.org/4mONc ):
This should produce:
Userland should not concern itself with the contents of the
var_export()
-produced codesnippets, and use them as-is instead.
Ref: php/php-src#8232
Ref: php/php-src#8233
Ref: Ocramius/ProxyManager#754