@@ -77,13 +77,9 @@ public static function set(int $levels = E_WARNING | E_NOTICE) : void{
77
77
*
78
78
* @phpstan-return \Closure(int, string, string, int) : bool
79
79
*/
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 );
87
83
};
88
84
}
89
85
@@ -98,7 +94,7 @@ private static function handleNoticeAndWarning(int $severities) : \Closure{
98
94
* @throws \ErrorException
99
95
*/
100
96
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 );
102
98
try {
103
99
return $ closure ();
104
100
}finally {
@@ -117,7 +113,7 @@ public static function trap(\Closure $closure, int $levels = E_WARNING | E_NOTIC
117
113
* @throws \ErrorException
118
114
*/
119
115
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 );
121
117
try {
122
118
$ result = $ closure ();
123
119
if ($ result === false ){
0 commit comments