From 6bf3f222bbbd1adec7f85a954dc1aee146259894 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Fri, 14 Mar 2014 16:58:17 +0100 Subject: fixed magic method documentation, added comment in Makefile --- documentation/magic-methods.html | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'documentation') diff --git a/documentation/magic-methods.html b/documentation/magic-methods.html index 9294a3e..6356d2a 100644 --- a/documentation/magic-methods.html +++ b/documentation/magic-methods.html @@ -35,8 +35,8 @@

Constructors

- We start with an exception to the rule. Normally, you do not have to register - magic methods to make them work. When you add a magic method like + Normally, magic methods do not have + to be registered to make them work. When you add a magic method like __toString() or __get() to your class, it will automatically be called when an object is casted to a string or a property is accessed. There is no need to enable the magic method explicitly in the get_module() startup @@ -67,17 +67,24 @@

Clone and destruct

The magic __clone() method is very similar to the __construct() method. It - is the first method to be called on a new object after it is copy - constructed. The __destruct() is the method that gets called right before - the object gets destructed (and the C++ destructor runs). + also is a method that is called directly after an object is constructed. + The difference is that __clone() is called after an object is copy + constructed (or cloned if you prefer the PHP idiom), while + __construct() is called right after the normal constructor.

- The __clone() and __destruct() methods are regular magic methods and you - therefore do not have to register them to make them active. The PHP-CPP - library calls them automatically if they are available. + The magic __destruct() method gets called right before the object gets + destructed (and right before the C++ destructor runs).

- In normal circumstances you probably have not need for these methods. + The __clone() and __destruct() methods are regular magic methods (unlike + __construct()) and you therefore do not have to register them to make them + active. If you add one of these two methods to your class, you will not have + to make any changes to the get_module() startup function. The PHP-CPP library + calls them automatically if they are available. +

+

+ In normal circumstances you probably have no need for these methods. The C++ copy constructor and the C++ destructor can be used too. The only difference is that the magic methods are called on objects that are in a fully initialized state, while the C++ copy constructor and C++ destructor -- cgit v1.2.3