Bug #69587 [Opn->Ver]: DateInterval properties and isset

From: Date: Wed, 06 May 2015 20:15:59 +0000
Subject: Bug #69587 [Opn->Ver]: DateInterval properties and isset
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192533@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69587&edit=1

 ID:                 69587
 Updated by:         cmb@php.net
 Reported by:        charlesw at ex-situ dot com
-Summary:            SPL objects (DateInterval) and isset
+Summary:            DateInterval properties and isset
-Status:             Open
+Status:             Verified
 Type:               Bug
-Package:            SPL related
+Package:            Date/time related
 Operating System:   CentOS / OSX / Other
 PHP Version:        5.6.8
 Block user comment: N
 Private report:     N

 New Comment:

DateTime doesn't belong to SPL, so I changed the package and the summary.

Otherwise verified: <http://3v4l.org/D7bcM>. Seems to be
related to bug #67621.


Previous Comments:
------------------------------------------------------------------------
[2015-05-06 19:22:22] charlesw at ex-situ dot com

Description:
------------
Testing public properties on DateInterval objects with isset returns false even when they contain
data. Running a print_r or var_dump on the object BEFORE testing isset will provide the desired
result.

Test script:
---------------
$currentDate = new DateTime();
$targetDate = new DateTime('2015-03-05 11:11:11');
$interval = $currentDate->diff($targetDate);
// var_dump($interval); // Uncomment and isset will give the expected response
var_dump($interval->y);
var_dump($interval->m);
var_dump(isset($interval->y));
var_dump(isset($interval->m));


Expected result:
----------------
int(0)
int(2)
bool(true)
bool(true)


Actual result:
--------------
int(0)
int(2)
bool(false)
bool(false)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69587&edit=1


Thread (5 messages)

« previous php.bugs (#192533) next »