Skip to content

Missing IntelliSense support for PHP 8.4 \DateTime & \DateTimeImmutable classes #841

Description

@gwythan

Hi,

I was just including the following classes released in my PHP 8.4 project, but PHP Tools does not recognise them:

DateTime::createFromTimestamp()
DateTime::getMicrosecond()
DateTime::setMicrosecond()
DateTimeImmutable::createFromTimestamp()
DateTimeImmutable::getMicrosecond()
DateTimeImmutable::setMicrosecond()

I'm not surprised you don't support them yet, because they are not documented in the manual, but I managed to obtain any parameters requirements by forcing some argument errors for the functions (if that helps!).

The following PHP8.4 examples with the \DateTime class produce no errors. The \DateTimeImmutable function arguments are exactly the same

$dt = \DateTime::createFromTimestamp(\microtime(true)); // New function createFromTimestamp()  expects exactly 1 argument, must be of type int|float between -9223372036854775808 and 9223372036854775807.999999

echo $dt->format('Y-m-d H:i:s u') . PHP_EOL; // prints whatever the current date-time is with microseconds

echo $dt->getMicrosecond() . PHP_EOL; // New function getMicrosecond() prints the current microseconds

$dt->setMicrosecond(0); // New function setMicrosecond() expects exactly 1 argument of type int between 0 and 999999

echo $dt->getMicrosecond(); // New function getMicrosecond() now prints integer zero that was set in the previous instruction

Kind regards.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions