-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Initial ReflectionReference implementation #3550
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
Conversation
/cc @nicolas-grekas |
Thanks, I'll definitely check this PR! |
@sarciszewski Any tips on how to return scrambled memory addresses, for the getId() function? I could run the address through sha1 together with a per-process secret key, but I'd prefer something more lightweight. A fast 64-bit cipher would probably be ideal here. |
Comment on behalf of petk at php.net: Labelling |
f3ea6ef
to
d96bef5
Compare
Should the class implements |
Not if we can avoid it :) Reflector is quite the abomination and should really be removed entirely... I'd prefer not to have implicit stringification on this class just to satisfy this interface. Thankfully there is precedent in not implementing
Yes it should! I've made serialize throw for all other reflection classes a while ago, but forgot it here... |
cbead86
to
d712326
Compare
Serialization is now properly forbidden. |
RFC accepted, merged as 6347f0b. |
> - Reflection: > A new ReflectionReference class has been added, which allows detecting > references and comparing them for identity. Refs: * https://wiki.php.net/rfc/reference_reflection * https://github.com/php/php-src/blob/42cc58ff7b2fee1c17a00dc77a4873552ffb577f/UPGRADING#L388-L391 * php/php-src#3550 * php/php-src@6347f0b
Implementation of
ReflectionReference
based on the discussion in https://externals.io/message/102638. Currently the class definition isThe return value of
getId()
uniquely identifies the reference for the duration of its lifetime. An ID may be reused if the reference is destroyed. The format of the return value is unspecified any may change. Only the fact that it will be an integer or string is guaranteed.In the current implementation
the address of the reference is directly returned as the ID. We should be hiding the address here, possibly by hashing it with a secret key.the ID is a raw SHA1 hash of the reference address and a per-process key. Raw meaning 20 character binary data, no hex encoding.