- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8k
Description
Description
With PHP 8.2, the following changes were applied:
- PHP: rfc:iterator_xyz_accept_array
- RFC: Make the iterator_*() family accept all iterables by TimWolla · Pull Request #8819 · php/php-src
As a result, iterable became an alias for Traversable|array, changing the result of reflection acquisition as mentioned here.
However, there's a problem. While Traversable|object becomes an error because it's redundant, iterable|object compiles without any issue. But if we resolve the alias of iterable|object, it becomes Traversable|object|array, which is an invalid expression for PHP's type declaration.
In fact, we encountered a bug where creating a mock of a class with a method that takes iterable|object as an argument in the mockery/mockery causes a compile error only in PHP 8.2 or later. Should this be fixed by prohibiting the declaration of iterable|object itself? Or is this intended behavior, and should be addressed on the library side?
class ExampleClass
{
    public function __invoke(iterable|object $arg): void
    {
    }
}// Type Traversable|object|array contains both object and a class type, which is redundant
$mock = \Mockery\Mockery::mock(Example::class);PHP Version
PHP 8.2
Operating System
No response