val_rc
"zpp::val_rc" is wrap around a zval structure rather than a pointer to one. It does use zpp::val_ptr methods in some of its internals. With this class the address of the zval is never null.
A major purpose of val_rc, is to allow class methods to be able to create and return "mixed" values, of any PHP type, and have their lifetime managed with reference counting. This is needed for methods and functions that can return more than one possible PHP type.
'val_rc', like 'val_ptr' has the same names of methods to test the contained PHP type, and can extract PHP value types asked for, namely zobject(), zarray(), zstr(). It returns a nullptr() if the type is not available, and does not throw an exception.
value assignment operators
A marked difference to val_ptr, is that val_rc has a large number of assignment operators, and constructor options, and destructor. All of these maintain any required reference counting for a contained type. Their is also a few methods to coerce the underlying type in place.
class val_rc {
// ...
public:
//! mutate in place to suggested type if necessary
void toLong();
void toDouble();
void toString();
void make_ref();
void decref();
void addref();
void set_bool(bool value);
void set_null();
void new_array();
void empty_array();
//...
const val_rc& operator=(const val_ptr &rc);
const val_rc& operator=(const obj_ptr &rc);
const val_rc& operator=(const str_ptr &rc);
const val_rc& operator=(const htab_rc &rc);
const val_rc& operator=(zend_long value);
const val_rc& operator=(double value);
const val_rc& operator=(const val_rc &rc);
};