Skip to content

Commit

Permalink
Merge pull request #161 from antecedent/feature/php-8.4-replace-trigg…
Browse files Browse the repository at this point in the history
…er-error-use

PHP 8.4 | Silence deprecation for trigger_error()
  • Loading branch information
antecedent authored Sep 27, 2024
2 parents 91246c4 + a4ce4a3 commit 41249a2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/includes/TestUtils.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?php

class ExceptionNotThrown extends Exception {}
class WrongExceptionThrown extends Exception {}

function expectException($type, $callback)
{
try {
call_user_func($callback);
trigger_error("No exception thrown", E_USER_ERROR);
throw new ExceptionNotThrown('No exception thrown');
} catch (ExceptionNotThrown $e) {
// Rethrow the exception.
throw $e;
} catch (Exception $e) {
if (!$e instanceof $type) {
trigger_error("No exception of type $type thrown", E_USER_ERROR);
throw new WrongExceptionThrown("No exception of type $type thrown");
}
}
}

0 comments on commit 41249a2

Please sign in to comment.