-
-
Notifications
You must be signed in to change notification settings - Fork 108
Open
Labels
Description
When cloning an object of an ArrayObject-inherited class, deep_copy returns ArrayObject object instead of the actual clone of the supplied object. Obviously, all custom properties are lost in the process.
Example:
class TheTest extends ArrayObject {
public $x = 1;
}
$a = new TheTest();
$b = DeepCopy\deep_copy($a);
echo 'get_class($a) = ', get_class($a), "\n";
echo '$a->x = ', $a->x ?? "<none>", "\n\n";
echo 'get_class($b) = ', get_class($b), "\n";
echo '$b->x = ', $b->x ?? "<none>", "\n";Output:
get_class($a) = TheTest
$a->x = 1
get_class($b) = ArrayObject
$b->x = <none>
$b should be a carbon copy of $a, but it's not.
DeepCopy version: 1.9.5.
PHP version:
PHP 7.3.11-0ubuntu0.19.10.3 (cli) (built: Feb 12 2020 15:22:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.11-0ubuntu0.19.10.3, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans