CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

fix: PHP 8.1 deprecated error in URI::ruri_string()

Open kenjis opened this issue 3 years ago • 2 comments

ltrim(): Passing null to parameter #1 ($string) of type string is deprecated

Steps to Reproduce In a controller:

echo $this->uri->ruri_string();

kenjis avatar Mar 17 '22 04:03 kenjis

I'm not sure if this should be the fix or it, or that we should default the property CI_Router::$directory to an empty string (''), as we expect anyway that to be a string.

Of course, this would imply for sure other 2 places to be changed as well, since we check for the NULLness of the property.

gxgpet avatar Mar 27 '22 17:03 gxgpet

instead string(), it should be an isset() like this: return ltrim(isset(load_class('Router', 'core')->directory), '/').implode('/', $this->rsegments);

slimdestro avatar Nov 10 '23 17:11 slimdestro