php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38079 __copy magic method to increase backwards compatibility
Submitted: 2006-07-12 13:34 UTC Modified: 2018-05-05 18:14 UTC
From: wickedfather at hotmail dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.1.5CVS OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wickedfather at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-07-12 13:34 UTC] 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;
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-05 18:14 UTC] requinix@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2018-05-05 18:14 UTC] requinix@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 16:01:28 2024 UTC