Skip to content
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

False InvalidNamedArgument on 3rd LimitIterator Constructor Argument #8631

Closed
MaxBoeh opened this issue Oct 30, 2022 · 3 comments
Closed

False InvalidNamedArgument on 3rd LimitIterator Constructor Argument #8631

MaxBoeh opened this issue Oct 30, 2022 · 3 comments
Labels
easy problems Issues that can be fixed without background knowledge of Psalm good first issue Help wanted internal stubs/callmap

Comments

@MaxBoeh
Copy link

MaxBoeh commented Oct 30, 2022

The third argument of LimitIterator (php doc) is named $limit, however Psalm has a different opinion and outputs:

ERROR: InvalidNamedArgument - 5:49 - Parameter $limit does not exist on function LimitIterator::__construct

The first two arguments can be passed as named arguments without any trouble.

Example: https://psalm.dev/r/6f037a2c89

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/6f037a2c89
<?php

$source = new ArrayIterator([1,2,3,4]);

new LimitIterator(iterator: $source, offset: 0, limit: 10);
Psalm output (using commit 7c83878):

ERROR: InvalidNamedArgument - 5:49 - Parameter $limit does not exist on function LimitIterator::__construct

@orklah
Copy link
Collaborator

orklah commented Oct 30, 2022

Indeed, Psalm has it wrong: https://github.com/vimeo/psalm/blob/4.x/stubs/CoreGenericIterators.phpstub#L564

Could you fix this? :)

@orklah orklah added easy problems Issues that can be fixed without background knowledge of Psalm internal stubs/callmap Help wanted good first issue labels Oct 30, 2022
orklah added a commit that referenced this issue Oct 31, 2022
@weirdan
Copy link
Collaborator

weirdan commented Nov 19, 2022

Fixed in #8639

@weirdan weirdan closed this as completed Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy problems Issues that can be fixed without background knowledge of Psalm good first issue Help wanted internal stubs/callmap
Projects
None yet
Development

No branches or pull requests

3 participants