Skip to content

Conversation

schlndh
Copy link
Contributor

@schlndh schlndh commented Jan 28, 2024

See https://phpstan.org/r/bff03687-1f39-496b-a23e-0386bcb75362 . Ideally, removeNoIntersect should be reported as an issue since it is not possible for the removes to do anything. However, AFAIK there is no way to express such constraint in the current type system (i.e. I'd want to make sure that the key types of the two storages have a non-empty intersection).

I considered using \SplObjectStorage<covariant TObject, *>|\SplObjectStorage<contravariant TObject, *>, which would report removeNoIntersect, but it would lead to a false positive in removePossibleIntersect. And \SplObjectStorage<*, *> seems to have been the intention of the previous stub.

Fixes phpstan/phpstan#9411

@ondrejmirtes ondrejmirtes force-pushed the fix-SplObjectStorageRemove branch from 0c34325 to af13ca6 Compare March 20, 2024 10:10
@ondrejmirtes ondrejmirtes merged commit e8e466d into phpstan:1.10.x Mar 20, 2024
@ondrejmirtes
Copy link
Member

Nice, thanks a lot!

@schlndh schlndh deleted the fix-SplObjectStorageRemove branch March 20, 2024 10:51
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.

2 participants