Throwable::getPrevious

(PHP 7)

Throwable::getPreviousZwraca poprzedni Throwable

Opis

abstract public Throwable::getPrevious ( void ) : Throwable

Zwraca dowolny poprzedni Throwable (na przykład ten podany jako trzeci argument do Exception::__construct()).

Parametry

Ta funkcja nie posiada parametrów.

Zwracane wartości

Zwraca poprzedni Throwable lub NULL jeśli nie jest dostępny.

Zobacz też:

add a note add a note

User Contributed Notes 1 note

up
0
harry at upmind dot com
5 years ago
/**
     * Gets sequential array of all previously-chained errors
     *
     * @param Throwable $error
     *
     * @return Throwable[]
     */
    function getChain(Throwable $error) : array
    {
        $chain = [];

        do {
            $chain[] = $error;
        } while ($error = $error->getPrevious());

        return $chain;
    }
To Top