diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-10 12:26:04 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-10 12:26:04 +0100 |
commit | 4872cc627642044f46ba8a8726902592a1fae05f (patch) | |
tree | a416aff6d3511b17923001a664ece1deca01b4d7 /include | |
parent | d2e10c764d1b8860dd798eda3055fc957ff556ad (diff) |
first setup for magic methods __get(), __set(), __isset() and __unset()
Diffstat (limited to 'include')
-rw-r--r-- | include/base.h | 44 | ||||
-rw-r--r-- | include/classbase.h | 34 |
2 files changed, 78 insertions, 0 deletions
diff --git a/include/base.h b/include/base.h index b027d5a..d944e3c 100644 --- a/include/base.h +++ b/include/base.h @@ -111,6 +111,50 @@ public: { return Value(this)[name]; } + + /** + * 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 + */ + virtual bool __isset(const Php::Value &key); + + /** + * 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 + */ + virtual void __set(const Php::Value &key, const Php::Value &value); + + /** + * Retrieve a property + * + * The default implementation does nothing, and the script will fall back + * to accessing the regular object properties + * + * @param key + * @return value + */ + virtual Php::Value __get(const Php::Value &key); + + /** + * Remove a member + * + * The default implementation does nothing, and the script will fall back + * to accessing the regular object properties + * + * @param key + */ + virtual void __unset(const Php::Value &key); + private: /** diff --git a/include/classbase.h b/include/classbase.h index 1be2538..492bb15 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -298,6 +298,40 @@ private: static struct _zend_object_iterator *getIterator(struct _zend_class_entry *entry, struct _zval_struct *object, int by_ref); /** + * Function that is called when a property is being read + * @param object The object on which it is called + * @param offset The name of the property + * @param type The type of the variable??? + * @return zval + */ + static struct _zval_struct *readProperty(struct _zval_struct *object, struct _zval_struct *name, int type); + + /** + * Function that is called when a property is set / updated + * @param object The object on which it is called + * @param name The name of the property + * @param value The new value + * @return zval + */ + static void writeProperty(struct _zval_struct *object, struct _zval_struct *name, struct _zval_struct *value); + + /** + * Function that is called to check whether a certain property is set + * @param object The object on which it is called + * @param name The name of the property to check + * @param has_set_exists See above + * @return bool + */ + static int hasProperty(struct _zval_struct *object, struct _zval_struct *name, int has_set_exists); + + /** + * Function that is called when a property is removed from the project + * @param object The object on which it is called + * @param member The member to remove + */ + static void unsetProperty(struct _zval_struct *object, struct _zval_struct *member); + + /** * Name of the class * @var string */ |