Skip to content

Update CoreImmutableClasses.phpstub#5218

Merged
muglug merged 1 commit intovimeo:masterfrom
tarlepp:patch-2
Feb 14, 2021
Merged

Update CoreImmutableClasses.phpstub#5218
muglug merged 1 commit intovimeo:masterfrom
tarlepp:patch-2

Conversation

@tarlepp
Copy link
Copy Markdown
Contributor

@tarlepp tarlepp commented Feb 14, 2021

Fixes wrong parameter names - https://psalm.dev/r/8cfdb309d9

@psalm-github-bot
Copy link
Copy Markdown

I found these snippets:

https://psalm.dev/r/8cfdb309d9
<?php

// https://www.php.net/manual/en/datetimeimmutable.construct.php

// Correct
new DateTimeImmutable(timezone: new DateTimeZone('UTC'));
// Wrong
new DateTimeImmutable(tz: new DateTimeZone('UTC'));

// https://www.php.net/manual/en/datetimezone.construct.php

// Correct
new DateTimeZone(timezone: 'UTC');
// Wrong
new DateTimeZone(tz: 'UTC');

// See example from:
// https://3v4l.org/gsj5r
Psalm output (using commit a80d5b7):

ERROR: InvalidNamedArgument - 6:23 - Parameter $timezone does not exist on function DateTimeImmutable::__construct

ERROR: InvalidNamedArgument - 13:18 - Parameter $timezone does not exist on function DateTimeZone::__construct

@tarlepp
Copy link
Copy Markdown
Contributor Author

tarlepp commented Feb 14, 2021

Also I noticed that DateTime class is behaving the same way - https://psalm.dev/r/129b9fce2b - but that class doesn't have stub like that DateTimeImmutable has.

@psalm-github-bot
Copy link
Copy Markdown

I found these snippets:

https://psalm.dev/r/129b9fce2b
<?php

new DateTime(timezone: new DateTimeZone('UTC'));
Psalm output (using commit a80d5b7):

ERROR: InvalidNamedArgument - 3:14 - Parameter $timezone does not exist on function DateTime::__construct

@muglug muglug merged commit ede9510 into vimeo:master Feb 14, 2021
@muglug
Copy link
Copy Markdown
Collaborator

muglug commented Feb 14, 2021

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants