Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not properly clone classes inherited from ArrayObject #152

Open
alexpkalinka opened this issue Mar 19, 2020 · 0 comments
Open

Does not properly clone classes inherited from ArrayObject #152

alexpkalinka opened this issue Mar 19, 2020 · 0 comments
Assignees
Labels

Comments

@alexpkalinka
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants