Re: [phpweb] zendengine2.php

From: Date: Fri, 02 Apr 2004 13:52:51 +0000
Subject: Re: [phpweb] zendengine2.php
References: 1  Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-24120@lists.php.net to get a copy of this message
Could someone please review this? I have not been into PHP 5 too deeply, so it seems to be illogical to me that __toString() is not called on casting but is called on echoing... Also the wording within the clone() explanation is not fine... Goba Friedhelm Betz wrote:
Hi Goba, attached a patch against zendengine2.php. Summary: reflect changed clone behaviour, no more $that, new keyword clone. use private, protected, public instead of var hasMore changed to valid __toString, not called with $str = (string) $obj; // call __toString() If this looks correct, I would be happy if you apply this one. Friedhelm ------------------------------------------------------------------------ Index: zend-engine-2.php =================================================================== RCS file: /repository/phpweb/zend-engine-2.php,v retrieving revision 1.24 diff -u -r1.24 zend-engine-2.php --- zend-engine-2.php 19 Mar 2004 07:58:03 -0000 1.24 +++ zend-engine-2.php 1 Apr 2004 10:35:33 -0000 @@ -267,10 +267,12 @@ of this other object so that the replica has its own separate copy. </p> <p> - An object copy is created by calling the object's <code>__clone()</code> method: + An object copy is created by calling the object's <code>__clone()</code> method + invoked with the keyword clone. An object's method <code>__clone()</code> can not + be called directly. </p> <?php highlight_php('<?php -$copy_of_object = $object->__clone(); +$copy_of_object = clone $object; ?>'); ?> <p> When the developer asks to create a new copy of an object, PHP 5 will @@ -292,7 +294,6 @@
     }
      function __clone() {
-        $this->name = $that->name;
         $this->address = "New York";
         $this->id = self::$id++;
     }
@@ -305,11 +306,11 @@ print $obj->id . "\n"; -$obj = $obj->__clone(); +$obj_cloned = clone $obj; -print $obj->id . "\n"; -print $obj->name . "\n"; -print $obj->address . "\n"; +print $obj_cloned->id . "\n"; +print $obj_cloned->name . "\n"; +print $obj_cloned->address . "\n"; ?>'); ?> @@ -693,7 +694,7 @@ <h3>Example: __call()</h3> <?php highlight_php('<?php class Caller {
-    var $x = array(1, 2, 3);
+    private $x = array(1, 2, 3);
      function __call($m, $a) {
         print "Method $m called:\n";
@@ -715,8 +716,8 @@ <h3>Example</h3> <?php highlight_php('<?php class Foo {
-    var $x = 1;
-    var $y = 2;
+    public $x = 1;
+    public $y = 2;
} $obj = new Foo; @@ -750,7 +751,7 @@
     function rewind() {
         $this->num = 0;
     }
-    function hasMore() {
+    function valid() {
         return $this->num < $this->obj->max;
     }
     function key() {
@@ -832,9 +833,7 @@
     }
} -$obj = Foo; - -$str = (string) $obj; // call __toString() +$obj = new Foo; echo $obj; // call __toString() ?>'); ?>


« previous php.mirrors (#24120) next »