Bug #69925 [Opn->Ver]: ReflectionProperty::setAccessible() permanently mutates properties on DateTime

From: Date: Mon, 13 Jun 2016 13:10:09 +0000
Subject: Bug #69925 [Opn->Ver]: ReflectionProperty::setAccessible() permanently mutates properties on DateTime
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201569@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: cmb@php.net Reported by: mark at mark-story dot com Summary: ReflectionProperty::setAccessible() permanently mutates properties on DateTime -Status: Open +Status: Verified 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: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#201569) next »