15
15
use chillerlan \QRCode \Data \QRMatrix ;
16
16
use chillerlan \QRCode \QRCode ;
17
17
use chillerlan \Settings \SettingsContainerInterface ;
18
- use Exception ;
18
+ use ErrorException , Exception ;
19
19
20
20
use function array_values , count , extension_loaded , imagecolorallocate , imagecolortransparent , imagecreatetruecolor ,
21
21
imagedestroy , imagefilledellipse , imagefilledrectangle , imagegif , imagejpeg , imagepng , imagescale , in_array ,
22
- is_array , ob_end_clean , ob_get_contents , ob_start , range ;
22
+ is_array , ob_end_clean , ob_get_contents , ob_start , range , restore_error_handler , set_error_handler ;
23
23
use const IMG_BICUBIC ;
24
24
25
25
/**
@@ -90,8 +90,15 @@ protected function setModuleValues():void{
90
90
* @return string|resource|\GdImage
91
91
*
92
92
* @phan-suppress PhanUndeclaredTypeReturnType, PhanTypeMismatchReturn
93
+ * @throws \ErrorException
93
94
*/
94
95
public function dump (string $ file = null ){
96
+
97
+ /** @phan-suppress-next-line PhanTypeMismatchArgumentInternal */
98
+ set_error_handler (function (int $ severity , string $ msg , string $ file , int $ line ):void {
99
+ throw new ErrorException ($ msg , 0 , $ severity , $ file , $ line );
100
+ });
101
+
95
102
$ file ??= $ this ->options ->cachefile ;
96
103
97
104
// we're scaling the image up in order to draw crisp round circles, otherwise they appear square-y on small scales
@@ -126,6 +133,8 @@ public function dump(string $file = null){
126
133
}
127
134
128
135
if ($ this ->options ->returnResource ){
136
+ restore_error_handler ();
137
+
129
138
return $ this ->image ;
130
139
}
131
140
@@ -139,6 +148,8 @@ public function dump(string $file = null){
139
148
$ imageData = $ this ->base64encode ($ imageData , 'image/ ' .$ this ->options ->outputType );
140
149
}
141
150
151
+ restore_error_handler ();
152
+
142
153
return $ imageData ;
143
154
}
144
155
0 commit comments