Re: [PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Marco Pivetta
Hey Tim, On Tue, 26 Nov 2024 at 12:07, Tim Düsterhus wrote: > it was *semantically* identical, > That's the most important bit, thanks! That means that upstream Psalm may translate back/forth from it into a uniform version :-) To Eugene: consider posting this to the Psalm issue tracker. Marco

Re: [PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Tim Düsterhus
Hi Am 2024-11-26 12:00, schrieb Marco Pivetta: Is `Traversable|array` an alias of `iterable`? Is it **always** like that? Since PHP 8.2 `iterable` is internally transformed into `Traversable|array` on the engine level: https://github.com/php/php-src/pull/7309. `iterable` no longer exists as

Re: [PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Marco Pivetta
Hey Tim, On Tue, 26 Nov 2024 at 10:50, Tim Düsterhus wrote: > Hi > > Am 2024-11-26 10:40, schrieb Eugene Sidelnyk: > > I think it would make sense to change the signature of iterator_count > > to > > accept iterable rather than array|Traversable so that static analysis > > tools > > would pick i

Re: [PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Tim Düsterhus
Hi Am 2024-11-26 10:40, schrieb Eugene Sidelnyk: I think it would make sense to change the signature of iterator_count to accept iterable rather than array|Traversable so that static analysis tools would pick it up better That sounds like a bug in Psalm's understanding of union types. PHPSta

[PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Eugene Sidelnyk
Hello internals! Currently, iterator_count has the following signature: iterator_count(Traversable|array $iterator): int If we try to use iterable type and pass it to iterator_count function, we'd get following static analysis error: Argument 1 of iterator_count expects Traversable|array, but