-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Update 2020-03-23-doctrine-entity-typed-properties-with-php74.md #1065
Conversation
With `@var Collection<Trainer>`, PhpStan gives me (on level 6) - see https://stackoverflow.com/a/64242837/1668200 > Property ... with generic interface Doctrine\Common\Collections\Collection does not specify its types: TKey, T
Hi, thanks for PR. Beware, PHPStan is not always right. It's still an assumption tool. How do you know there is
Because there can be any class of |
By dumping it - see the stackoverflow link above. However, I didn't double check Doctrine's source code ;-)
Well, there could be any class, but in fact it is Other question: The next thing that's going to happen in this regard is the switch from today's annotations to PHP8's attributes - do you agree? If yes: When people are updating all their entities to PHP7.4's types, is there anything they could do to "prepare" for PHP8? |
I see. Thanks for explaining. Let's ship it then. |
I'd go with SOLID dependency inversion principle here. |
As for prepare for PHP 8, I'd use all the Rector sets from 5.6 to 7.4 and put them in CI. |
Well, symfony/maker-bundle v1.21.1 sees it like you :-) It produces: /**
* @return Collection|Bar[]
*/
public function getBars(): Collection
{
return $this->bars;
} |
😃 That's actually incorrect, as array of Bar[] is not a Collection object. |
To my last comment... I see the type must be technically invalid, so it works in both PHPStorm and PHPStan Saying that, you might like this @rectorphp rule... 😃 |
Sorry, haven't ever used rector, so I can't say something here ;-) |
Great :-) |
With
@var Collection<Trainer>
, PhpStan gives me (on level 6) - see https://stackoverflow.com/a/64242837/1668200Question/suggestion: Why do you suggest
Collection
here instead ofArrayCollection
? What's the difference?