+ return $this->sv->getValue();
+ }
+
+ /**
+ * Backwards compatibility logic
+ *
+ * @param string $name
+ */
+ function __get( $name ) {
+ if ( $name === 'ok' ) {
+ return $this->sv->isOK();
+ } elseif ( $name === 'errors' ) {
+ return $this->sv->getErrors();
+ }
+ throw new Exception( "Cannot get '$name' property." );
+ }
+
+ /**
+ * Backwards compatibility logic
+ *
+ * @param string $name
+ * @param mixed $value
+ */
+ function __set( $name, $value ) {
+ if ( $name === 'ok' ) {
+ $this->sv->setOK( $value );
+ } elseif ( !property_exists( $this, $name ) ) {
+ // Caller is using undeclared ad-hoc properties
+ $this->$name = $value;
+ } else {
+ throw new Exception( "Cannot set '$name' property." );
+ }
+ }
+
+ /**
+ * @return string
+ */
+ public function __toString() {
+ return $this->sv->__toString();
+ }
+
+ /**
+ * Don't save the callback when serializing, because Closures can't be
+ * serialized and we're going to clear it in __wakeup anyway.
+ */
+ function __sleep() {
+ $keys = array_keys( get_object_vars( $this ) );
+ return array_diff( $keys, array( 'cleanCallback' ) );
+ }
+
+ /**
+ * Sanitize the callback parameter on wakeup, to avoid arbitrary execution.
+ */
+ function __wakeup() {
+ $this->cleanCallback = false;