summaryrefslogtreecommitdiff
path: root/src/base.cpp
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-10 12:26:04 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-10 12:26:04 +0100
commit4872cc627642044f46ba8a8726902592a1fae05f (patch)
treea416aff6d3511b17923001a664ece1deca01b4d7 /src/base.cpp
parentd2e10c764d1b8860dd798eda3055fc957ff556ad (diff)
first setup for magic methods __get(), __set(), __isset() and __unset()
Diffstat (limited to 'src/base.cpp')
-rw-r--r--src/base.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/base.cpp b/src/base.cpp
index 305821f..b561899 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -78,6 +78,72 @@ MixedObject *Base::store(zend_class_entry *entry)
}
/**
+ * Overridable method that is called to check if a property is set
+ *
+ * The default implementation does nothing, and the script will fall back
+ * to accessing the regular object properties
+ *
+ * @param key
+ * @return bool
+ */
+bool Base::__isset(const Php::Value &key)
+{
+ // throw an exception that will be caught in the ClassBase class,
+ // so that the default implementation of the unset function can be called
+ throw NotImplemented();
+}
+
+/**
+ * Overridable method that is called to set a new property
+ *
+ * The default implementation does nothing, and the script will fall back
+ * to accessing the regular object properties
+ *
+ * @param key
+ * @param value
+ */
+void Base::__set(const Php::Value &key, const Php::Value &value)
+{
+ // throw an exception that will be caught in the ClassBase class,
+ // so that the default implementation of the unset function can be called
+ throw NotImplemented();
+}
+
+/**
+ * Retrieve a property
+ *
+ * The default implementation does nothing, and the script will fall back
+ * to accessing the regular object properties
+ *
+ * @param key
+ * @return value
+ */
+Php::Value Base::__get(const Php::Value &key)
+{
+ // throw an exception that will be caught in the ClassBase class,
+ // so that the default implementation of the function can be called
+ throw NotImplemented();
+
+ // unreachable code
+ return nullptr;
+}
+
+/**
+ * Remove a member
+ *
+ * The default implementation does nothing, and the script will fall back
+ * to accessing the regular object properties
+ *
+ * @param key
+ */
+void Base::__unset(const Php::Value &key)
+{
+ // throw an exception that will be caught in the ClassBase class,
+ // so that the default implementation of the function can be called
+ throw NotImplemented();
+}
+
+/**
* End namespace
*/
}