@@ -213,6 +213,10 @@ public function errorHandler(int $severity, string $message, ?string $file = nul
213
213
return true ;
214
214
}
215
215
216
+ if ($ this ->isImplicitNullableDeprecationError ($ message , $ file , $ line )) {
217
+ return true ;
218
+ }
219
+
216
220
if (! $ this ->config ->logDeprecations || (bool ) env ('CODEIGNITER_SCREAM_DEPRECATIONS ' )) {
217
221
throw new ErrorException ($ message , 0 , $ severity , $ file , $ line );
218
222
}
@@ -253,6 +257,38 @@ private function isSessionSidDeprecationError(string $message, ?string $file = n
253
257
return false ;
254
258
}
255
259
260
+ /**
261
+ * Workaround to implicit nullable deprecation errors in PHP 8.4.
262
+ *
263
+ * "Implicitly marking parameter $xxx as nullable is deprecated,
264
+ * the explicit nullable type must be used instead"
265
+ *
266
+ * @TODO remove this before v4.6.0 release
267
+ */
268
+ private function isImplicitNullableDeprecationError (string $ message , ?string $ file = null , ?int $ line = null ): bool
269
+ {
270
+ if (
271
+ PHP_VERSION_ID >= 80400
272
+ && str_contains ($ message , 'the explicit nullable type must be used instead ' )
273
+ // Only Kint and Faker, which cause this error, are logged.
274
+ && (str_starts_with ($ message , 'Kint \\' ) || str_starts_with ($ message , 'Faker \\' ))
275
+ ) {
276
+ log_message (
277
+ LogLevel::WARNING ,
278
+ '[DEPRECATED] {message} in {errFile} on line {errLine}. ' ,
279
+ [
280
+ 'message ' => $ message ,
281
+ 'errFile ' => clean_path ($ file ?? '' ),
282
+ 'errLine ' => $ line ?? 0 ,
283
+ ]
284
+ );
285
+
286
+ return true ;
287
+ }
288
+
289
+ return false ;
290
+ }
291
+
256
292
/**
257
293
* Checks to see if any errors have happened during shutdown that
258
294
* need to be caught and handle them.
0 commit comments