-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
Php extension should check properties visibility #8002
Php extension should check properties visibility #8002
Conversation
Thanks for this change. Is there any way to 100% prohibit any direct read/write of properties from outside of the class itself? If so I'd prefer to do that. We want the properties of the object to be totally encapsulated. |
@haberman To my understanding the patch does exactly this. The visibility level and a class from where access is performed are checked inside zend_get_property_info(): Are you talking about some specific case I have overlooked? |
Yes, your change seems to have the desired behavior. I was wondering if we could deny access without having to look up the property info. Since we want to protect all properties, it seems unfortunate to do a lookup for it. Perhaps we could use |
It seems to me that in php a parent class should always check if visibility was re-declared in the child class. I realise this may be a way too pedantic approach for protobuf case since php code generator should generate "protected" visibility for all properties. I just explained how I came to idea of my patch. Yeah, I can re-implement zend_get_property_info() to adapt it to protobuf case, if you think this is a right approach. |
I am hoping this could be as simple as:
I guess we could return |
I'm going to close this request given no response to the last review comment, but feel free to reopen if you'd like! |
I think php extension should respect php visibility rules for message properties.
Please note this patch is made on top of #7993
test.proto:
test.php:
Output:
Expected output: