php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79115 ReflectionClass::isCloneable calls reflected class __destruct
Submitted: 2020-01-14 15:04 UTC Modified: 2020-01-17 13:29 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: brucekwells at gmail dot com Assigned:
Status: Closed Package: Reflection related
PHP Version: 7.3.13 OS: Windows 10
Private report: No CVE-ID: None
 [2020-01-14 15:04 UTC] brucekwells at gmail dot com
Description:
------------
---
From manual page: https://php.net/reflectionclass.iscloneable
---

When ReflectionClass::isCloneable is called, it calls the reflected class's destructor.

Output should be nothing, but returns "__destruct".  Uncomment __clone, and nothing is output, which is correct.  See code snippet below.

Test script:
---------------
class A {
    function __construct() { echo __FUNCTION__ . "\n"; }
    function __destruct() { echo __FUNCTION__ . "\n"; }
//    function __clone() { echo __FUNCTION__ . "\n"; }
}

$c = new ReflectionClass('A');
$c->isCloneable();


Expected result:
----------------
No output should be returned.

Actual result:
--------------
__destruct

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-14 18:43 UTC] requinix@php.net
-Status: Open +Status: Verified
 [2020-01-14 18:43 UTC] requinix@php.net
There's some awkwardness going on for detecting cloneability that currently results in having to create a new instance and check whether *it* can be cloned. There should be room for improvement here.
 [2020-01-17 10:38 UTC] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=07bda97e765407bac9c37c9d4feb6aebb23434bd
Log: Fixed bug #79115
 [2020-01-17 10:38 UTC] nikic@php.net
-Status: Verified +Status: Closed
 [2020-01-17 13:29 UTC] brucekwells at gmail dot com
-Summary: ReflectionClass::isCloneable call reflected class __destruct +Summary: ReflectionClass::isCloneable calls reflected class __destruct
 [2020-01-17 13:29 UTC] brucekwells at gmail dot com
Better title.  Thanks for the fast fix!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC