|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73952 Reflection say interfaces are not cloneable
Submitted: 2017-01-17 06:41 UTC Modified: 2017-01-17 07:00 UTC
From: hidingitfrombots at example dot org Assigned:
Status: Not a bug Package: Reflection related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2017-01-17 06:41 UTC] hidingitfrombots at example dot org
$interfaceReflection->isCloneable() always returns false for interfaces.

But they are, as all types are cloneable by default unless one explicitly makes __clone non public.

Additionally, it returns false even if __clone is explicitly defined:

interface Baz{ function __clone(); }
$rc = new ReflectionClass(Baz::class);
var_dump($rc->isCloneable()); // false



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-17 07:00 UTC]
-Status: Open +Status: Not a bug
 [2017-01-17 07:00 UTC]
Interfaces cannot be constructed, therefore they cannot be cloned. Same goes for traits and abstract classes. The existence and visibility of __clone only matters for regular classes.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 12:01:28 2024 UTC