diff options
author | William Desportes <williamdes@wdes.fr> | 2021-08-20 03:19:05 +0300 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2021-08-20 03:30:02 +0300 |
commit | 38c263359edc3437749206c082496211eaa95d7a (patch) | |
tree | 91d854c6a0e05961293050b4fbfcbc0199d4752b /libraries/classes/ErrorHandler.php | |
parent | af835bc52ced34f2ee183d9e1aa0bc5bb102da28 (diff) |
Ref #17084 - comment the code and add a new test case
And fix the modified test
Signed-off-by: William Desportes <williamdes@wdes.fr>
Diffstat (limited to 'libraries/classes/ErrorHandler.php')
-rw-r--r-- | libraries/classes/ErrorHandler.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libraries/classes/ErrorHandler.php b/libraries/classes/ErrorHandler.php index d1363f2f30..6a6084f445 100644 --- a/libraries/classes/ErrorHandler.php +++ b/libraries/classes/ErrorHandler.php @@ -151,13 +151,19 @@ class ErrorHandler /** * Pops recent errors from the storage * - * @param int $count Old error count + * @param int $count Old error count (amount of errors to splice) * - * @return Error[] + * @return Error[] The non spliced elements (total-$count) */ public function sliceErrors(int $count): array { + // store the errors before any operation, example number of items: 10 $errors = $this->getErrors(false); + + // before array_splice $this->errors has 10 elements + // cut out $count items out, let's say $count = 9 + // $errors will now contain 10 - 9 = 1 elements + // $this->errors will contain the 9 elements left $this->errors = array_splice($errors, 0, $count); return $errors; |