Req #38079 [Opn->Wfx]: __copy magic method to increase backwards compatibility
| From: | requinix@php.net | Date: | Sat, 05 May 2018 18:14:05 +0000 |
| Subject: | Req #38079 [Opn->Wfx]: __copy magic method to increase backwards compatibility | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215070@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=38079&edit=1
ID: 38079
Updated by: requinix@php.net
Reported by: wickedfather at hotmail dot com
Summary: __copy magic method to increase backwards
compatibility
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: All
PHP Version: 5.1.5CVS
Block user comment: N
Private report: N
New Comment:
Old request is old.
PHP 5's OOP rewrite is long in the past now and its revised treatment of object instances is
the norm.
Previous Comments:
------------------------------------------------------------------------
[2006-07-12 13:34:59] wickedfather at hotmail dot com
Description:
------------
An extra magic method that works in the same was as __clone but is called when an object is assigned
in the normal way. Code earlier that php5 could be fixed in one place by adding a single method to
a class rather than having to find every $obj1 = $obj2 line in your scripts.
Reproduce code:
---------------
<?php
class MyClass
{
public function __copy
{
echo 'I want to return a copy, not a reference, like in olden days';
return clone($this);
}
}
$obj1 = new MyClass;
$obj2 = $obj1;
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=38079&edit=1