Skip to content
Snippets Groups Projects
Commit 01ce8081 authored by Jan Kuchař's avatar Jan Kuchař
Browse files

added support for variadic arguments for adding more exceptions at once

parent 1c446d0a
No related branches found
No related tags found
No related merge requests found
......@@ -11,9 +11,11 @@ trait SuppressedExceptions /* implements WithSuppressedExceptions */
private $suppressedExceptions = [];
public function addSuppressed(\Throwable $e): void
public function addSuppressed(\Throwable ...$exceptions): void
{
$this->suppressedExceptions[] = $e;
foreach($exceptions as $exception) {
$this->suppressedExceptions[] = $exception;
}
}
public function getSuppressed(): array
......
......@@ -27,9 +27,9 @@ interface WithSuppressedExceptions
* Note that programmer written code is also able to take advantage of calling this method in situations
* where there are multiple sibling exceptions and only one can be propagated.
*
* @param \Throwable $e the exception to be added to the list of suppressed exceptions
* @param \Throwable ...$exceptions the exception to be added to the list of suppressed exceptions
*/
public function addSuppressed(\Throwable $e): void;
public function addSuppressed(\Throwable ...$exceptions): void;
/**
* Returns an array containing all of the exceptions that were suppressed.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment