PHP 8.6.0 Beta 1 is available for testing

Throwable::getPrevious

(PHP 7, PHP 8)

Throwable::getPreviousDevuelve el objeto Throwable previo

Descripción

public function Throwable::getPrevious(): ? Throwable

Devuelve el objeto Throwable previo (por ejemplo, uno proporcionado como tercer parámetro de Exception::__construct() ).

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

Devuelve el objeto Throwable anterior si está disponible, o null si no lo está.

Véase también

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes 1 note

up
1
harry at upmind dot com
7 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;
 }
+add a note

AltStyle によって変換されたページ (->オリジナル) /