psalm icon indicating copy to clipboard operation
psalm copied to clipboard

Unexpected `InvalidNamedArgument` in `DateTime` constructor with `timezone` argument

Open vjik opened this issue 10 months ago • 1 comments

Example: https://psalm.dev/r/4bf2f97a7e

vjik avatar Apr 02 '24 06:04 vjik

I found these snippets:

https://psalm.dev/r/4bf2f97a7e
<?php

function createDate(): DateTime
{
    $tz = new DateTimeZone('GMT-7');
    return new DateTime(timezone: $tz);
}
Psalm output (using commit ef3b018):

ERROR: InvalidNamedArgument - 6:25 - Parameter $timezone does not exist on function DateTime::__construct

psalm-github-bot[bot] avatar Apr 02 '24 06:04 psalm-github-bot[bot]