By utilizing __toString(), all classes using t_base_return can now be directly used as a string.
This saves the effort of writing $my_class->get_value() or $my_class->get_value_exact().
This directly returns the private value as a string, which is probably faster than returning an object and then calling a function to convert.
Complex types, such as array, object, or resource, or converted to an empty string and must still be handled via function calls.
}
/**
+ * Provide to string object override.
+ *
+ * @return string
+ * An empty string.
+ *
+ * @see: http://php.net/manual/en/language.oop5.magic.php@object.tostring
+ */
+ public function __toString() {
+ return "";
+ }
+
+ /**
* Assign the value.
*
* @param array $value
}
/**
+ * Provide to string object override.
+ *
+ * @return string
+ * An empty string.
+ *
+ * @see: http://php.net/manual/en/language.oop5.magic.php@object.tostring
+ */
+ public function __toString() {
+ return "";
+ }
+
+ /**
* Assign the value.
*
* @param object $value
}
/**
+ * Provide to string object override.
+ *
+ * @return string
+ * An empty string.
+ *
+ * @see: http://php.net/manual/en/language.oop5.magic.php@object.tostring
+ */
+ public function __toString() {
+ return "";
+ }
+
+ /**
* Assign the value.
*
* @param resource $value
protected $value;
/**
+ * Provide to string object override.
+ *
+ * @return string
+ * The string representation of the value contained in this object.
+ *
+ * @see: http://php.net/manual/en/language.oop5.magic.php@object.tostring
+ */
+ public function __toString() {
+ return strval($this->value);
+ }
+
+ /**
* Assign the value.
*
* If the value is an object, then this should create a copy of the object (a clone).