Req #75113 [Opn->Ana]: adding missing DatePeriod::getRecurrences method

From: Date: Thu, 24 Aug 2017 14:49:53 +0000
Subject: Req #75113 [Opn->Ana]: adding missing DatePeriod::getRecurrences method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210793@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75113&edit=1 ID: 75113 Updated by: requinix@php.net Reported by: nyamsprod at gmail dot com Summary: adding missing DatePeriod::getRecurrences method -Status: Open +Status: Analyzed Type: Feature/Change Request Package: Date/time related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: There are a few undocumented dynamic properties, including one for the number of recurrences (which is calculated when using an end date). https://3v4l.org/iGAV1 But don't go using them just yet. HHVM implements a few properties in the class definition but makes them private: $start, $interval, $end, $options, $current, $recurrances [sic], and $iterKey. PHP's properties are created on the object and not defined on the class. - ReflectionObject: https://3v4l.org/8BKTW - ReflectionClass: https://3v4l.org/CfZuJ Since there's already getDateInterval, getEndDate, and getStartDate, maybe making the properties real and private and creating a getRecurrences would be best. (HHVM does not have a getRecurr[ae]nces method either) Previous Comments: ------------------------------------------------------------------------ [2017-08-24 11:32:29] nyamsprod at gmail dot com Description: ------------ Currently it is not possible to access the DatePeriod recurrences property when no endDate is specified. Expected result: ---------------- $start = new DateTimeImmutable('2012-07-01'); $end = new DateTimeImmutable('2012-07-31'); $interval = new DateInterval('P7D'); $recurrences = 4; $periodWithRecurrences = new DatePeriod($start, $interval, $recurrences); $periodWithRecurrences->getRecurrences(); //returns 4 $periodWithRecurrences->getEndDate(); //returns null $periodWithoutRecurrences = new DatePeriod($start, $interval, $end); $periodWithoutRecurrences->getRecurrences(); //returns null $periodWithoutRecurrences->getEndDate(); //returns DateTimeInterface object equivalent to $end Actual result: -------------- Fatal error: Uncaught Error: Call to undefined method DatePeriod::getRecurrences() ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75113&edit=1

« previous php.bugs (#210793) next »