Re: ReflectionType for iterable / PHP 8.2
| From: | Juliette Reinders Folmer | Date: | Wed, 02 Nov 2022 18:54:12 +0000 |
| Subject: | Re: ReflectionType for iterable / PHP 8.2 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-118942@lists.php.net to get a copy of this message | ||
On 2-11-2022 18:46, Benjamin Morel wrote:
Hi internals, It just came to my attention that there is a change of behaviour between PHP 8.1 and 8.2 in the way iterable is decomposed, or not, into Traversable|array when reflected:Smile, Juliettefunction foo(): iterable {} function bar(): stdClass|iterable {} echo (new ReflectionFunction('foo'))->getReturnType(), PHP_EOL; echo (new ReflectionFunction('bar'))->getReturnType(), PHP_EOL;Output on PHP 8.1:iterable stdClass|iterableOutput on PHP 8.2:iterable stdClass|Traversable|arrayIs this expected behaviour? Or should I file a bug? I'm particularly surprised that it behaves this way on PHP 8.2 only in the presence of union types. Thank you, Benjamin That's a intentional behaviour change and related to this accepted PHP 8.2 RFC: https://wiki.php.net/rfc/iterator_xyz_accept_array