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

Feature request: allow transformation of generic array-syntax in IDE helper docblocks #1470

Closed
jnoordsij opened this issue Dec 5, 2022 · 5 comments

Comments

@jnoordsij
Copy link

Description

In #479 a resolver was introduced to interpret docblocks like \Illuminate\Database\Eloquent\Collection|\App\Account[] $accounts as \Illuminate\Database\Eloquent\Collection<\App\Account> $accounts.

It would be useful to also accept another pattern, namely \Illuminate\Database\Eloquent\Collection|array<\App\Account> $accounts and convert this. This pattern is the result of auto-correction by PHP_CodeSniffer using my current ruleset.

In (https://github.com/jnoordsij/larastan/tree/generalise-ide-helper-type-transformer) I made a first attempt at implementing this, but it currently seems to be resolving incorrectly for some other union types. It also contains tests for both transforms.

@szepeviktor
Copy link
Collaborator

Hello @jnoordsij! 👋🏻
The feature in #479 is not the nicest thing in the world.
Using a PHP generics compatible IDE is the sustainable solution.

@jnoordsij
Copy link
Author

@szepeviktor thanks for your quick reaction!

I totally agree, but looking at barryvdh/laravel-ide-helper#942, it seems like support for that won't land anytime soon, so I was hoping for a workaround.

@szepeviktor
Copy link
Collaborator

so I was hoping for a workaround.

You may get it anytime. Here we have a small community.

@canvural
Copy link
Collaborator

There is no plan to support this. It is a really old syntax. You can use the generic version instead \Illuminate\Database\Eloquent\Collection<int, \App\Account>

@canvural canvural closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2022
@jnoordsij
Copy link
Author

Update for those who find this: barryvdh/laravel-ide-helper#1298 has been merged in the Laravel IDE helper packages, so if you use the dev-master version of this package, you can automatically update your docblocks to use the new generic notation.

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

3 participants