PHP Velho Oeste 2024

Throwable::getPrevious

(PHP 7, PHP 8)

Throwable::getPreviousRetourne le Throwable précédent

Description

public Throwable::getPrevious(): ?Throwable

Retourne un Throwable précedent (par exemple, un fournit grâce au troisième paramètre de Exception::__construct()).

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne le Throwable précédent si disponible ou null sinon.

Voir aussi

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