reactphp / promise

Promises/A implementation for PHP.
https://reactphp.org/promise/
MIT License
2.38k stars 146 forks source link

php 7.1 multiple exceptions using the pipe (|) character #205

Closed amir-khoshbakht closed 2 years ago

amir-khoshbakht commented 2 years ago

The behavior of the software is unexpected when I use several different types of Exceptions by pipe.

class FirstException extends Exception
{

}
class SecondException extends Exception
{

}

        $a = new Deferred();
        $a->reject(new Exception('test'));

        $a->promise()
            // this will cause TypeError
            ->otherwise(function (FirstException|SecondException $exception) {
               // no exception here
            })
            ->otherwise(function (Exception $exception) {
                // also no exception here
            })
            ->otherwise(function ($exception) {
                // type error exception occurs here
            });

the situation get worse when developer don't use : error_reporting(error_reporting() & ~E_DEPRECATED); PHP 8.0.11

amir-khoshbakht commented 2 years ago

it seems it is addressed here: https://github.com/reactphp/promise/pull/198 and here: https://github.com/reactphp/promise/issues/181