From af6c10e389515ce97ac623ee352848e7480d6720 Mon Sep 17 00:00:00 2001 From: andot Date: Thu, 10 Jul 2014 21:52:32 +0800 Subject: [PATCH 1/2] Add ref method for Php::Value If you want get a reference of a value, you can use this method. It will work correctly when patched #114. --- include/value.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/value.h b/include/value.h index f72304cf..d8931c43 100644 --- a/include/value.h +++ b/include/value.h @@ -381,6 +381,14 @@ class Value : private HashParent bool isArray() const { return type() == Type::Array; } bool isCallable() const; + /** + * Get a reference of this Value. + * + * @return Value + */ + Value ref() const { + return Value(_val, true); + } /** * Get access to the raw buffer - you can use this for direct reading and * writing to and from the buffer. Note that this only works for string From 5a1241255831cb8b115d69b912da26828c91687a Mon Sep 17 00:00:00 2001 From: andot Date: Thu, 10 Jul 2014 22:09:35 +0800 Subject: [PATCH 2/2] Add refequals method for Php::Value You can use this method to check for reference equality. You can use it to compare whether two arrays are the same. There is no similar function in PHP, but we need it when we want to write a serialize program. --- include/value.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/value.h b/include/value.h index d8931c43..87465388 100644 --- a/include/value.h +++ b/include/value.h @@ -389,6 +389,17 @@ class Value : private HashParent Value ref() const { return Value(_val, true); } + + /** + * To check for reference equality. + * @param value + * @return bool + */ + bool refequals(const Value &value) const + { + return isRef() && _val == value._val; + } + /** * Get access to the raw buffer - you can use this for direct reading and * writing to and from the buffer. Note that this only works for string