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

Add links to details or examples #665

Closed
tacman opened this issue Nov 29, 2023 · 2 comments
Closed

Add links to details or examples #665

tacman opened this issue Nov 29, 2023 · 2 comments

Comments

@tacman
Copy link

tacman commented Nov 29, 2023

Q A
Bug report? no
Feature request? yes

What a cool tool!

I'm getting this warning:

Usage of array type hint syntax in "Term[]" is disallowed, use generic type hint syntax instead.

It comes from the stubs created by the symfony maker

 bin/console make:entity Term
/**
 * @extends ServiceEntityRepository<Term>
 *
 * @method Term|null find($id, $lockMode = null, $lockVersion = null)
 * @method Term|null findOneBy(array $criteria, array $orderBy = null)
 * @method Term[]    findAll()
 * @method Term[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */

First, since it's coming from the Symfony generator and works with PhpStorm, I would think that it was in fact a good practice. If there's a better way, I'm interested. And that got me thinking, maybe you could add something like PHPStan that provides a link to some common errors and their solutions.

Thanks for your consideration, and for creating this!

@Jibbarth
Copy link
Collaborator

In this case, you should use

@method array<Term> findAll()

Or you can disable this insight 😉 (https://phpinsights.com/insights/code.html#disallow-array-type-hint-syntax)

@tacman
Copy link
Author

tacman commented Oct 13, 2024

Does either approach work? Symfony tends to follow best practices, but I've found generics confusing and keep waiting for a version of PHP that supports them natively. Like when attributes came out, I couldn't wait to rid my code of annotations, which often tripped me up.

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

2 participants