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

PHPStan already supports array-key as template type variable bound #274

Merged
merged 2 commits into from
Jun 9, 2021

Conversation

ondrejmirtes
Copy link
Contributor

It's now even counter-productive to leave @phpstan-template there.

@greg0ire
Copy link
Member

greg0ire commented Jun 9, 2021

We are ignoring a message right now, and it just changed:

- Array (array<TKey, T>) does not accept key int.
+ Array (array<TKey of (int|string), T>) does not accept key int.

That's about

which is described at

* @psalm-var array<TKey,T>
* @var mixed[]
*/
private $elements;

I don't understand why it still fails… array<TKey of (int|string), T> should accept key int, shouldn't it?

@ondrejmirtes
Copy link
Contributor Author

I'll update the ignore, sorry.

The error message tells you that if the user has ArrayCollection<string, Foo>, the method add() will break the key type as it inserts an int.

greg0ire
greg0ire previously approved these changes Jun 9, 2021
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙂

@greg0ire
Copy link
Member

greg0ire commented Jun 9, 2021

🤔 didn't notice the Psalm issue, sorry! It's pre-existing it seems.

@greg0ire
Copy link
Member

greg0ire commented Jun 9, 2021

I'll ignore it in an extra commit.

@greg0ire greg0ire merged commit b33e58d into doctrine:1.6.x Jun 9, 2021
@greg0ire
Copy link
Member

greg0ire commented Jun 9, 2021

Thanks @ondrejmirtes !

@greg0ire greg0ire added this to the 1.6.8 milestone Jun 9, 2021
@ondrejmirtes
Copy link
Contributor Author

Thank you!

@ondrejmirtes ondrejmirtes deleted the fix-phpstan branch June 9, 2021 19:52
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Aug 11, 2021
greg0ire added a commit to greg0ire/doctrine-orm that referenced this pull request Aug 11, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants