-
Notifications
You must be signed in to change notification settings - Fork 8k
Add DateInterval subclasses #13050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add DateInterval subclasses #13050
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,7 +248,7 @@ function timezone_abbreviations_list(): array {} | |
function timezone_version_get(): string {} | ||
|
||
/** @refcount 1 */ | ||
function date_interval_create_from_date_string(string $datetime): DateInterval|false {} | ||
function date_interval_create_from_date_string(string $datetime): DateTimeStringInterval|false {} | ||
|
||
/** @refcount 1 */ | ||
function date_interval_format(DateInterval $object, string $format): string {} | ||
|
@@ -668,12 +668,14 @@ public static function __set_state(array $array): DateTimeZone {} | |
|
||
class DateInterval | ||
{ | ||
public readonly bool $from_string; | ||
|
||
public function __construct(string $duration) {} | ||
|
||
/** | ||
* @tentative-return-type | ||
*/ | ||
public static function createFromDateString(string $datetime): DateInterval|false {} | ||
public static function createFromDateString(string $datetime): DateTimeStringInterval|false {} | ||
|
||
/** | ||
* @tentative-return-type | ||
|
@@ -692,6 +694,26 @@ public function __wakeup(): void {} | |
public static function __set_state(array $array): DateInterval {} | ||
} | ||
|
||
final class DateTimeStringInterval extends DateInterval | ||
{ | ||
public readonly ?string $date_string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. camelCase ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, using camelCase was better, but this is not easily possible because |
||
|
||
public function __construct(string $datetime) {} | ||
} | ||
|
||
final class DateTimeInterval extends DateInterval | ||
{ | ||
public readonly int $y; | ||
public readonly int $m; | ||
public readonly int $d; | ||
public readonly int $h; | ||
public readonly int $i; | ||
public readonly int $s; | ||
public readonly float $f; | ||
public readonly int $invert; | ||
public readonly int|false $days; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO -1 for false would be better than mixed types There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree here. |
||
} | ||
|
||
class DatePeriod implements IteratorAggregate | ||
{ | ||
/** | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're creating it, shouldn't it be
$fromString
now? And ditto with$date_string
inDateTimeStringInterval
?I am also unsure as to the new names...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I realized a bit too late that the consistent property name would be
$fromString
. On the other hand, this property is only kept for BC concerns (since from now on you'll know the type of the interval based on the class name), so renaming it defies the main purpose. I'm also fine with removing the property altogether if we think that its BC impact is negligible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the other names, I'm fine with finding better names/moving them under some namespace :)