php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65672 Broken classes inherited from DatePeriod
Submitted: 2013-09-14 01:32 UTC Modified: 2017-01-16 06:58 UTC
Votes:17
Avg. Score:4.2 ± 1.4
Reproduced:14 of 16 (87.5%)
Same Version:5 (35.7%)
Same OS:9 (64.3%)
From: hosiplan at gmail dot com Assigned:
Status: Open Package: Date/time related
PHP Version: 7.1 OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-09-14 01:32 UTC] hosiplan at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/class.dateperiod
---

Classes inherited from DatePeriod class cannot use their declared properties

Test script:
---------------
<?php

class Period extends \DatePeriod
{
	public $test;
}

$p = new Period(new \DateTime('now'), new \DateInterval('P1Y'), new \DateTime('tomorrow'));
$p->test = FALSE;



Expected result:
----------------
no error

Actual result:
--------------
Fatal error: main(): Writing to DatePeriod properties is unsupported in 
period.phpt on line 9

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-29 14:44 UTC] info at vdespa dot de
I can confirm this bug. It seems to introduce a backward incompatibility and it seems not to be properly documented in the changelog.

Looks like trying to fix bug #53437 (Crash when using unserialized DatePeriod instance) generated this issue. (https://bugs.php.net/bug.php?id=53437)
 [2017-01-16 06:58 UTC] heiglandreas@php.net
-PHP Version: 5.5.3 +PHP Version: 7.1
 [2017-01-16 06:58 UTC] heiglandreas@php.net
Looks like this never actually worked[1], so it can't have been introduced by a bugfix…

[1] https://3v4l.org/0oIl7
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Feb 26 10:01:55 2017 UTC