Bug #53967 [Ana->Csd]: ReflectionClass::isCloneable reports false positives
| From: | nikic@php.net | Date: | Fri, 28 Feb 2020 14:43:38 +0000 |
| Subject: | Bug #53967 [Ana->Csd]: ReflectionClass::isCloneable reports false positives | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225785@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53967&edit=1
ID: 53967
Updated by: nikic@php.net
Reported by: whatthejeff at gmail dot com
Summary: ReflectionClass::isCloneable reports false positives
-Status: Analyzed
+Status: Closed
Type: Bug
Package: Reflection related
PHP Version: trunk-SVN-2011-02-09 (snap)
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
isCloneable() for SplFileObject/SplTempFileObject in particular has been fixed in bug #72884.
Fact remains though that the final arbiter is whether
clone $obj does not throw,
isCloneable() can only help to detect cases that are definite not cloneable.
Previous Comments:
------------------------------------------------------------------------
[2019-08-04 05:41:49] trannguyenhoang8433 at gmail dot com
The following pull request has been associated:
Patch Name: error message should matched path
On GitHub: https://github.com/php/pecl-database-pdo_informix/pull/1
Patch: https://github.com/php/pecl-database-pdo_informix/pull/1.patch
------------------------------------------------------------------------
[2019-08-04 05:40:28] trannguyenhoang8433 at gmail dot com
The following pull request has been associated:
Patch Name: protect master branches except for the pecl repos against force pushes
On GitHub: https://github.com/php/karma/pull/4
Patch: https://github.com/php/karma/pull/4.patch
------------------------------------------------------------------------
[2017-12-09 22:03:05] nikic@php.net
I don't think so. As was mentioned, some objects determine clonability dynamically. There is no
real way to determine if something is clonable short of doing it and seeing if it throws. This also
holds for userland objects, of course. isClonable() can tell you when something definitely cannot be
cloned, but it's just impossible to say if it will succeed once __clone() comes into the
picture.
What do you need it for anyway? As of PHP 7, just cloning the object and catching Errors should be a
fine way to determine clonability, as it doesn't throw a fatal anymore.
------------------------------------------------------------------------
[2017-12-07 13:00:21] sebastian@php.net
Is there any chance to fix ReflectionClass::isCloneable() to work correctly for all internal
classes?
------------------------------------------------------------------------
[2011-02-11 22:48:53] whatthejeff at gmail dot com
Yeah, I actually realized ReflectionClass::isCloneable wouldn't work for SplFileObject and
SplTempFileObject when I was looking at the implementation for
SplFileObject.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=53967
--
Edit this bug report at https://bugs.php.net/bug.php?id=53967&edit=1