php.net |  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
Description:
------------
$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

thanks


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-17 07:00 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2017-01-17 07:00 UTC] requinix@php.net
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: Mon Dec 30 14:01:28 2024 UTC