-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Should PhpStorm complete in foreach? #83
Comments
Thanks for calling attention to this! The support for generics in PhpStorm is limited right now, but it looks like they added support for this in 2021.2.1 (see the release notes here; it's the note "Support inference based on It works when I change /**
* @extends AbstractCollection<Specific>
* @implements IteratorAggregate<Specific>
*/
class SpecificCollection extends AbstractCollection implements IteratorAggregate
{
public function getType(): string
{
return Specific::class;
}
} However, this should work without making this change because I'll do some more digging around to see if I can figure out whether I need to change something in the library or whether this is a limitation in PhpStorm. |
PhpStorm 2021.3 has the same issue. Adding I'm fairly sure this is a PhpStorm limitation and relates to these issues: |
It looks like this is now working in PhpStorm, especially after I did an audit of all the type annotations and updated them in version 2.0.0. I'm closing this issue now, but if you still have problems, let me know. |
PhpStorm 2021.2 support for generics in PHP. But when I use foreach above collection PhpStomr does not recognize correct element type.
Should PhpStorm autocomplete inner types in foreach?
It is important when I want to change method names.
Example code
The text was updated successfully, but these errors were encountered: