File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,7 @@ class PHPCPP_EXPORT Value : private HashParent
398398 bool isBool () const ;
399399 bool isString () const ;
400400 bool isFloat () const ;
401+ bool isReference () const ;
401402 bool isObject () const ;
402403 bool isArray () const ;
403404 bool isScalar () const { return isNull () || isNumeric () || isBool () || isString () || isFloat (); }
Original file line number Diff line number Diff line change @@ -1048,6 +1048,16 @@ bool Value::isFloat() const
10481048 return ((Type) Z_TYPE_P (_val.dereference ())) == Type::Float;
10491049}
10501050
1051+ /* *
1052+ * Are we a reference?
1053+ * @return bool
1054+ */
1055+ bool Value::isReference () const
1056+ {
1057+ // check our pointer if we are a reference
1058+ return Z_ISREF_P (_val);
1059+ }
1060+
10511061/* *
10521062 * Are we an object? This will also check if we're a reference to an object
10531063 * @return bool
@@ -1130,12 +1140,20 @@ bool Value::isCallable() const
11301140 */
11311141zend_class_entry *Value::classEntry (bool allowString) const
11321142{
1143+ // are we a reference
1144+ if (isReference ())
1145+ {
1146+ // we go through the reference to retrieve the object
1147+ return Z_OBJCE_P (Z_REFVAL_P (_val));
1148+ }
1149+
11331150 // is this an object
1134- if (isObject ())
1151+ else if (isObject ())
11351152 {
11361153 // class entry can be easily found
11371154 return Z_OBJCE_P (_val);
11381155 }
1156+
11391157 else
11401158 {
11411159 // the value is not an object, is this allowed?
@@ -1777,11 +1795,14 @@ HashMember<std::string> Value::operator[](const char *key)
17771795 */
17781796Base *Value::implementation () const
17791797{
1798+ // are we a reference
1799+ if (isReference ()) return ObjectImpl::find (Z_REFVAL_P (_val))->object ();
1800+
17801801 // must be an object
1781- if (! isObject ()) return nullptr ;
1802+ if (isObject ()) return ObjectImpl::find (_val)-> object () ;
17821803
17831804 // retrieve the mixed object that contains the base
1784- return ObjectImpl::find (_val)-> object () ;
1805+ return nullptr ;
17851806}
17861807
17871808/* *
You can’t perform that action at this time.
0 commit comments