From: Derick Rethans Date: Mon, 16 Feb 2004 12:08:20 +0000 (+0000) Subject: - Clearify clone behavior, fixed clone example (Patch by Jan Lehnardt) X-Git-Tag: RELEASE_0_2_0~312 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5dcf37b6188b8dcec92720f0a41151622a8dd7b9;p=php - Clearify clone behavior, fixed clone example (Patch by Jan Lehnardt) --- diff --git a/Zend/ZEND_CHANGES b/Zend/ZEND_CHANGES index 696c00578d..78b0deb886 100644 --- a/Zend/ZEND_CHANGES +++ b/Zend/ZEND_CHANGES @@ -275,7 +275,7 @@ Changes in the Zend Engine 2.0 * Final methods and classes. The Zend Engine 2.0 introduces the "final" keyword to declare - final methods. Those cannot be overridden by sub-classes. + final methods. Those cannot be overridden by sub-classes. Example: @@ -339,42 +339,42 @@ Changes in the Zend Engine 2.0 all of the object's properties. If a __clone() method is defined, then it will be responsible to set the necessary properties in the created object. For convenience, the engine - will supply a function that imports all of the properties from - the source object, so that they can start with a by-value - replica of the source object, and only override properties that - need to be changed. + ensures, that the clone will be initialized with all of the + properties from the source object, so that developers can start + with a by-value replica of the source object, and only override + properties that need to be changed. Example: - id = self::$id++; - } + function MyCloneable() { + $this->id = self::$id++; + } - function __clone() { - $this->name = $that->name; - $this->address = 'New York'; - $this->id = self::$id++; - } + function __clone() { + $this->address = 'New York'; + $this->id = self::$id++; + } } $obj = new MyCloneable(); - $obj->name = 'Hello'; + $obj->name = 'Hello'; $obj->address = 'Tel-Aviv'; - print $obj->id . "\n"; - - $obj = clone $obj; + $obj_clone = clone $obj; print $obj->id . "\n"; print $obj->name . "\n"; print $obj->address . "\n"; - ?> + print $obj_clone->id . "\n"; + print $obj_clone->name . "\n"; + print $obj_clone->address . "\n"; + ?> + * Unified Constructors. The Zend Engine allows developers to declare constructor methods @@ -488,7 +488,7 @@ Changes in the Zend Engine 2.0 Exceptions can be rethrown in catch blocks. Also it is possible to have multiple catch blocks. In that case the caught exception is - compare with the classtype of each catch block from top to bottom + compared with the classtype of each catch block from top to bottom and the first block that has a 'instanceof' match gets executed. When the catch block finishes execution continues at the end of the last catch block. If no catch block has a 'instanceof' match @@ -535,12 +535,11 @@ Changes in the Zend Engine 2.0 do so. This is because the internal Exception class can gather a lot of information otherwise not available. The PHP code emulation code would look something like shown below. The comments show the - meaning of each proerty and hence there getter methods. As the code - shows it is possible to read any available information by using the - getter methods. But since some of the methods are used internally - they are marked final. All in all the class is very restrictive - because it must be ensured that anything used internally always - works as expected. + meaning of each property. As the code shows it is possible to read + any available information by using the getter methods. But since + some of the methods are used internally they are marked final. All + in all the class is very restrictive because it must be ensured + that anything used internally always works as expected. Emulating class Exception: