Skip to content

Add get_mangled_object_vars() function #4163

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

Closed
wants to merge 1 commit into from

Conversation

nikic
Copy link
Member

@nikic nikic commented May 14, 2019

This function provides the same functionality as (array) $object, with the caveat that it is not affected by any overloaded (array) casts. In particular it will always provide the real object properties for ArrayObject and derived classes, even if the STD_PROP_LIST flag is not set.

@nikic nikic changed the base branch from master to PHP-7.4 May 14, 2019 12:38
@KalleZ
Copy link
Member

KalleZ commented May 14, 2019

I would prefer if this was named something like get_mangled_object_vars for consistency with get_class_vars and get_object_vars, not pretty sure, but consistent.

@nikic
Copy link
Member Author

nikic commented May 14, 2019

@KalleZ Agreed and done!

@nikic nikic changed the title Add get_mandled_object_properties() function Add get_mandled_object_vars() function May 14, 2019
@nikic nikic changed the title Add get_mandled_object_vars() function Add get_mangled_object_vars() function May 14, 2019
@guilliamxavier
Copy link
Contributor

Thanks for your work, just: typo "mandled" in test filename (and commit messages also)

@petk petk added the Feature label May 16, 2019
Copy link
Contributor

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a test change required: could you please use var_export(), so that \0 in keys are visible?

@nikic nikic force-pushed the get-mangled-props branch from 9b8c662 to d1a6a2b Compare June 6, 2019 09:09
@nikic
Copy link
Member Author

nikic commented Jun 6, 2019

@Ocramius Done!

@Majkl578
Copy link
Contributor

Majkl578 commented Jun 6, 2019

Wouldn't this be better as part of ReflectionProperty instead? There is also no way to easily get a map of unmangled -> mangled or vice versa.

@nikic
Copy link
Member Author

nikic commented Jun 6, 2019

@Majkl578 This would have to be on ReflectionObject if anything. However there are some performance concerns. If we want people to replace existing (array) casts with this function, it needs to have comparable performance. The cases where this functionality is needed tend to use it a lot.

@Majkl578
Copy link
Contributor

Majkl578 commented Jun 6, 2019

@nikic Likely both, what I meant was ReflectionProeprty::getMangledName().

@nikic
Copy link
Member Author

nikic commented Jun 6, 2019

@Majkl578 We could add getMangledName(). Any particular use you have in mind for it?

@KalleZ
Copy link
Member

KalleZ commented Jun 6, 2019

@staabm The correct phrasing of the word is mangled, see:
https://www.dictionary.com/browse/mangled

@nikic
Copy link
Member Author

nikic commented Jun 6, 2019

@staabm Apart from the suggestion being grammatically incorrect, was it really necessary to send the same suggested edit 9 times, each as a separate comment (not as part of a review), each sending out a new email? Please don't do that.

@staabm
Copy link
Contributor

staabm commented Jun 6, 2019

The correct phrasing of the word is mangled, see:

I just realized this. thx for the hint.

Apart from the suggestion being grammatically incorrect, was it really necessary to send the same suggested edit 9 times, each as a separate comment (not as part of a review), each sending out a new email? Please don't do that

very sorry about that. will be more carefully next time.
since the comments were wrong overall I deleted them again.

sorry for the noise.

@nikic
Copy link
Member Author

nikic commented Jun 6, 2019

@Majkl578 Thanks! Sounds like a good addition then. Would you like to submit a PR? Otherwise I can do it.

@Majkl578
Copy link
Contributor

Majkl578 commented Jun 6, 2019

Sure, could try that. :)

@nikic
Copy link
Member Author

nikic commented Jun 11, 2019

Merged as eecd896 into 7.4.

@nikic nikic closed this Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants