CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

use null coalesce to suppress deprecation notice in php 8.1

Open munkiepus opened this issue 3 years ago • 2 comments

Signed-off-by: Tony Dunlop [email protected]

spotted a deprecation notice when running unit test with php 8.1

addresses the following:

RuntimeException: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated on line 726 in file /vendor/codeigniter/framework/system/core/Common.php

munkiepus avatar Apr 12 '22 14:04 munkiepus

hmm, just noticed the tests failed for php 5.x, is that still supported? might need to change the null coalesce for a ternary if is?

munkiepus avatar Apr 12 '22 16:04 munkiepus

Hello! Yes, we still aim at maintaining compatibility with PHP 5. But no worries, if we find there's a bug that we should handle, we can ensure that $str is a string in other ways.

The only way that this would happen is that either you are passing NULL as the value of $str, or that over that iteration, $str gets nulled by preg_replace() call.

Could you please share an example of how we could reproduce this?

gxgpet avatar Apr 12 '22 17:04 gxgpet