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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2019 The PHP Group
All rights reserved.
Last updated: Wed Mar 20 21:01:26 2019 UTC