Skip to content

Singular DateTime::[get|set]Microsecond & no tentative return type #13486

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

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PHP NEWS

- Date:
. Added DateTime[Immutable]::createFromTimestamp. (Marc Bennewitz)
. Added DateTime[Immutable]::[get|set]Microseconds. (Marc Bennewitz)
. Added DateTime[Immutable]::[get|set]Microsecond. (Marc Bennewitz)

- DOM:
. Added DOMNode::compareDocumentPosition(). (nielsdos)
Expand Down
4 changes: 2 additions & 2 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ PHP 8.4 UPGRADE NOTES
- Date:
. Added static methods
DateTime[Immutable]::createFromTimestamp(int|float $timestamp): static.
. Added method DateTime[Immutable]::getMicroseconds(): int.
. Added method DateTime[Immutable]::getMicrosecond(): int.
. Added method
DateTime[Immutable]::setMicroseconds(int $microseconds): static.
DateTime[Immutable]::setMicrosecond(int $microsecond): static.

- DOM:
. Added constant DOMNode::DOCUMENT_POSITION_DISCONNECTED.
Expand Down
12 changes: 6 additions & 6 deletions ext/date/php_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -2377,15 +2377,15 @@ static void update_errors_warnings(timelib_error_container **last_errors) /* {{{
*last_errors = NULL;
} /* }}} */

static void php_date_set_time_fraction(timelib_time *time, int microseconds)
static void php_date_set_time_fraction(timelib_time *time, int microsecond)
{
time->us = microseconds;
time->us = microsecond;
}

static void php_date_get_current_time_with_fraction(time_t *sec, suseconds_t *usec)
{
#if HAVE_GETTIMEOFDAY
struct timeval tp = {0}; /* For setting microseconds */
struct timeval tp = {0}; /* For setting microsecond */

gettimeofday(&tp, NULL);
*sec = tp.tv_sec;
Expand Down Expand Up @@ -3855,7 +3855,7 @@ PHP_METHOD(DateTimeImmutable, setTimestamp)
/* }}} */

/* {{{ */
PHP_METHOD(DateTimeImmutable, setMicroseconds)
PHP_METHOD(DateTimeImmutable, setMicrosecond)
{
zval *object, new_object;
php_date_obj *dateobj, *new_dateobj;
Expand Down Expand Up @@ -3889,7 +3889,7 @@ PHP_METHOD(DateTimeImmutable, setMicroseconds)
/* }}} */

/* {{{ */
PHP_METHOD(DateTime, setMicroseconds)
PHP_METHOD(DateTime, setMicrosecond)
{
zval *object;
php_date_obj *dateobj;
Expand Down Expand Up @@ -3947,7 +3947,7 @@ PHP_FUNCTION(date_timestamp_get)
}
/* }}} */

PHP_METHOD(DateTime, getMicroseconds) /* {{{ */
PHP_METHOD(DateTime, getMicrosecond) /* {{{ */
{
zval *object;
php_date_obj *dateobj;
Expand Down
16 changes: 7 additions & 9 deletions ext/date/php_date.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ public function getOffset(): int;
/** @tentative-return-type */
public function getTimestamp(): int;

public function getMicrosecond(): int;

/** @tentative-return-type */
public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval;

Expand Down Expand Up @@ -412,8 +414,7 @@ public function setTimezone(DateTimeZone $timezone): DateTime {}
*/
public function getOffset(): int {}

/** @tentative-return-type */
public function getMicroseconds(): int {}
public function getMicrosecond(): int {}

/**
* @tentative-return-type
Expand All @@ -439,8 +440,7 @@ public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTime {
*/
public function setTimestamp(int $timestamp): DateTime {}

/** @tentative-return-type */
public function setMicroseconds(int $microseconds): static {}
public function setMicrosecond(int $microsecond): static {}

/**
* @tentative-return-type
Expand Down Expand Up @@ -510,10 +510,9 @@ public function getOffset(): int {}
public function getTimestamp(): int {}

/**
* @alias DateTime::getMicroseconds
* @tentative-return-type
* @alias DateTime::getMicrosecond
*/
public function getMicroseconds(): int {}
public function getMicrosecond(): int {}

/**
* @tentative-return-type
Expand Down Expand Up @@ -545,8 +544,7 @@ public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTimeIm
/** @tentative-return-type */
public function setTimestamp(int $timestamp): DateTimeImmutable {}

/** @tentative-return-type */
public function setMicroseconds(int $microseconds): static {}
public function setMicrosecond(int $microsecond): static {}

/** @tentative-return-type */
public static function createFromMutable(DateTime $object): static {}
Expand Down
29 changes: 16 additions & 13 deletions ext/date/php_date_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading