Bug #69925 [Ver->Dup]: ReflectionProperty::setAccessible() permanently mutates properties on DateTime
| From: | nikic@php.net | Date: | Sat, 29 Sep 2018 12:30:30 +0000 |
| Subject: | Bug #69925 [Ver->Dup]: ReflectionProperty::setAccessible() permanently mutates properties on DateTime | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217280@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69925&edit=1
ID: 69925
Updated by: nikic@php.net
Reported by: mark at mark-story dot com
Summary: ReflectionProperty::setAccessible() permanently
mutates properties on DateTime
-Status: Verified
+Status: Duplicate
Type: Bug
Package: Reflection related
Operating System: MacOS 10.10.3
PHP Version: 5.5.26
Block user comment: N
Private report: N
New Comment:
Yes, this is due to a bug in DateTime, not reflection. I'm closing this as a duplicate of bug
#75232, which is about print_r, but the root cause is the same (debugging properties added in
get_properties).
Previous Comments:
------------------------------------------------------------------------
[2016-06-13 13:10:09] cmb@php.net
Verified: <https://3v4l.org/VHJMq>.
The behavior appears to be related to bug #69587, and if so, it
wouldn't be an issue regarding reflection, but rather DateTime.
------------------------------------------------------------------------
[2015-06-25 02:30:25] mark at mark-story dot com
Description:
------------
The documentation for ReflectionProperty::setAccessible() implies that the change should not effect
the object property visibility and this is true of user land classes, however DateTime works a bit
differently, and doesn't match the behavior around userland classes.
Test script:
---------------
<?php
$subject = new DateTime('2015-06-24 22:09:00');
var_dump(isset($subject->timezone));
$reflection = new ReflectionObject($subject);
foreach ($reflection->getProperties() as $prop) {
$prop->setAccessible(true);
$prop->setAccessible(false);
}
var_dump(isset($subject->timezone));
Expected result:
----------------
I would expect the output to be:
bool(false)
bool(false)
Actual result:
--------------
However, it is:
bool(false)
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69925&edit=1