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

Support for @template T of array{foo: int} in PHPDoc comments #3128

Open
barronhsu15 opened this issue Dec 10, 2024 · 0 comments
Open

Support for @template T of array{foo: int} in PHPDoc comments #3128

barronhsu15 opened this issue Dec 10, 2024 · 0 comments

Comments

@barronhsu15
Copy link

Feature description or problem with existing feature
First of all, thank you for creating such an amazing tool! Intelephense has been incredibly helpful for my PHP development.

Currently, I noticed that Intelephense doesn't support @template T of array{foo: int} in PHPDoc comments. adding support for it would make Intelephense even more powerful and compatible with modern PHP practices.

Describe the solution you'd like
I would love to see Intelephense support parsing and understanding @template T of array{foo: int} syntax in PHPDoc comments. Specifically:

  1. Recognize and validate the structure of arrays defined with this syntax.
  2. Provide accurate type inference and autocompletion when such templates are used in functions or classes.
/**
 * @template T of array{foo: int}
 *
 * @param T $foo
 * @return int
 */
function foo($foo)
{
    return $foo['foo'];
}

Additional context
Thank you for considering this request, and I truly appreciate all the effort that goes into maintaining and improving this tool.

Currently, when using @template T of array{foo: int} in PHPDoc comments and applying it to a function, Intelephense infers the parameter and return types as mixed. This can be seen in the attached screenshot:
image

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

No branches or pull requests

1 participant