Skip to content

Commit cae9488

Browse files
committed
tidy
1 parent 78004a3 commit cae9488

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/ErrorToExceptionHandler.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,9 @@ public static function set(int $levels = E_WARNING | E_NOTICE) : void{
7777
*
7878
* @phpstan-return \Closure(int, string, string, int) : bool
7979
*/
80-
private static function handleNoticeAndWarning(int $severities) : \Closure{
81-
return function(int $severity, string $message, string $file, int $line) use ($severities) : bool{
82-
if(($severities & $severity) !== 0){
83-
throw new \ErrorException($message, 0, $severity, $file, $line);
84-
}
85-
86-
return false;
80+
private static function throwAll() : \Closure{
81+
return function(int $severity, string $message, string $file, int $line): bool{
82+
throw new \ErrorException($message, 0, $severity, $file, $line);
8783
};
8884
}
8985

@@ -98,7 +94,7 @@ private static function handleNoticeAndWarning(int $severities) : \Closure{
9894
* @throws \ErrorException
9995
*/
10096
public static function trap(\Closure $closure, int $levels = E_WARNING | E_NOTICE){
101-
set_error_handler(self::handleNoticeAndWarning($levels));
97+
set_error_handler(self::throwAll(), $levels);
10298
try{
10399
return $closure();
104100
}finally{
@@ -117,7 +113,7 @@ public static function trap(\Closure $closure, int $levels = E_WARNING | E_NOTIC
117113
* @throws \ErrorException
118114
*/
119115
public static function trapAndRemoveFalse(\Closure $closure, int $levels = E_WARNING | E_NOTICE){
120-
set_error_handler(self::handleNoticeAndWarning($levels));
116+
set_error_handler(self::throwAll(), $levels);
121117
try{
122118
$result = $closure();
123119
if($result === false){

0 commit comments

Comments
 (0)