diff options
-rw-r--r-- | include/call.h | 8 | ||||
-rw-r--r-- | include/hashmember.h | 3 | ||||
-rw-r--r-- | zend/callable.cpp | 2 | ||||
-rw-r--r-- | zend/classimpl.h | 2 | ||||
-rw-r--r-- | zend/globals.cpp | 2 | ||||
-rw-r--r-- | zend/object.cpp | 4 | ||||
-rw-r--r-- | zend/stringmember.h | 4 | ||||
-rw-r--r-- | zend/super.cpp | 4 | ||||
-rw-r--r-- | zend/value.cpp | 6 |
9 files changed, 19 insertions, 16 deletions
diff --git a/include/call.h b/include/call.h index 6c5dd8f..1fb1462 100644 --- a/include/call.h +++ b/include/call.h @@ -50,6 +50,7 @@ inline Value array_key_exists(const char *key, const Value &array) { return arra inline Value array_key_exists(const std::string &key, const Value &array) { return array.contains(key); } inline Value array_keys(const Value &value) { return call("array_keys", value); } inline Value array_values(const Value &value) { return call("array_values", value); } +inline Value count(const Value &value) { return call("count", value); } inline Value echo(const char *input) { out << input; return nullptr; } inline Value echo(const std::string &input) { out << input; return nullptr; } inline Value empty(const Value &value) { return value.isNull() || !value.boolValue(); } @@ -57,9 +58,10 @@ inline Value empty(const HashMember<std::string> &member) { return !member.exist inline Value empty(const HashMember<int> &member) { return !member.exists() || empty(member.value()); } inline Value ini_get(const Value &value) { return call("ini_get", value); } inline Value is_array(const Value &value) { return value.isArray(); } -inline void unset(HashMember<std::string> &member) { member.unset(); } -inline void unset(HashMember<int> &member) { member.unset(); } -inline void unset(HashMember<Value> &member) { member.unset(); } +inline Value strlen(const Value &value) { return call("strlen", value); } +inline void unset(const HashMember<std::string> &member) { member.unset(); } +inline void unset(const HashMember<int> &member) { member.unset(); } +inline void unset(const HashMember<Value> &member) { member.unset(); } /** * The isset function conflicts with the 'isset' macro defined by the Zend engine diff --git a/include/hashmember.h b/include/hashmember.h index 1a29548..6853228 100644 --- a/include/hashmember.h +++ b/include/hashmember.h @@ -497,7 +497,7 @@ public: /** * Unset the member */ - void unset() + void unset() const { _parent->unset(_index); } @@ -599,6 +599,7 @@ private: * Friend classes */ friend class HashMember<std::string>; + friend class HashMember<Value>; friend class HashMember<int>; friend class Base; friend class Value; diff --git a/zend/callable.cpp b/zend/callable.cpp index 96f5f90..caee311 100644 --- a/zend/callable.cpp +++ b/zend/callable.cpp @@ -94,7 +94,7 @@ void Callable::initialize(zend_arg_info *info, const char *classname) const // because we do not support returning references in PHP-CPP, although Zend // engine allows it. Inside the name we hide a pointer to the current object finfo->_name = _ptr; - finfo->_name_len = strlen(_ptr); + finfo->_name_len = ::strlen(_ptr); finfo->_class_name = classname; // number of required arguments, and the expected return type diff --git a/zend/classimpl.h b/zend/classimpl.h index febdbca..ec28322 100644 --- a/zend/classimpl.h +++ b/zend/classimpl.h @@ -408,7 +408,7 @@ public: void property(const char *name, bool value, int flags = Php::Public) { _members.push_back(std::make_shared<BoolMember> (name, value, flags & PropertyModifiers)); } void property(const char *name, char value, int flags = Php::Public) { _members.push_back(std::make_shared<StringMember> (name, &value, 1, flags & PropertyModifiers)); } void property(const char *name, const std::string &value, int flags = Php::Public) { _members.push_back(std::make_shared<StringMember> (name, value, flags & PropertyModifiers)); } - void property(const char *name, const char *value, int flags = Php::Public) { _members.push_back(std::make_shared<StringMember> (name, value, strlen(value), flags & PropertyModifiers)); } + void property(const char *name, const char *value, int flags = Php::Public) { _members.push_back(std::make_shared<StringMember> (name, value, ::strlen(value), flags & PropertyModifiers)); } void property(const char *name, double value, int flags = Php::Public) { _members.push_back(std::make_shared<FloatMember> (name, value, flags & PropertyModifiers)); } /** diff --git a/zend/globals.cpp b/zend/globals.cpp index 8132ef3..5299c90 100644 --- a/zend/globals.cpp +++ b/zend/globals.cpp @@ -43,7 +43,7 @@ Global Globals::operator[](const char *name) TSRMLS_FETCH(); // check if the variable already exists - if (zend_hash_find(&EG(symbol_table), name, strlen(name)+1, (void**)&varvalue) == FAILURE) + if (zend_hash_find(&EG(symbol_table), name, ::strlen(name)+1, (void**)&varvalue) == FAILURE) { // the variable does not already exist, return a global object // that will automatically set the value when it is updated diff --git a/zend/object.cpp b/zend/object.cpp index d7fc158..08553b5 100644 --- a/zend/object.cpp +++ b/zend/object.cpp @@ -33,7 +33,7 @@ Object::Object(const char *name, Base *base) // this is a brand new object that should be allocated, the C++ instance // is already there (created by the extension) but it is not yet stored // in PHP, find out the classname first - auto *entry = zend_fetch_class(name, strlen(name), 0 TSRMLS_CC); + auto *entry = zend_fetch_class(name, ::strlen(name), 0 TSRMLS_CC); if (!entry) throw Php::Exception(std::string("Unknown class name ") + name); // construct an implementation (this will also set the implementation @@ -55,7 +55,7 @@ void Object::instantiate(const char *name) TSRMLS_FETCH(); // convert the name into a class_entry - auto *entry = zend_fetch_class(name, strlen(name), 0 TSRMLS_CC); + auto *entry = zend_fetch_class(name, ::strlen(name), 0 TSRMLS_CC); if (!entry) throw Php::Exception(std::string("Unknown class name ") + name); // initiate the zval (which was already allocated in the base constructor) diff --git a/zend/stringmember.h b/zend/stringmember.h index e58cd3d..05fdb11 100644 --- a/zend/stringmember.h +++ b/zend/stringmember.h @@ -1,7 +1,7 @@ /** * StringMember.h * - * Implementation for a property that is initially set to a strnig value + * Implementation for a property that is initially set to a string value * * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> * @copyright 2013 Copernica BV @@ -40,7 +40,7 @@ public: * @param value * @param flags */ - StringMember(const char *name, const char *value, int flags) : StringMember(name, value, strlen(value), flags) {} + StringMember(const char *name, const char *value, int flags) : StringMember(name, value, ::strlen(value), flags) {} /** * Constructor diff --git a/zend/super.cpp b/zend/super.cpp index 506d4a5..c25efeb 100644 --- a/zend/super.cpp +++ b/zend/super.cpp @@ -34,7 +34,7 @@ Value Super::operator[](const std::string &key) TSRMLS_FETCH(); // call zend_is_auto_global to ensure that the just-in-time globals are loaded - if (_name) { zend_is_auto_global(_name, strlen(_name) TSRMLS_CC); _name = nullptr; } + if (_name) { zend_is_auto_global(_name, ::strlen(_name) TSRMLS_CC); _name = nullptr; } // create a value object that wraps around the actual zval Value value(PG(http_globals)[_index]); @@ -55,7 +55,7 @@ Value Super::operator[](const char *key) TSRMLS_FETCH(); // call zend_is_auto_global to ensure that the just-in-time globals are loaded - if (_name) { zend_is_auto_global(_name, strlen(_name) TSRMLS_CC); _name = nullptr; } + if (_name) { zend_is_auto_global(_name, ::strlen(_name) TSRMLS_CC); _name = nullptr; } // create a value object that wraps around the actual zval Value value(PG(http_globals)[_index]); diff --git a/zend/value.cpp b/zend/value.cpp index a8fadce..dd371b9 100644 --- a/zend/value.cpp +++ b/zend/value.cpp @@ -126,7 +126,7 @@ Value::Value(const char *value, int size) { // create a string zval MAKE_STD_ZVAL(_val); - ZVAL_STRINGL(_val, value, size < 0 ? strlen(value) : size, 1); + ZVAL_STRINGL(_val, value, size < 0 ? ::strlen(value) : size, 1); } /** @@ -1640,7 +1640,7 @@ bool Value::contains(int index) const bool Value::contains(const char *key, int size) const { // calculate size - if (size < 0) size = strlen(key); + if (size < 0) size = ::strlen(key); // deal with arrays if (isArray()) @@ -1704,7 +1704,7 @@ Value Value::get(const char *key, int size) const if (!isArray() && !isObject()) return Value(); // calculate size - if (size < 0) size = strlen(key); + if (size < 0) size = ::strlen(key); // are we in an object or an array? if (isArray()) |