phpstan-src
phpstan-src copied to clipboard
Improve parameter type of SplObjectStorage::removeAll/Except
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 https://github.com/phpstan/phpstan/issues/9411