From 7377d81ca44baf2e505c927a2e25b2f0e3596fed Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Thu, 10 May 2018 10:52:39 -0700 Subject: Throw error if user want to access message properties (#4603) * Throw error if user want to access message properties * Fix typo --- php/ext/google/protobuf/message.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'php/ext') diff --git a/php/ext/google/protobuf/message.c b/php/ext/google/protobuf/message.c index 4c68c391..c8f4d62b 100644 --- a/php/ext/google/protobuf/message.c +++ b/php/ext/google/protobuf/message.c @@ -222,7 +222,13 @@ static zval* message_get_property_ptr_ptr(zval* object, zval* member, int type, } static HashTable* message_get_properties(zval* object TSRMLS_DC) { - return NULL; + // User cannot get property directly (e.g., $a = $m->a) + zend_error(E_USER_ERROR, "Cannot access private properties."); +#if PHP_MAJOR_VERSION < 7 + return zend_std_get_properties(object TSRMLS_CC); +#else + return zend_std_get_properties(object); +#endif } static HashTable* message_get_gc(zval* object, CACHED_VALUE** table, -- cgit v1.2.3