diff options
-rw-r--r-- | include/hashmember.h | 4 | ||||
-rw-r--r-- | include/value.h | 2 | ||||
-rw-r--r-- | zend/value.cpp | 14 |
3 files changed, 15 insertions, 5 deletions
diff --git a/include/hashmember.h b/include/hashmember.h index 12ee385..378ee90 100644 --- a/include/hashmember.h +++ b/include/hashmember.h @@ -611,8 +611,8 @@ private: * @param value * @return ostream */ -std::ostream &operator<<(std::ostream &stream, const HashMember<int> &value); -std::ostream &operator<<(std::ostream &stream, const HashMember<std::string> &value); +PHPCPP_EXPORT std::ostream &operator<<(std::ostream &stream, const HashMember<int> &value); +PHPCPP_EXPORT std::ostream &operator<<(std::ostream &stream, const HashMember<std::string> &value); /** diff --git a/include/value.h b/include/value.h index 40327cd..29b64af 100644 --- a/include/value.h +++ b/include/value.h @@ -1204,7 +1204,7 @@ protected: * @param value * @return ostream */ -std::ostream &operator<<(std::ostream &stream, const Value &value); +PHPCPP_EXPORT std::ostream &operator<<(std::ostream &stream, const Value &value); /** * Custom +=, -=, *=, /=, &= operators, to update integral types with a Php::Value diff --git a/zend/value.cpp b/zend/value.cpp index da42f30..f596669 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -1490,8 +1490,18 @@ bool Value::contains(const char *key, int size) const // is marked as private/protected (cast necessary for php 5.3) if (zend_check_property_access(zend_objects_get_address(_val TSRMLS_CC), const_cast<char *>(key), size TSRMLS_CC) == FAILURE) return false; - // check if the property is set inside the hashtable of the object - return zend_hash_find(Z_OBJPROP_P(_val), key, size+1, (void **)&result) != FAILURE; + // check if the 'has_property' method is available for this object + auto *has_property = Z_OBJ_HT_P(_val)->has_property; + + // leap out if no 'has_property' function is not set (which should normally not occur) + if (!has_property) return false; + + // the property must be a zval, turn the key into a value + Value property(key, size); + + // call the has_property() method (0 means: check whether property exists and is not NULL, + // this is not really what we want, but the closest to the possible values of that parameter) + return has_property(_val, property._val, 0, nullptr TSRMLS_CC); } else { |