summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Schoenmakers <toon.schoenmakers@copernica.com>2015-05-18 13:11:25 +0200
committerToon Schoenmakers <toon.schoenmakers@copernica.com>2015-05-18 13:11:25 +0200
commit9956d998368e0d9f55e1940f4d584fe1554c7418 (patch)
tree4261010efa15dd9136e03a204442dc9aef91ba55
parent273ad6a1f4bec5360bf7635197cb28fc4b55c24a (diff)
The Value::contains(int) method now also works with ArrayAccess
-rw-r--r--zend/value.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/zend/value.cpp b/zend/value.cpp
index 963f05b..a728dcc 100644
--- a/zend/value.cpp
+++ b/zend/value.cpp
@@ -1455,8 +1455,10 @@ void Value::iterate(const std::function<void(const Php::Value &,const Php::Value
*/
bool Value::contains(int index) const
{
+ // if we're an object implementing ArrayAccess it makes sense for this method to work as well, so we call offsetExists
+ if (isObject() && instanceOf("ArrayAccess")) return call("offsetExists", index).boolValue();
// must be an array
- if (!isArray()) return false;
+ else if (!isArray()) return false;
// unused variable
zval **result;