php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70292 Calling array_key_exists/var_dump on \DateTime adds public fields
Submitted: 2015-08-18 11:21 UTC Modified: 2015-08-18 11:47 UTC
From: orminapod3 at gmail dot com Assigned: cmb (profile)
Status: Duplicate Package: *General Issues
PHP Version: 7.0.0beta3 OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: orminapod3 at gmail dot com
New email:
PHP Version: OS:

 

 [2015-08-18 11:21 UTC] orminapod3 at gmail dot com
Description:
------------
Upon calling var_dump() or array_key_exists() on a \DateTime object, it will receive new public properties not accessible before.

Test script:
---------------
$object = new DateTime();
array_key_exists("test",$object);
var_dump($object->date);



Expected result:
----------------
The result should be the same regardless of the arbitrary calls ( probably fields should not exist at all )

Actual result:
--------------
For the code using array_key_exists/var_dump, we receive a string from the public field.

Otherwise we receive a warning.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-18 11:47 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2015-08-18 11:47 UTC] cmb@php.net
Basically, that is a duplicate of bug #69587.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 30 20:01:29 2025 UTC