@@ -40,6 +40,13 @@ public function save($filename, int $flags = 0): void
40
40
41
41
// Create PDF
42
42
$ config = ['tempDir ' => $ this ->tempDir . '/mpdf ' ];
43
+ $ restoreHandler = false ;
44
+ if (PHP_VERSION_ID >= self ::$ temporaryVersionCheck ) {
45
+ // @codeCoverageIgnoreStart
46
+ set_error_handler (self ::specialErrorHandler (...));
47
+ $ restoreHandler = true ;
48
+ // @codeCoverageIgnoreEnd
49
+ }
43
50
$ pdf = $ this ->createExternalWriterInstance ($ config );
44
51
$ ortmp = $ orientation ;
45
52
$ pdf ->_setPageSize ($ paperSize , $ ortmp );
@@ -83,9 +90,30 @@ public function save($filename, int $flags = 0): void
83
90
$ str = $ pdf ->Output ('' , 'S ' );
84
91
fwrite ($ fileHandle , $ str );
85
92
93
+ if ($ restoreHandler ) {
94
+ restore_error_handler (); // @codeCoverageIgnore
95
+ }
86
96
parent ::restoreStateAfterSave ();
87
97
}
88
98
99
+ protected static int $ temporaryVersionCheck = 80500 ;
100
+
101
+ /**
102
+ * Temporary handler for Php8.5 waiting for Dompdf release.
103
+ *
104
+ * @codeCoverageIgnore
105
+ */
106
+ public function specialErrorHandler (int $ errno , string $ errstr , string $ filename , int $ lineno ): bool
107
+ {
108
+ if ($ errno === E_DEPRECATED ) {
109
+ if (preg_match ('/Providing an empty string is deprecated/ ' , $ errstr ) === 1 ) {
110
+ return true ;
111
+ }
112
+ }
113
+
114
+ return false ; // continue error handling
115
+ }
116
+
89
117
/**
90
118
* Convert inches to mm.
91
119
*/
0 commit comments