|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69925 ReflectionProperty::setAccessible() permanently mutates properties on DateTime
Submitted: 2015-06-25 02:30 UTC Modified: 2018-09-29 12:30 UTC
From: mark at mark-story dot com Assigned:
Status: Duplicate Package: Reflection related
PHP Version: 5.5.26 OS: MacOS 10.10.3
Private report: No CVE-ID: None
 [2015-06-25 02:30 UTC] mark at mark-story dot com
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:
$subject = new DateTime('2015-06-24 22:09:00');

$reflection = new ReflectionObject($subject);
foreach ($reflection->getProperties() as $prop) {

Expected result:
I would expect the output to be:


Actual result:
However, it is:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-13 13:10 UTC]
-Status: Open +Status: Verified
 [2016-06-13 13:10 UTC]
Verified: <>.

The behavior appears to be related to bug #69587, and if so, it
wouldn't be an issue regarding reflection, but rather DateTime.
 [2018-09-29 12:30 UTC]
-Status: Verified +Status: Duplicate
 [2018-09-29 12:30 UTC]
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).
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 09 06:01:28 2023 UTC