-
Notifications
You must be signed in to change notification settings - Fork 428
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
Static analysis error with psalm due to missing @template tag #6198
Comments
Well, more precisely, Iterator has 2 templates. When it is implemented, a
Here, ObjectIterator seems to use int as an offset (because So you would have something like /**
* @template TValue
*
* @template-implements \Iterator<int, TValue>
*/ That way, users of ObjectIterator will still need to fill the TValue type for their own instantation/implementations I don't know the library enough but based on the name, it could even be /**
* @template TValue of object
*
* @template-implements \Iterator<int, TValue>
*/ to restrain the possible type of the template to objects only |
I see the |
it's used here: https://github.com/googleapis/google-cloud-php/blob/main/Storage/src/Bucket.php#L651, not sure if it's used in other places |
I'm sorry, could you please confirm the given link has |
Sorry, my answer was not clear. What I meant is that there is an annotation that is using ObjectIterator as if it had a template here: But ObjectIterator doesn't actually have one: So either the |
Note: this is not a blocker as we can psalm-suppress the error and the code actually works fine, but I'm reporting this here since it seems like an easy fix and others might encounter the same issue.
Environment details
Steps to reproduce
$objects = $bucket->objects(['prefix' => $gcs_path, 'fields' => 'items,nextPageToken']);
Details: vimeo/psalm#9744
Code example
Error as reported by psalm on that code:
Per vimeo/psalm#9744, this can be fixed by adding an
@template
annotation to the src/ObjectIterator.php class (I have verified this)The text was updated successfully, but these errors were encountered: