class Throwable
@psalm-immutable
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Hierarchy
- class \PHPUnit\Event\Code\Throwable
Expanded class hierarchy of Throwable
10 files declare their use of Throwable
- BeforeFirstTestMethodErrored.php in vendor/
phpunit/ phpunit/ src/ Event/ Events/ Test/ HookMethod/ BeforeFirstTestMethodErrored.php - DispatchingEmitter.php in vendor/
phpunit/ phpunit/ src/ Event/ Emitter/ DispatchingEmitter.php - Emitter.php in vendor/
phpunit/ phpunit/ src/ Event/ Emitter/ Emitter.php - Errored.php in vendor/
phpunit/ phpunit/ src/ Event/ Events/ Test/ Outcome/ Errored.php - Failed.php in vendor/
phpunit/ phpunit/ src/ Event/ Events/ Test/ Outcome/ Failed.php
4 string references to 'Throwable'
- Exporter::exportRegistry in vendor/
symfony/ var-exporter/ Internal/ Exporter.php - ThrowablePatch::doesNotExtendAThrowableClass in vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ ClassPatch/ ThrowablePatch.php - ThrowablePatch::implementsAThrowableInterface in vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ ClassPatch/ ThrowablePatch.php - ThrowPromise::isAValidThrowable in vendor/
phpspec/ prophecy/ src/ Prophecy/ Promise/ ThrowPromise.php
File
-
vendor/
phpunit/ phpunit/ src/ Event/ Value/ Throwable.php, line 20
Namespace
PHPUnit\Event\CodeView source
final class Throwable {
/**
* @psalm-var class-string
*/
private readonly string $className;
private readonly string $message;
private readonly string $description;
private readonly string $stackTrace;
private readonly ?Throwable $previous;
/**
* @psalm-param class-string $className
*/
public function __construct(string $className, string $message, string $description, string $stackTrace, ?self $previous) {
$this->className = $className;
$this->message = $message;
$this->description = $description;
$this->stackTrace = $stackTrace;
$this->previous = $previous;
}
/**
* @throws NoPreviousThrowableException
*/
public function asString() : string {
$buffer = $this->description();
if (!empty($this->stackTrace())) {
$buffer .= PHP_EOL . $this->stackTrace();
}
if ($this->hasPrevious()) {
$buffer .= PHP_EOL . 'Caused by' . PHP_EOL . $this->previous()
->asString();
}
return $buffer;
}
/**
* @psalm-return class-string
*/
public function className() : string {
return $this->className;
}
public function message() : string {
return $this->message;
}
public function description() : string {
return $this->description;
}
public function stackTrace() : string {
return $this->stackTrace;
}
/**
* @psalm-assert-if-true !null $this->previous
*/
public function hasPrevious() : bool {
return $this->previous !== null;
}
/**
* @throws NoPreviousThrowableException
*/
public function previous() : self {
if ($this->previous === null) {
throw new NoPreviousThrowableException();
}
return $this->previous;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
Throwable::$className | private | property | @psalm-var class-string |
Throwable::$description | private | property | |
Throwable::$message | private | property | |
Throwable::$previous | private | property | |
Throwable::$stackTrace | private | property | |
Throwable::asString | public | function | |
Throwable::className | public | function | @psalm-return class-string |
Throwable::description | public | function | |
Throwable::hasPrevious | public | function | @psalm-assert-if-true !null $this->previous |
Throwable::message | public | function | |
Throwable::previous | public | function | |
Throwable::stackTrace | public | function | |
Throwable::__construct | public | function | @psalm-param class-string $className |