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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hidingitfrombots at example dot org
New email:
PHP Version: OS:

 

 [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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 02 12:01:29 2025 UTC